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.

4 Answers 4

10

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
2
  • 3
    Thanks. jstest worked well for me. In my case, the path was /dev/input/js0. Commented Mar 27, 2014 at 16:02
  • on Fedora 39, $ sudo dnf install jstest-gtk, check by $ jstest-gtk.
    – mario
    Commented May 22 at 17:37
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.

1
  • This is perfect! It's so much easier than what I wanted since this is within the emulator itself. Commented Jun 27, 2013 at 20:25
1

Updating the jstest answer slightly... Using the joystick I just configured as an example.

In Debian (and most derivatives) jstest is in the joystick package.

apt install joystick

Then we check the kernel messages to see what human-readable description the joystick device provided. It's between the square brackets. (I don't find a stable specification for this message, so you may find more, fewer, or no pairs of square brackets in your output.)

dmesg | grep -i joystick

    [14265.976322] logitech 0003:046D:C215.0005: input,
    hidraw4: USB HID v1.10 Joystick [Logitech Logitech 
    Extreme 3D] on usb-0000:22:00.3-1.1.1/input0

(The above output appears on one line. I've broken it up for readability.)

We search for that string in the set of input devices. (The command is typed on one line; it is broken on two lines here for readability.)

grep -A 10 -B 2 "Logitech Logitech Extreme 3D" 
/proc/bus/input/devices | grep ^H

    H: Handlers=event13 js1

Now we know which device special file to provide to jstest.

jstest /dev/input/js1
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
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .