Java 中的虚拟操纵杆

发布于 2024-10-10 08:15:39 字数 114 浏览 4 评论 0原文

您听说过带有 Java 包装的 Windows 虚拟操纵杆吗?

我尝试过 PPJOY,它工作得很好,但随后我需要使用 JNI 来让它在 Java 中工作,目前看来这并不容易。

谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

秋风の叶未落 2024-10-17 08:15:39

你就在那里。我为 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();
}

源代码和二进制文件可以在此处找到。

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.

混吃等死 2024-10-17 08:15:39

我发现了这个:

http://www.hardcode.de/jxinput/

尚未尝试。希望有帮助!

I've found this :

http://www.hardcode.de/jxinput/

Not tried yet though. Hope it helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文