Please do not post a support request without first reading and following the advice in

Want to use USB Controllers and GPIO-Buttons for Hotkeys.

  • Hello Everyone!
    First Things first:

    • Raspberry Pi3 B V1,2 2015

    • Using Retropie 4.1, installed from the Image found on

    • Power: 5.1V 2.5A

    • PullUp Buttons. (Prototypes done and working on Raspbian with Python 2.7.9)

    Well, what I am strugling with right now is this:
    I want to use Buttons over GPIO-Pins for Hotkeys and a Controller/Controllers for the Games.
    The initial Plan is a Pythonscript running in the Background of all of the Emulators and Fronts acting like a "Keyboard" with a Shutdown Function and the Rest of it.
    Basically the Script will be telling the Pi that the F4 Button was pressed if Pin12 gets a Contact and so on...

    What I do not know by now and hope someone can Help me out is this: Where do I put the Script in RetroPie?
    Is there a rc.local and if, where?

    How do I assign the Buttons in a Way they do not interfere with the Controllers?*

    Thank you very much!

  • I have similiar plan for my project and did some Research how it could work.

    I'd configure a keyboard as a controller (basic SNES setup) and use PyAutoGUI via scripting to simulate button presses if GPIO pin Inputs are detected.

  • So, if I understand you correctly: You want to use a Keyboard as a "third" Controller?
    That would do the Trick I think.
    Hardcode the Keyboard as a Controller additional to the others and see if it works.
    But would the RetroPie reset the Controlls after Reboot? If so, can that be stopped?
    I had to remap the Controller after every Reboot sofar...

  • Retropie should remember controllers properly if you don't switch up inputs between reboots. I first configured the controllers and then the keyboard.

  • Back at it again...
    I'm stuck. The Script runs in Background no Problem.
    But I can't get the Buttons to work. I tried to Remap the Safefunktion in retroarch.conf but it does not do anything. I can however use F4 as Exit out of the Emustation via the GPIO Pins. But all the other Buttons just don't do anything.
    Don't know anywhere else to look in the System. I also tried the Config in the Setup and chose Option (1) for enabeling the Hotkeys without the need of pressing Alt. But still to no avail.
    Anybody any Ideas?

    PS: The Buttons work in Console...

  • @opusa I also had problems using pyautogui, so I searched around and found retrogame by adafruit. It's a litte software that maps GPIO inputs to keyboard presses, so i can save, load, change slots and return to ES via buttons on my N64. I hide 4 buttons where the expansion pack usually sits, RESET returns to ES.

    Retrogame Installation guide

    This thread probalby helps configuring the retroarch.cfg to use only one button instead of a hotkey and button:

  • Well. The Script is running. If I assign F4 to one of my own Buttons it kills the RetroPie like a Keyboard would. The Shutdown Button works fine as well. (Regardless if I am in a Game or in the Setupconfig of Retropie or anywhere). With the Xbox360 Controller I can use all the Hotkeys (Select + Button = Something).
    What I can not do is assign a Function to my buttons to do the same. Means: Press Button to Save, Load ect...
    I tried messing aroung with the .cfg Files but to no Avail. The only Thing I managed to do was to kill all Hotkeys all together.
    I tried to rebind the Controllerbuttons to Keyboardbuttons by just changing the Button in the .cfg for the 360 to a Keyboardbutton but that did not work.
    If I hook up a Keyboard simultaniously with the Controller I can't use the Hotkeys on a original Keyboard neither. Except F4.
    Somewhat at a loss right now.

    Saves state,

    (# input_save_state =
    (# Loads state,
    (# input_load_state =

    #input_state_slot_increase =
    #input_state_slot_decrease =
    how parts of the retroarch.cfg look like after Changes:

    -# Saves state,
    input_save_state = s

    Loads state,

    input_load_state = b

    input_state_slot_increase = q
    input_state_slot_decrease = w


    input_enable_hotkey = "nul" (tried without anything, no change)
    auto_remaps_enable = "false" (tried it with true no change)

    any ideas?

  • @opusa You need to disable the hotkey button in the cfg, so you can use a single button to trigger the events. If you do that make sure to disable hotkeys on the controller, because nearly every button will trigger some hotkey event.

    I did this for my controllers and mapped the rgui menu on the centerbutton/psbutton so I can still access important emulator functions without a keyboard.

  • I tried all of that. At least I think I did...
    How do I disable the Hotkeybuttons on a Controller? After I tempered with the .cfgs it stoped working but I am not sure why.
    Writing this Line in the .cfg File for the Controller would do the Trick? And if, where in the .cfg?
    input_enable_hotkey = "nul"
    I tried that but it did not help.
    Well, since I have Backups I will try from a new again next week.
    At least I have the Hardware build by now.
    All in all I belive I made a small Mistake somewhere and stumble over it the entire Time...

  • @opusa


    this is the content of my retroarch.cfg:

    This is where I disabled the hotkeys and mapped them to single keys on the keyboard. Aside from escape I only used letters to avoid any problems. I hope this helps!

  • @Capt_MorganCreek Hey!
    Thank you very much for the file and the Help!
    I had to change a little bit in the Script and use now uinput from uinput.
    I ran into Problems with Dependencies... basically I haven't read thoroughly enough...
    Everything else in the Script is the same.
    Software works and the Buttons also... but! I have to make a new Plan on the Hardware itself.
    It turned out that the Way I wantet to build the entire Thing does not work. It just does not fit...
    Will have to see when I will have enough Time again to make a new Plan...

    Big Thanks for the Help!

Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.