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

    Creating Save States with a Single Button Press

    Scheduled Pinned Locked Moved Help and Support
    nes30save stateshotkeyremapping
    16 Posts 6 Posters 5.5k 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.
    • K
      Katsu @Danorak1981
      last edited by

      @Danorak1981 That's funny. I was thinking of this very same things as my backup workaround to this problem. I'll probably set it that way for the meantime (L being my hotkey instead of Select), but I'd really like to figure out a way to do this properly.

      It's strange. Retroarch is so customizable, but it won't let you just hit a button or combination of buttons that you'd like to perform actions like this. It would be nice to have it prompt you to hit the button or buttons you'd like to perform whatever action. Kind of how it does when you set up a new controller in Emulation Station.

      Anyway, if anyone has the solution or workaround to this, I'd be very happy to know it!

      1 Reply Last reply Reply Quote 0
      • ethelingE
        etheling
        last edited by

        I was scratching my head with this same problem with RetroPie 4.6. E.g. how to trigger save state with single keypad button press (right shoulder).

        It appears that with 4.6 you can go to 'RetroArch Settings (F1) -> Settings -> Input -> Hotkey binds -> Load|Save State' and simply press the controller button that you with to assign this functionality. Alternatively setting following settings in /opt/retroarch/config/all/retroarch.cfg will do the trick:

        input_load_state_btn = "4"
        input_save_state_btn = "5"

        To find which buttons (e.g. 4,...) to assign here, use jstest /dev/input/js0 (or js1,...).

        What is really important is that for any of this to work input_enable_hotkey = must NOT be set in retroarch.cfg or for any configured gamepad. If it is set anywhere, then RetroArch (very annoyingly if I may) will require you to also hold the hotkey in addition of gamepad button or keyboard key. E.g. make sure that retroarch.cfg has 'input_enable_hotkey ="nul"' in it. After this, also keyboard key bindings work by just pressing e.g. F2 to save state without the need to hold down another key.

        So to sum it up - as long as 'input_enable_hotkey =" is NOT set anywhere, with RetroPie 4.6 single key/button press hotkeys work beautifully!

        M 1 Reply Last reply Reply Quote 0
        • M
          M0dd3r4t0R @etheling
          last edited by

          @etheling Have been waiting the longest time for this answer! I have modified the retroarch.cfg and <gamepad>.cfg to reflect 'input_enable_hotkey ="nul" like you suggested! And the one button press for save states and load states do work!!! BUT - with the hotkey now in the "nul" state, I am not able to perform the exit command through <start> + <select(hotkey)> button presses. Am I missing something? Thanks in advance!

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

            @M0dd3r4t0R said in Creating Save States with a Single Button Press:

            BUT - with the hotkey now in the "nul" state, I am not able to perform the exit command through <start> + <select(hotkey)> button presses. Am I missing something?

            Yes, you're missing the Hotkey. Once you've un-set it, no hotkey combination will work - pressing only Start should exit the game.

            M ethelingE 2 Replies Last reply Reply Quote 0
            • M
              M0dd3r4t0R @mitu
              last edited by

              @mitu Thanks for chipping in bro. However, with the hotkey unset, the Start button still performs as it should though, for my case at least.
              Leaving the hotkey unset, what I did afterwards was to bind Exit, Load State and Save State to 3 separate buttons. <CFG details below>.
              This meant that the hotkey was no longer required for these regularly used functions. But strangely enough, only exit and load state buttons work, save state does not.
              I have double checked with jstest to make sure i got the numerals correct, but I still fail in identifying what went wrong. Just when I thought I had a solution to the earlier problem - only to hit another wall with a new one. HA!

              input_device = "DragonRise Inc. Generic USB Joystick "
              input_driver = "udev"
              input_l_btn = "4"
              input_save_state_btn = "6"
              input_load_state_btn = "8"

              input_start_btn = "10"
              input_exit_emulator_btn = "9"
              input_down_axis = "+1"
              input_r_btn = "5"
              input_right_axis = "+0"
              input_state_slot_increase_axis = "nul"
              input_select_btn = "11"
              input_left_axis = "-0"
              input_state_slot_decrease_axis = "nul"
              input_l2_btn = "nul"
              input_up_axis = "-1"
              input_a_btn = "0"
              input_b_btn = "1"
              input_reset_btn = "nul"
              input_enable_hotkey_btn = "nul"
              input_x_btn = "2"
              input_menu_toggle_btn = "nul"
              input_y_btn = "3"

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

                @M0dd3r4t0R said in Creating Save States with a Single Button Press:

                This meant that the hotkey was no longer required for these regularly used functions. But strangely enough, only exit and load state buttons work, save state does not.

                This contradicts what you said earlier:

                And the one button press for save states and load states do work!!!

                Your configuration has save/load inputs bound, but they're not the same buttons as input_l_btn or input_r_btn.

                M 1 Reply Last reply Reply Quote 0
                • M
                  M0dd3r4t0R @mitu
                  last edited by

                  @mitu said in Creating Save States with a Single Button Press:

                  larly used functions. But strangely enough, only exit and load state buttons work, save state does not.

                  This contradicts what you said earlier:

                  And the one button press for save states and load states do work!!!

                  Your configuration has save/load inputs bound, but they're not the same buttons as input_l_btn or input_r_btn.

                  Apologies for the confusion. The earlier configuration I had save and load mapped to other buttons, all worked except the hotkey - thus not being able to exit the game.

                  For the latest config, I attempted to map EXIT to a single button, and have save state mapped to button "6", but the latter didnt work upon.

                  Being someone new to the scene, I have difficulty understanding " Your configuration has save/load inputs bound, but they're not the same buttons as input_l_btn or input_r_btn.". I'm embarrassed to have to request for a simpler explanation. Thanks in advance! :)

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

                    @M0dd3r4t0R said in Creating Save States with a Single Button Press:

                    For the latest config, I attempted to map EXIT to a single button, and have save state mapped to button "6", but the latter didnt work upon.

                    6 is an input code that is tied to a button, but your configuration doesn't have any other button using to this code, so it may not be a valid input code.

                    The RetroPie gamepad auto-configuration will read the input codes for the buttons you choose during the input configuration and generate a .cfg where Save/Load are bound to the L/R shoulder buttons.
                    In your configuration, input_r_btn is mapped to 5, so pressing L to load a save state will not work. The same for input_l_btn , which is mapped to 4, but your save button is mapped to 6. If you want to use the L and R shoulder buttons for Save/Load, the input codes for save/load should be identical to the ones for L/R.

                    1 Reply Last reply Reply Quote 0
                    • ethelingE
                      etheling @M0dd3r4t0R
                      last edited by etheling

                      @M0dd3r4t0R Right. I should have pointed out that after disabling hotkey, exit (and other) gamepad button combinations cease to work. That was a problem for me too so I ended up writing:

                      URL: https://github.com/etheling/vkbdd

                      I also wanted to exit game from the controller (which I 'solved' that originally by just ssh:ing to RetroPie and sending SIGTERM to RetroArch. ;) ). And toggle FPS, slow motion, shaders etc. via arbitrary button combinations from gamepad. Which to my knowledge is not possible with stock RetroPie (xboxdrv can be used to achieve this too, but...).

                      To achieve this I wrote a little daemon (vkbdd - GitHub link above has some documentation and install instructions) that acts as a virtual keyboard device on RetroPie. When combined with triggerhappy daemon, you can now trigger events from gamed pad that require dual keypress (or triple). As an example, here is triggerhappy config that assigns (on Xbox 360 controller) select+start to send ESC to exit emulator, and left analog stick + (X|B|Y) respectively to next/prev shader, and to FPS display toggle.

                      pi@retropie:~ $ cat /etc/triggerhappy/triggers.d/vkbdd-retropie.conf
                      ## xbox 360 wired controller
                      BTN_SELECT+BTN_START		1	/usr/bin/printf '\033' > /tmp/vkbdd.fifo # ESC / exit emulator
                      BTN_THUMBL+BTN_B		1	/usr/bin/printf m > /tmp/vkbdd.fifo # next shader
                      BTN_THUMBL+BTN_NORTH		1	/usr/bin/printf n > /tmp/vkbdd.fifo # prev shader
                      BTN_THUMBL+BTN_WEST		1	/usr/bin/printf '\214' > /tmp/vkbdd.fifo # F3 fps on/off
                      

                      As emphasized before, to be able to use these single key/button hotkeys (and /w vkbdd and triggerhappy to handle button combinations), 'input_enable_hotkey =" must NOT be set anywhere.

                      I hope this was helpful and if you try vkbdd, let me know if I should update / improve the docs. I wrote it mostly for myself to be able to solve the problem that you also bumped into (single button hotkeys work, but not combinations after 'input_enable_hotkey ="), so I didn't put a lot of emphasis on documentation. What took me down this rabbit hole was that I did a build of RetroPie inside Atari 2600 and I had to get the switches on Atari working without having to press hotkey somewhere else (https://retropie.org.uk/forum/topic/27120/atari-2600-4-switch-woodgrain-housing-for-retropie).

                      If you're not familiar with triggerhappy, it's installed and running by default on RetroPie 4.6 and here is the package documentation: https://packages.debian.org/sid/triggerhappy . After updating triggerhappy config, you should restart the daemon with 'sudo systemctl restart triggerhappy.service' (as in RetroPie 4.6) for the new config to take effect. In order to find correct BTN_ events for creating triggerhappy config for a given gamepad, use thd on gamepads event* device. For example '$ thd --dump /dev/input/event0' assuming gamepad is registered as event0.

                      edit: evtest --> thd example fix

                      1 Reply Last reply Reply Quote 0
                      • ethelingE
                        etheling @mitu
                        last edited by etheling

                        @mitu said in Creating Save States with a Single Button Press:

                        pressing only Start should exit the game.

                        My experience with (retropie 4.6) is that (luckily) it doesn't. Which at least for my purposes is good. Should this change at some future version, then if 'input_enable_hotkey =" and single press hotkeys are what's desired, then one would need to change that mapping in RetroArch configurations somewhere to avoid exiting emulator when Start is pressed. (it's almost like the old joke on Windows - you press start to to stop/exit ;-) ).

                        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.