6

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 (e.g. '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?

keattsd
  • 69
  • 5

2 Answers2

0

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

cafebabe1991
  • 4,928
  • 2
  • 34
  • 42
-1

You should be able to easily from my expierience the gamepad buttons are mapped to keyboard buttons the only mapping i know it i,j,k,l go to looking around and w,a,s,d go to moving around

Jeremiah
  • 99
  • 1
  • 9