Creating Save States with a Single Button Press
-
@Katsu
Hmmm...if you had a programmable gamepad you could program R shoulder to be both Select+R shoulder buttons at once when pressed.I don't know but maybe @mediamogul's Advanced Controller Mappings can accomplish this:
https://retropie.org.uk/docs/Universal-Controller-Calibration-&-Mapping-Using-xboxdrv/https://retropie.org.uk/forum/topic/2861/guide-advanced-controller-mappings
-
Hmmm. Taking a look at that now... Seems like xboxdrv can emulate pressing a keyboard key on a controller, but it will still take two keyboard keys to create a save state. Alt+F2, so that still leaves me hitting two keys to create a save file.
The reason I need a single button, R, to save is that when I'm playing a face paced shooting game like Lords of Thunder on Super hard difficulty, I want to just hit the R button and not stop what I'm doing to hit Select+R. Timing is crucial in shooters. Letting go of the fire button isn't a good option.
-
Just a thought, could you not set the left shoulder button as the hotkey and the right to save the state? I don't know about you, but my index fingers naturally 'hover' over those when playing anything, and that way you can keep your thumbs on the d-pad and buttons without having to locate the select button without looking...
-
@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!
-
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!
-
@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!
-
@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. -
@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" -
@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
orinput_r_btn
. -
@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! :)
-
@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 to5
, so pressingL
to load a save state will not work. The same forinput_l_btn
, which is mapped to4
, but your save button is mapped to6
. If you want to use theL
andR
shoulder buttons for Save/Load, the input codes for save/load should be identical to the ones forL
/R
. -
@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
-
@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 ;-) ).
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.