处理游戏中鼠标和键盘输入的不同选项 [英] Different options to handle mouse and keyboard input in a game

查看:108
本文介绍了处理游戏中鼠标和键盘输入的不同选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始涉足DirectX,以及游戏编程。我已经开始充实该程序的基础知识,现在我希望开始处理输入。我现在的方法是在主循环中调用一个函数,该函数使用GetDeviceState(简而言之)及其各自的参数来查询鼠标和键盘。但是,在深入了解DirectInput之后,我看到许多人说过不建议再使用DirectInput。微软似乎也同意!

I've recently been getting into DirectX and along with that, game programming. I've started fleshing out my base of the program and now I'm looking to get into handling input. The way I have right now is through calling a function in my main loop which queries the mouse and keyboard using GetDeviceState (in a nutshell) and their respective arguments; however, after doing some more in depth reading into DirectInput, I've seen many people saying how DirectInput is NOT recommended for use anymore. Microsoft seems to agree too!

我正在寻找实现此目的的其他方法,以及关于它们的优缺点的讨论(没有必要,但是欢迎,我可以研究)

What I am looking for are other ways to go about doing this, along with discussion on the pros and cons about them (not necessary, but welcome. I can research)

推荐答案

只需使用GetMessage或PeekMessage,请参见 should-i-use-directinput-or-windows-message-loop
for一个例子。

Just use GetMessage or PeekMessage, see should-i-use-directinput-or-windows-message-loop for an example.

这篇关于处理游戏中鼠标和键盘输入的不同选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆