gpt4 book ai didi

java - Java 中的虚拟操纵杆

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:24:02 26 4
gpt4 key购买 nike

您是否听说过具有 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com