11

Here's my situation: I have a Raspberry Pi with Raspbian installed on it. I also have RetroArch installed and a simple USB gamepad hooked up. Everything works fine, but I wanted to set it up so that pressing a key combination (ex L1+L2+R1+R2) would gracefully exit the emulator so that I don't have to keep a keyboard around. RetroArch's default key to gracefully exit is ESC, and I can't remap it to a key combination due to a limitation in RetroArch (I could, however, remap it to a single gamepad key).

So I was wondering if there were any utilities out there that could listen to the gamepad's key presses and, when a certain combination is pressed, performs an action (sending the ESC key to the emulator). Or is there an easier way to achieve what I want and I'm just being silly?

EDIT: Now that I think about it, it would also be nice if I could have a different key combination execute a bash script that starts the emulator so that I could start it without a keyboard as well.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Doppelganger
  • 115
  • 1
  • 1
  • 6

3 Answers3

8

Give jstest a try. This article discusses its use, titled: flightgear.org - Input device. Appears to be installed by default in most distros. Also, here's a link to the jstest man page.

Basically you have to determine what device the joystick is being assigned. Look in the dmesg log file after you plug it in to get this info. Might be something like /dev/input0.

$ dmesg | grep Joystick
input0: USB HID v1.00 Joystick [SAITEK CYBORG 3D USB] on usb2:3.0 

Then run this command:

$ jstest /dev/input0
slm
  • 363,520
  • 117
  • 767
  • 871
6

This looks like a common problem with RetroPie/Emulation station.

They address it in the RetroPie-Setup Wiki: https://github.com/petrockblog/RetroPie-Setup/wiki/EmulationStation#my-emulator-wont-close-through-my-gamepad

It should just require editing your RetroArch config file to add a line:

input_exit_emulator_btn = “6″

Where "6" is the gamepad button identifier.


If you want to make it work with a key combination, you can instead add the following lines: (from http://forum.themaister.net/viewtopic.php?pid=1065#p1065)

input_enable_hotkey_btn = 1
input_exit_emulator_btn = 2

This makes it so that you need to press button 1 to "unlock" hotkeys, and press 2 at the same time to quit.

Doppelganger
  • 115
  • 1
  • 1
  • 6
0

Put this in you .rc file (.bashrc if you are a bash user, then source .bashrc).

joyst () {
    js='/dev/input/js0'
    jscal  $js
    jstest $js
}
Emanuel Berg
  • 6,763
  • 7
  • 43
  • 65