我正在研究 Java 地图项目。我使用 Logitechextreme 3D pro Joystick 和JInput库。单击操纵杆上的按钮时,我想将文本写入控制台。但我不能这样做,有人可以帮忙吗?
1 回答
You can adapt the JInput example found here which shows "how to read the values in a polling loop for the first mouse". In line 28 simply change the controller type to STICK
, as it is defined in the Controller
class of that library:
/**
* Stick controller, such as a joystick or flightstick.
*/
public static final Type STICK = new Type("Stick");
If you execute the example you will retrieve "the components of the controller" (see line 46, /* Get all the axis and buttons */
).
With those components at hand, you can retrieve properties or data from the connected (joystick) controller, in your case not a mouse but a joystick.
Hint: Before modifying the example, you can just start to experiment with the "first mouse" connected to your machine.