异步读取键盘输入和使用 DirectInput 有什么区别?

发布于 2024-08-22 03:53:49 字数 74 浏览 4 评论 0原文

DirectInput 需要大量初始化函数等来检测键盘输入,那么使用它而不是 GetAsyncKeyState() 函数有什么好处呢?

DirectInput requires a lot of initialization functions and cetera to detect keyboard input, so what benefits are there to using it rather than the GetAsyncKeyState() function?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

走野 2024-08-29 03:53:49

Wikipedia 提供...

DirectInput 和 XInput 比普通 Win32 输入事件有优势

  • :即使应用程序位于后台,也可以从输入设备检索数据。
  • 它们为任何类型的输入设备以及力反馈提供全面支持。
  • 通过动作映射,应用程序可以检索输入数据,而无需知道使用哪种设备来生成数据。

基本上,DirectInput 为您提供了更大的灵活性,可以摆脱键盘的束缚。如果您打算使用键盘,那么使用 GetAsyncKeyState() 可能没有什么坏处

Courtesy of Wikipedia...

DirectInput and XInput have benefits over normal Win32 input events:

  • They enable an application to retrieve data from input devices even when the application is in the background.
  • They provide full support for any type of input device, as well as for force feedback.
  • Through action mapping, applications can retrieve input data without needing to know what kind of device is being used to generate it.

Basically DirectInput gives you more flexibility to move away from the keyboard. If the keyboard is all you ever plan on using then there is probably no harm in using GetAsyncKeyState()

归途 2024-08-29 03:53:49

另请参阅我应该使用 DirectInput 还是 Windows 消息循环?

微软现在似乎建议尽可能使用 Windows 消息来处理输入数据。

Also see Should I use DirectInput or Windows message loop?

Microsoft seem to recommend just using windows messages to handle input data where possible now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文