Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

GPIO Controls Not Registering After Launching Games



  • Pi Model or other hardware: RPi CM3+
    Power Supply used: On board power circuitry (same that's used on standard Rpi's)
    RetroPie Version Used: 4.4.12
    Built From: SD Image from Retropie website
    USB Devices connected: WiFi dongle
    Controller used: Tactile switches to GPIOs
    Error messages received: None found
    Emulator: gba(lr-mgba), n64(mupen64plus-auto)

    Hello,

    I'm working on a retropie handheld project and was trying to get my GPIO buttons working so I put together a python script (https://pastebin.com/034Q4xsT) that runs at startup. I was able to map my buttons and actually navigate the menus. But as soon as I launch a game (been mostly testing with gba and snes games), the controls do not respond (Super Mario 64 has been the only one so far that I noticed is not affected).
    If I SSH into the Pi and manually run the script again, while in the game, the controls start working!
    Does anyone know what I am doing wrong here? Is my script wrong? Is there another config file I need to set?

    Hope someone can help!
    Thanks!

    EDIT: Went a little further into Super Mario 64 and controls stop working after the game save file loading screen.... :(


  • Global Moderator

    @pengu1n Your script might need a tty in order to work, but the emulators started do not have access to it. Is there a reason you're not using one of the GPIO drivers to simulate a gamepad ?
    For RetroArch, you can turn on verbose logging from the Runcommand launch menu and then get the detailed log file from /dev/shm/runcommand.log to see how the gamepad is detected (probably as a keyboard). Note that RetroArch supports keyboards, but the default mappings are different than the ones you have defined - https://docs.libretro.com/guides/input-and-controls/#keyboard-controls. You can get a real keyboard start the GUI to re-map the default buttons to the ones you've defined in your script, just to see if it makes a difference.



  • @mitu What do you mean by needing a "tty"?

    I'm not using the GPIO drivers because their pins are not configurable.. I'm not following the same IO setup that the regular Pis have on the pin header. I designed my own pcb so these pins are kinda set right now..

    I tried the Runcommand launch menu and I get nothing about a controller in the runcommand.log other than referencing the retroarch.cfg which has my layout defined as a keyboard.

    I redefined the keyboard key mappings to match https://docs.libretro.com/guides/input-and-controls/#keyboard-controls but I still have the same issue... :(

    Really lost here... I think on my next rev I'll just design in a USB controller.


  • Global Moderator

    Try using the Adafruit Retrogame - it emulates a keyboard for GPIO inputs and it's configurable.



  • from my personal projects, I've discovered GPIO keyboard events are not registered in lr-emulators.

    I think it has to do with SDL2

    Using Adafruit Retrogame, as mitu, suggests will work. I have used it.

    Otherwise you need to create your own "virtual" keyboard in the system so they will be accepted.



  • @mitu This is my bad, but I forgot to launch the game with Verbose logging, sorry. So now when I look at the runcommand.log I find this:

    [WARN] Input device ID 3 is unknown to this libretro implementation. Using RETRO _DEVICE_JOYPAD.

    Any idea what that might mean?

    I'll give Retrogame a shot also. Thanks!


  • Global Moderator

    @pengu1n said in GPIO Controls Not Registering After Launching Games:

    [WARN] Input device ID 3 is unknown to this libretro implementation. Using RETRO _DEVICE_JOYPAD.

    That's because of the RA's configuration - try resetting the configuration to default by copying the retroarch.cfg.rp-dist files over the retroarch.cfg in the /opt/retropie/configs/all/ folder.



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.