您是否听说过具有 Java 封装的 Windows 虚拟操纵杆?
我正在尝试 PPJOY,它工作得很好,但是我需要使用 JNI 让它在 Java 中工作,目前看来这并不容易。
谢谢!
最佳答案
你来了。我为 PPJoy 制作了一个 Java 包装器。而且它真的很容易使用。见:
try {
/*
* Try to create a new joystick.
*/
Joystick joystick = new Joystick();
try {
/*
* Set joystick values
*/
/*
* Set analog values for Axis X/Y/Z,
* Rotation X/Y/Z, Slider, Dial. Overall 8 axes.
*
* Here we set the Z Axis to maximum.
*/
joystick.analog[Joystick.ANALOG_AXIS_Z] = Joystick.ANALOG_MAX;
/*
* Set digital values for the buttons. Overall 16 buttons.
*
* Here we turn on the 13-th button
*/
joystick.digital[12] = Joystick.DIGITAL_ON;
/*
* Send the data to the joystick. Keep in mind,
* that the send method may throw a JoystickException
*/
joystick.send();
} finally {
joystick.close();
}
} catch (JoystickException e) {
e.printStackTrace();
}
可以找到源代码和二进制文件 here .
关于java - Java 中的虚拟操纵杆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4589380/