Can you program buttons on a gamepad to bind with mouse/keyboard input?

廉价感情. 提交于 2019-12-13 03:46:48

问题


I was wondering if there was a way to write a program that could bind buttons on a gamepad to certain mouse/keyboard inputs. For example moving an analog stick on the gamepad to move the mouse, and clicking certain buttons on the gamepad == pressing keyboard keys or mouse clicks. Which language would be able to do this?


回答1:


Sure, its possible. You just need some sort of Joystick interface that allows you to read its actions and then your program can translate it into other actions sent to the system.

For example, in Java, you can use Jinput to read the joystick and then use jawa.awt.Robot to move the mouse. You may want to use some movement controls, such as a quadratic gradient to speedup/slowdown the mouse movements the longer the joystick is pushed in one direction, for instance.




回答2:


Of course you can do this. The issue is getting the responsiveness to be almost immediate. You can do this with any language that provides a way to talk to input devices.

  1. Listen for input from gamepad.

  2. If input received, map to corresponding button.

  3. Suppress the gamepad input.



来源:https://stackoverflow.com/questions/982446/can-you-program-buttons-on-a-gamepad-to-bind-with-mouse-keyboard-input

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!