Note that there are some explanatory texts on larger screens.

plurals
  1. POCan I simulate game pad button presses with Java's Robot class (Java.awt.robot)?
    text
    copied!<p>I'm using an Arduino Uno to hook a (genuine) SNES controller to a computer via USB or Bluetooth.</p> <p>The Arduino captures the controller's button presses and releases using the <a href="http://code.google.com/p/nespad/" rel="nofollow">snespad library</a>. 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 <a href="http://rxtx.qbang.org/wiki/index.php/Main_Page" rel="nofollow">rxtx library</a>. Finally, a <a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Robot.html" rel="nofollow">Java robot</a> simulates key presses using the <a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Robot.html#keyPress%28int%29" rel="nofollow">keyPress</a> and <a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Robot.html#keyRelease%28int%29" rel="nofollow">keyRelease</a>.</p> <p>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.</p> <p>Java doesn't appear to have any game pad <a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/event/KeyEvent.html" rel="nofollow">KeyEvents</a>. When I say "game pad KeyEvent," I mean something like what the Android SDK has: <a href="http://developer.android.com/reference/android/view/KeyEvent.html" rel="nofollow">http://developer.android.com/reference/android/view/KeyEvent.html</a> (ctrl+f "game pad" or "button".)</p> <p>My question is, is there a way to simulate game pad button presses instead of keystrokes using Java's robot class?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload