WPF 中的 XNA GamePad 输入触发事件
我正在尝试在 WPF 中使用 xbox 控制器,但似乎遇到了问题。
我能够使用游戏手柄从 XNA 获取输入
Microsoft.Xna.Framework.Input.GamePadState currentState = Microsoft.Xna.Framework.Input.GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.One);
,但我不知道如何让 WPF 在按下控制器上的某些内容时触发“KeyPressed”事件。
我尝试做一些研究,但我找不到任何太具体的东西,或者即使我做了,大多数时候也没有得到答复。我在下面找到了这个,但它似乎没有回答你实际上如何做到这一点:
I'm trying to use an xbox controller in WPF and I seem to have run into a problem.
I was able to grab the input from XNA using a gamepad
Microsoft.Xna.Framework.Input.GamePadState currentState = Microsoft.Xna.Framework.Input.GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.One);
but I can't figure out how to make WPF trigger the say "KeyPressed" event when something on the controller is pressed.
I tried doing some research but I couldn't find anything too specific or if I do they most of the time aren't answered. I found this below but it doesn't seem to answer how you could actually do this:
Can you program buttons on a gamepad to bind with mouse/keybourd input?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要查看每个按钮以查看它们是否被按下。
You will need to look at each of the buttons to see if they were pushed.
正如另一个答案中所述,您可以使用以下方法检查游戏手柄的状态:
您还可以使用
您可能想要创建按钮到按键映射的字典,但这取决于您。
一旦您知道如何检查游戏手柄状态,您的问题就会减少为 这个问题。查看已接受的答案。
As said in another answer, you can check the state of the gamepad with:
You can also use
You may want to create a dictionary of Buttons to Key mappings, but that is up to you.
Once you know how to check the gamepad state, your question reduces to this question. See the accepted answer.