Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 5 down vote accepted

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.

share|improve this answer
This is perfect! It's so much easier than what I wanted since this is within the emulator itself. – Doppelganger Jun 27 '13 at 20:25

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
share|improve this answer
Thanks. jstest worked well for me. In my case, the path was /dev/input/js0. – Drew Noakes Mar 27 '14 at 16:02

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

joyst () {
    jscal  $js
    jstest $js
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.