问题
Have you heard of a virtual joystick for Windows that has Java wrappings?
I've trying PPJOY, and it works great, but then I'll need to use JNI to get it working from Java and that doesn't seem easy for the time being.
Thanks!
回答1:
There you are. I've made a Java wrapper for PPJoy. And it's really easy to use. See:
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();
}
The source code and binaries may be found here.
回答2:
I've found this :
http://www.hardcode.de/jxinput/
Not tried yet though. Hope it helps!
来源:https://stackoverflow.com/questions/4589380/virtual-joystick-in-java