RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    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

    How to set pause key for libretro emulators?

    Scheduled Pinned Locked Moved Help and Support
    libretroretroarchipacpause
    12 Posts 3 Posters 3.0k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      agent4125
      last edited by agent4125

      Hi

      Running RP 4.5.1 on a Pi3B+

      I've got an IPAC keyboard encoder as my only controller. I have a "pause" button connected to the IPAC mapped to the "p" key on the keyboard.

      I can set up advmame, mame4all and other non libretro emulators to map to the letter "p" no problem and get the pause button working.

      I can't see how I can do this in lr emulators though without having to also press my defined hotkey.

      I don't have a gamepad connected and don't want to have to pause by pressing the pause button along with a hotkey. I need a hotkey enabled as I use it to quit games (by pressing coin+start buttons connected to my IPAC keyboard controller). I have a dedicated pause button on my control panel and simply want to set it to pause the emulator.

      If I set input_pause_toggle = "nul" (instead of "p") in retroarch.cfg, pause no longer works (kinda as expected but I thought it might be conflicting with mame's default "p" for pause).

      Surely it's something simple I'm missing here! I just want lr-mame2003 etc to pause when I hit the "p" key on its own. Any ideas?

      Thanks

      1 Reply Last reply Reply Quote 0
      • mituM
        mitu Global Moderator
        last edited by mitu

        When enabling the hotkey in RetroArch, you can't use a single key for the command, you need to use the hotkey.
        However, there is a workaround to that, albeit a bit more convoluted. RetroArch has a network input interface, to which you can send the Pause command through a script. You can trigger said script using the trigerhappy service (which is enabled and started by default on a RetroPie image).

        • Create a file named pause-retroarch.conf in the /etc/triggerhappy/triggers.d and add the following line:
        KEY_P /home/pi/pause-ra.sh
        

        You'll need to use sudo to create the file, since this is a system file.

        sudo nano /etc/triggerhappy/triggers.d/pause-retroarch.conf
        
        • Create a script that will send the pause command to RetroArch in /home/pi/pause-ra.sh with the following lines
        #!/bin/bash
        echo -n "PAUSE_TOGGLE" | nc  -u -w1 127.0.0.1 55355
        

        and then make the script executable

        chmod +x /home/pi/pause-ra.sh
        
        • Install netcat - used by the script
        sudo apt -y install netcat
        
        • Modify the RetroArch configuration configuration file in \\retropie\configs\all\retroarch.cfg and add a line at the end with
        network_cmd_enable = "true"
        

        Reboot and see if the P key pauses RetroArch.

        A 1 Reply Last reply Reply Quote 1
        • A
          agent4125 @mitu
          last edited by agent4125

          @mitu Thanks very much. It's a shame RA can't do it without a hotkey!

          I tried the script as you mentioned above (checked everything twice) but still pressing the button on its own doesn't do anything. It still works with the hotkey though.

          1 Reply Last reply Reply Quote 0
          • mituM
            mitu Global Moderator
            last edited by

            I may have omitted something in the thd script (pause-retroarch.conf. The line

            KEY_P /home/pi/pause-ra.sh
            

            should be

            KEY_P 1 /home/pi/pause-ra.sh
            

            Check if the service is started automatically with

            systemctl status triggerhappy.service
            
            A 1 Reply Last reply Reply Quote 0
            • A
              agent4125 @mitu
              last edited by

              @mitu thanks again. No luck though. tweaked the .conf file as mentioned, and checked triggerhappy was running, which it was. Still can only get pause to work if I hold the hotkey.

              I also ran the script ./pause-ra.sh directly from the terminal while lr-mame2003 was running. This did nothing either.

              Cheers

              mituM 1 Reply Last reply Reply Quote 0
              • mituM
                mitu Global Moderator @agent4125
                last edited by

                @agent4125 Then maybe the network input interface is not enabled. Did you ever used Save Configuration in RetroArch when configuring it ? This would generate a full configuration file that's different than the .cfg I mentioned.

                A 1 Reply Last reply Reply Quote 0
                • A
                  agent4125 @mitu
                  last edited by

                  @mitu I had set the network_cmd_enable = "true", is there another setting I should be looking out for. It's "true" in retroarch.cfg.

                  I may have saved configuration at some point in the past (before I knew better I guess), but manually editing the main retroarch.cfg for other settings works fine.

                  mituM 1 Reply Last reply Reply Quote 0
                  • mituM
                    mitu Global Moderator @agent4125
                    last edited by

                    @agent4125 I think I know why it doesn't work - there's an extra parameter in the pause script - I amended the original post and removed it. Please re-do the pause-ra.sh script with the new command and try again.

                    jlr2000J 1 Reply Last reply Reply Quote 1
                    • A
                      agent4125
                      last edited by

                      Bingo! That works.

                      Many thanks :)

                      1 Reply Last reply Reply Quote 0
                      • jlr2000J
                        jlr2000 @mitu
                        last edited by

                        @mitu Many thanks for sharing this information, I know this is an older post but is it possible to map multiple buttons using this script? I'm hoping to not use the pause key but a button combo such as Coin 2 and Player 2 simultaneously. This would allow me to have some consistency between emulators for Pause (libretto mame/advancemame) and avoid using the hotkey.

                        Thanks again for sharing this information!

                        mituM 1 Reply Last reply Reply Quote 0
                        • mituM
                          mitu Global Moderator @jlr2000
                          last edited by

                          @jlr2000 I don't know, in theory it knows about multiple key presses allowing for up to 5 modifiers. Just give it a test and see how it behaves.

                          jlr2000J 1 Reply Last reply Reply Quote 0
                          • jlr2000J
                            jlr2000 @mitu
                            last edited by

                            @mitu Will do, thanks!

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post

                            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.