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

10-08 23:55