2011-01-03 9 views
7

あなたはJavaラッピングを持つWindows用のバーチャルジョイスティックについて聞いたことがありますか?バーチャルジョイスティックin Java

私はPPJOYを試してみましたが、うまくいきましたが、JNIを使​​用してJavaから動作させる必要があり、当面は簡単ではないようです。

ありがとうございます!

+1

おそらくPPJoyがあなたの最高の賭けですが、私は誰かがあなたのためのより良い解決策を願っています! – Brad

+0

ありがとう、私は知っている*それは素晴らしい作品です。また、Cコードで実装するのは比較的簡単です。しかし、それは私がJavaで必要とすることです: -/ –

+0

多分、それはJNIの代わりにJNAまたはNativeCallを使用して動作します。うーん。 –

答えて

6

ありがとうございます。私は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です。