I'm using an Arduino Uno to hook a (genuine) SNES controller to a computer via USB or Bluetooth.
The Arduino captures the controller's button presses and releases using the snespad library . It communicates button presses and releases as characters (eg 'a' for pressing A, 'A' for releasing 'A'). Next, a Java program listens to the serial output using the rxtx library . Finally, a Java robot simulates key presses using the keyPress and keyRelease .
Unfortunately, this approach has a few drawbacks. The main issue is key mapping. I kind of arbitrarily decided which buttons would be which keyboard keys.
Java doesn't appear to have any game pad KeyEvents . When I say "game pad KeyEvent," I mean something like what the Android SDK has: http://developer.android.com/reference/android/view/KeyEvent.html (ctrl+f "game pad" or "button".)
My question is, is there a way to simulate game pad button presses instead of keystrokes using Java's robot class?
USING THE ROBOT CLASS IN JAVA
You can create virtual keypresses/releases in the following way...
Robot robo=new Robot();
robo.keyPress(KeyEvent.VK_A);
//don't forget to release it else you'll land up in infinite loop
robo.KeyRelease(KeyEvent.VK_A);
cheers
你应该可以轻松地从我的expierience游戏手柄按钮被映射到键盘按钮唯一的映射我知道它,我,j,k,我去环顾四周和w,a,s,d去四处走动
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.