libretro / libretro/RetroArch

[Feature request] Make it possible to use the same button position of the Hotkeys with any controller

Open
#16,172 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
14.1k
Forks
2.2k
Avg merge
7h 35m
Merged PRs (30d)
51

Description

First and foremost consider this:

  • Only RetroArch bugs should be filed here. Not core bugs or game bugs
  • This is not a forum or a help section, this is strictly developer oriented

Description

Currently, the controller button values (used to set Hotkeys, and Remaps) are read from an autoconfig file. However, the autoconfig file values are limited:

  • the autoconfig file themselves: Obviously the values are different between controllers
  • device driver -- the DualSense autoconfig file for android/ and udev/ is not identical, for example.
Feature request

Controller buttons with global values would be useful to Hotkeys and Remaps, so any controller driver and autoconfig file can be used:

  • Introduce Quick Menu -> Settings -> Input -> Hotkeys -> Controller position values (On/Off). When Dynamic controller values is turned On it will 1) Allow you to Select (like in Quick Menu -> Controls -> Port 1 Controls -> Any button) the "L2" for example instead of pressing the L2 button. 2) It will generate dynamic variable values for:
  • Quick Menu -> Controls -> Manage Remap Files -> Save*

Step 1: Set Quick Menu -> Settings -> Input -> Hotkeys to these values:

  • Dynamic controller values = On
  • Rewind = [Select L2]
  • Fast-Forward = [Select R2]
  • Save State = [Select L3]
  • Load State = [Select R3]

Step 2:

  • Plug a controller that have L2, R2, L3, and R3 buttons (in this example Sony DualSense), called Controller 1 from now on.
  • Load a SNES game, for example with the bsnes-mercury core.
  • Quick Menu -> Save Core Overrides. This file will be generated: retroarch/config/bsnes-mercury/bsnes-mercury.cfg :
input_hold_fast_forward_btn = "$input_player1_r2_btn$input_player1_r2_axis"
input_rewind_btn = "$input_player1_l2_btn$input_player1_l2_axis"
input_load_state_btn = "$input_player1_r3_btn$input_player1_r3_axis"
input_save_state_btn = "$input_player1_l3_btn$input_player1_l3_axis"

Autoconfig file buttons use either a _btn, or a _axis, for each button. Which is why both variables should be added.

Workaround

I wrote a simple Bash script that can be used for GNU/Linux users that can be used and studies until this feature request is implemented to RetroArch. Please try, and study the script to best understand what this feature request is all about, before you are raising questions.

Autoconfig file buttons use either a _btn, or a _axis, for each button. Which is why both variables should are added.

Here's the Bash script:

#!/bin/bash

:'
Copyright 2024 David Hedlund

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
'

autoconfig_file_name_1="Sony Interactive Entertainment DualSense Wireless Controller.cfg";
autoconfig_file_name_2="Nintendo - Switch Pro Controller.cfg";

echo -e "1: $autoconfig_file_name_1
2: $autoconfig_file_name_2\n"

read -p "Select the number of the joypad device: " -e autoconfig_file_name_selection


if [ "$autoconfig_file_name_selection" = 1 ]; then autoconfig_file_name="$autoconfig_file_name_1"
elif [ "$autoconfig_file_name_selection" = 2 ]; then autoconfig_file_name="$autoconfig_file_name_2"; fi


input_user_x_binds="1";
retroarch_dir="$HOME/Downloads/Software/RetroArch-Linux-x86_64/RetroArch-Linux-x86_64.AppImage.home/.config/retroarch";
joypad_autoconfig_dir=$(cat < "$retroarch_dir/retroarch.cfg" | grep joypad_autoconfig_dir | cut -d= -f2- | sed 's|"||g; s| ||');
input_joypad_driver_value=$(cat < "$retroarch_dir/retroarch.cfg" | grep input_joypad_driver | cut -d= -f2- | sed 's|"||g; s| ||');
controller_file="$joypad_autoconfig_dir/$input_joypad_driver_value/$autoconfig_file_name";

grep '_btn =\|_axis =' "$controller_file" > /tmp/autoconfig_variables.txt
sort /tmp/autoconfig_variables.txt > /tmp/autoconfig_variables-sorted.txt
cp -a /tmp/autoconfig_variables-sorted.txt /tmp/autoconfig_variables-sorted-valid_variables.txt

sed -i "
s| = |=| # Trim white space to make valid bash variables
s|^input_|input_player$input_user_x_binds""_""|
" /tmp/autoconfig_variables-sorted-valid_variables.txt

source /tmp/autoconfig_variables-sorted-valid_variables.txt

tee "$retroarch_dir/config/bsnes-mercury/bsnes-mercury.cfg" > /dev/null << EOF
input_hold_fast_forward_btn = "$input_player1_r2_btn$input_player1_r2_axis"
input_rewind_btn = "$input_player1_l2_btn$input_player1_l2_axis"
input_load_state_btn = "$input_player1_r3_btn$input_player1_r3_axis"
input_save_state_btn = "$input_player1_l3_btn$input_player1_l3_axis"
EOF

echo -e "\n$retroarch_dir/config/bsnes-mercury/bsnes-mercury.cfg :"
cat "$retroarch_dir/config/bsnes-mercury/bsnes-mercury.cfg"
Steps to reproduce the issue

Step 1: Set Quick Menu -> Settings -> Input -> Hotkeys to these values:

  • Rewind = [Press L2]
  • Fast-Forward = [Press R2]
  • Save State = [Press L3]
  • Load State = [Press R3]

Step 2:

  • Plug a controller that have L2, R2, L3, and R3 buttons (in this example Sony DualSense), called Controller 1 from now on.
  • Load a SNES game, for example with the bsnes-mercury core.
  • Quick Menu -> Save Core Overrides. This file will be generated: retroarch/config/bsnes-mercury/bsnes-mercury.cfg :
input_hold_fast_forward_btn = "7"
input_rewind_btn = "6"
input_load_state_btn = "12"
input_save_state_btn = "11"

Step 3:

  • Unplug Controller 1. Plug another controller model that has L2, R2, L3, and R3, called Controller 2 from now on.
  • The Hotkey that we remapped in Step1 is assigned values from Controller 1 so they will not work with Controller 2. So you have to run Step 1, and Step 2, to remap the Hotkeys for the core, every time you swap controller models.
Bisect Results

[Try to bisect and tell us when this started happening]

Version/Commit

You can find this information under Information/System Information

  • RetroArch: [version/commit]
Environment information
  • OS: [The operating system you're running]
  • Compiler: [In case you are running local builds]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source files or tests are named. Start by tracing how controller autoconfiguration supplies hotkey and remap button values, then follow the Quick Menu input settings and core-override save paths. Done means the proposed controller-position setting can select L2/R2/L3/R3 and saved hotkeys or remaps retain those positions across controller models and drivers.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, c
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.