Homepage Forums RetroPie Project Controller Configuration in RetroPie Capture gamepad as keyboard in Linux shell

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #115946
    targetboy
    Participant

    I need to figure out how to capture a game pad input as a keyboard key when Emulation Station has called out to the Linux shell.

    My goal is to have an image slideshow play when I am not playing games on my emulator. I created the file slideshow.sh under /home/pi/RetroPie/roms/pc, with the following contents:

    #!/bin/bash
    fbi /home/slideshow/*.jpg -a -noverbose -u -t 120

    This works great as a slideshow. I put images in /home/slideshow and they display at 2 minute intervals. However, I have to press ESC to return to Emulation Station. I would like to add a line to read a button on the game pad as ESC. When I finish this project, it will not have a keyboard attached, so I need to be able to get out of the slideshow with a button press.

    Google searches found a bunch of programs dealing with converting game pad inputs to keyboard inputs, but none are pre-installed on RetroPie.

    Is there something already installed that I can activate with a command in the script above?

    #115951
    labelwhore
    Participant

    That depends… what type of controller? I know how to do it with an xbox360 controller, but not others.

    #115958
    targetboy
    Participant

    It is a generic USB gamepad styled after Nintendo 64 (I think). It has a D-pad, Buttons labeled A, B, X and Y and two shoulder buttons. Whatever works for the X-box controller should work for it as well. It si at least something to try.

    #115962
    petrockblog
    Keymaster

    you can use xboxdrv on any event device to map joystick to keypresses, so that should work.

    #115963
    labelwhore
    Participant

    With xboxdrv, you need to start it with some commandline options like --ui-button-map GUIDE=KEY_ESC or something to that effect. This would map the xbox button to the escape key. It works for the other buttons too. I’d double check the syntax in the manual though, as I’ve only ever done this with config files and the –alt-config tag.

    http://pingus.seul.org/~grumbel/xboxdrv/xboxdrv.html

    #115996
    targetboy
    Participant

    No luck. xboxdrv did not see the gamepad. I have been trying to use joy2key, but that does not seem to be what I need either. I used this command with joy2key:

    joy2key -terminal -axis 0 0 0 0 -thresh 0 0 0 0 -buttons q q q q q q q q

    The result was a cursor after the joy2key startup text. I could press buttons and it would display “q”, so it is reading the joystick. The thing is, it does not start the slideshow until I press Ctrl-C to break out, at which point it is not reading the stick any more.

    Is there some way I could start it in a different process, and end that process before exiting the script?

    Sorry to be so ignorant. I am not very experienced with Linux.

    #116001
    targetboy
    Participant

    I figured it out. Here is the final script:

    #!/bin/bash
    joy2key -terminal -axis 0 0 0 0 -thresh 0 0 0 0 -buttons q q q q q q q q &
    fbi /home/slideshow/*.jpg -a -noverbose -u -t 120
    pkill joy2key

    The joy2key command starts reading the joystick with all buttons returning “q”. The “&” at the end makes it start in the background.

    The pkill statement kills the joy2kill process, that otherwise hung around throwing keys into the standard output and generally being a nuisance.

    #116034
    labelwhore
    Participant

    I was gonna say, try running it in the background, but it looks like that’s exactly what you did. :)

Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘Controller Configuration in RetroPie’ is closed to new topics and replies.