Skip to content

Commit 57041e4

Browse files
authored
Update controller-autoconfiguration.md (#1070)
* Update controller-autoconfiguration.md * Added a section on how to add hotkeys to the autoconfig file. * Enhanced the Bash script to automatically detect all autoconfig files for every GNU/Linux RetroArch release when a USB controller is plugged in. * Fixed (repaired) a table formatting. * Update controller-autoconfiguration.md Improved step 3 in section "Step 2: Configure Hotkeys in RetroArch" "Close RetroArch properly to save your hotkey assignments to the main retroarch.cfg file. On most platforms, simply exiting RetroArch saves the configuration. However, on Android, you must explicitly quit RetroArch via the menu by selecting `Main Menu` → `Quit` for your changes to be saved correctly."
1 parent 88fb958 commit 57041e4

File tree

1 file changed

+128
-51
lines changed

1 file changed

+128
-51
lines changed

docs/guides/controller-autoconfiguration.md

Lines changed: 128 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,48 @@ If your joypad is not recognized by RetroArch even after updating the profiles,
273273
2. Connect the controller intended for autoconfiguration. Ensure your system supports the selected connectivity method. If your joypad supports both wired and wireless connections and the initial attempt (e.g., via USB) fails, try the alternative option (e.g., Bluetooth). For example, the Nintendo Switch Pro Controller does not support USB connection on Linux 5.15 and older but does support Bluetooth.
274274
3. For Android, run the [Android](#android) steps first.
275275
4. Use `Settings` -> `Input` -> `RetroPad Binds` -> `Port 1 Controls` -> `Set All Controls`. If automatic mapping fails for any button (e.g., due to lack of driver support), the process will be interrupted. In case of interruption, manually map the remaining buttons, starting from the one that caused the interruption and continuing through the rest of the list.
276-
5. If applicable, then also set the menu button binding in `Settings` -> `Input` -> `Hotkeys` -> `Menu Toggle`
277-
6. Use `Settings` -> `Input` -> `RetroPad Binds` -> `Port 1 Controls` -> `Save Controller Profile`
278-
7. The new profile file (also known as the autoconfig file) will be saved to your disk: [Controller profile directory]/[Controller driver]/[Device index].cfg.
279-
8. For analog L2/R2 triggers (pressure-sensitive triggers) you must manually edit the autoconfig file (see the [Analog L2/R2 remapping](#analog-l2r2-remapping) section) due to a bug in RetroArch.
276+
5. Use `Settings` -> `Input` -> `RetroPad Binds` -> `Port 1 Controls` -> `Save Controller Profile`
277+
6. The new profile file (also known as the autoconfig file) will be saved to your disk: [Controller profile directory]/[Controller driver]/[Device index].cfg.
278+
7. Proceed with the manual configuration step section below.
280279

281-
### Manual analog L2/R2 remapping
280+
### Additional manual configuration steps
281+
282+
#### Add hotkey(s)
283+
When using RetroArch, not all controller buttons are automatically mapped through the "Set All Controls" option. Some buttons—such as menu toggles, screenshot triggers, or other special functions—must be configured separately. Here’s a step-by-step guide to ensure all your controller buttons work as desired.
284+
285+
##### Step 1: Identify the Button Functions
286+
Take a look at your physical controller to spot any special buttons that might not be auto-mapped by RetroArch. These could include:
287+
288+
- Buttons marked for menus, home, or guides (e.g., *Menu Toggle*).
289+
- Extra buttons for screenshots or system functions (e.g., *Screenshot* on some Nintendo Switch Pro Controllers).
290+
291+
Knowing which buttons are physically present helps you decide what needs manual mapping or hotkey assignment.
292+
293+
##### Step 2: Configure Hotkeys in RetroArch
294+
1. Open RetroArch and navigate to:
295+
- `Settings``Input``Hotkeys`
296+
2. Assign your desired button to the special function (e.g., menu toggle, screenshot).
297+
3. Close RetroArch properly to save your hotkey assignments to the main retroarch.cfg file. On most platforms, simply exiting RetroArch saves the configuration. However, on Android, you must explicitly quit RetroArch via the menu by selecting `Main Menu``Quit` for your changes to be saved correctly.
298+
299+
##### Step 3: Transfer Hotkey Assignments to the Autoconfig File
300+
To persist your custom mappings automatically for your controller:
301+
302+
1. Open your main `retroarch.cfg` and locate the relevant variable(s), e.g.:
303+
```
304+
input_menu_toggle_btn = "[x]"
305+
input_screenshot_btn = "[y]"
306+
```
307+
The values shown are only examples and won’t work if directly copied into your autoconfig.
308+
309+
2. Open your controller’s autoconfig file, usually located at:
310+
311+
```
312+
RetroArch/autoconfig/[platform]/[controller-name].cfg
313+
```
314+
3. Append the copied hotkey lines at the very bottom of the autoconfig file.
315+
4. Save changes.
316+
317+
### Analog L2/R2 remapping
282318
RetroArch has a bug([ref1](https://github.com/libretro/RetroArch/issues/6920), [ref2](https://github.com/libretro/RetroArch/issues/16767)) that causes analog L2/R2 triggers to be incorrectly mapped as digital buttons instead of analog axes when configuring controls through the UI. This affects pressure-sensitive triggers on controllers like PlayStation 2 and later, making some games unplayable due to the lack of analog input.
283319
284320
To work around this issue, you need to manually edit the RetroArch config file to set the correct analog axis mappings for L2 and R2. Here's how to find the proper axis values:
@@ -322,10 +358,12 @@ Note: These variable values are examples and should not be directly copied to yo
322358
323359
When modifying your autoconfig file for analog triggers, it's crucial to pay attention to both variable names and values. A common oversight is focusing solely on the values while neglecting to update the variable names themselves. The `_axis` suffix is essential for ensuring proper analog functionality. Simply changing values without updating the suffix from `_btn` to `_axis` will not achieve the desired result.
324360
325-
####Common Pitfall
361+
#### Common Pitfall
326362
Users often unintentionally incorporate analog variable values without properly adjusting the existing variable names to reflect their analog nature. This oversight frequently results in configuration problems within the system.
327363
By carefully updating both the variable names and values, you can ensure that your analog triggers are correctly configured for optimal performance.
328364
365+
###
366+
329367
### Inspect the file
330368
331369
Without modifying anything in the original file, open it in the file in a text editor and
@@ -467,8 +505,8 @@ input_device_alt2 = "Pro Controller"
467505
468506
**DualShock 4 v2:**
469507
470-
| Controller | Linux Kernel Version | HID Support | USB Supported | Device Index in RetroArch (USB) | Bluetooth Supported[^2] | Device Index in RetroArch (Bluetooth) | Autoconfig structure |
471-
|-|-|-|-|-|-|-|
508+
| Controller Version | Linux Kernel Version | HID Support | USB Supported | Device Index in RetroArch (USB) | Bluetooth Supported | Device Index in RetroArch (Bluetooth) | Autoconfig Structure |
509+
|--------------------|---------------------|-------------|---------------|---------------------------------|---------------------|---------------------------------------|----------------------|
472510
| 5.15 | Yes | Yes | Sony Interactive Entertainment Wireless Controller | Yes | Wireless Controller | udev/linuxraw: Generate `Sony DualShock 4 Controller.cfg` (see "Note" below). udev/linuxraw: Manually add DualShock 4 v1 values to input_device_alt1, input_device_display_name_alt1. linuxraw: Manually add: input_vendor_id_alt1, input_product_id_alt1 |
473511
| 5.19 | Yes | Yes | Sony Interactive Entertainment Wireless Controller | Yes | Wireless Controller | |
474512
| 6.2.0 | Yes | Yes | Sony Interactive Entertainment Wireless Controller | Yes | Wireless Controller | |
@@ -555,13 +593,6 @@ input_product_id = "3570"
555593
If you need to manually identify the VID:PID for your controller (for example, if RetroArch does not work as expected for you) in GNU/Linux, you can run this script:
556594
557595
```
558-
#!/bin/bash
559-
560-
# This script helps you identify your connected USB joypad.
561-
# It lists all USB devices, lets you select your joypad, extracts its Vendor ID and Product ID,
562-
# converts these IDs from hexadecimal to decimal, and prints them in a configuration-ready format.
563-
# If you skip selection, it exits gracefully.
564-
565596
read -p "Connect your joypad and press ENTER."
566597
lsusb | nl -w2 -s': '
567598
read -p "Enter the number of your joypad device (or ENTER to skip): " n
@@ -580,14 +611,59 @@ input_vendor_id=$((16#$product_hex))
580611

581612
echo -e "\ninput_vendor_id = \"$input_product_id\"\ninput_product_id = \"$input_vendor_id\"\n"
582613

583-
```
614+
########################################
615+
# List all autoconfig files for the selected USB controller
616+
617+
search_autoconfig() {
618+
local retroarch_dir="$1"
619+
620+
if [ ! -f "$retroarch_dir/retroarch.cfg" ]; then
621+
echo "Config file not found: $retroarch_dir/retroarch.cfg. Please start RetroArch, and optionally configure Settings -> Directory -> Controller Profiles."
622+
return
623+
fi
584624

585-
This is especially useful if you want to search for existing autoconfig files matching your controller.
586-
For example, after obtaining the decimal Product ID, you can search the autoconfig directory (usually ~/.config/retroarch/autoconfig/) like this:
625+
# Extract raw joypad_autoconfig_dir from config, strip quotes and spaces
626+
local joypad_autoconfig_dir_raw
627+
joypad_autoconfig_dir_raw=$(grep "^joypad_autoconfig_dir" "$retroarch_dir/retroarch.cfg" | cut -d= -f2- | tr -d '" ')
587628

629+
local joypad_autoconfig_dir
588630

589-
`grep -r "input_product_id = \"$input_vendor_id\"" ~/.var/app/org.libretro.RetroArch/config/retroarch/autoconfig/`
631+
# For AppImage, expand ~ to retroarch_dir; for others, expand ~ to $HOME
632+
if [[ "$retroarch_dir" == *".AppImage.home/.config/retroarch" ]]; then
633+
joypad_autoconfig_dir="${joypad_autoconfig_dir_raw/#\~/$retroarch_dir}"
634+
# Remove duplicated ".config/retroarch/" if present twice
635+
joypad_autoconfig_dir="${joypad_autoconfig_dir//.config\/retroarch\/.config\/retroarch/.config/retroarch}"
636+
else
637+
joypad_autoconfig_dir="${joypad_autoconfig_dir_raw/#\~/$HOME}"
638+
fi
590639

640+
# Fallback to default autoconfig directory if empty
641+
if [ -z "$joypad_autoconfig_dir" ]; then
642+
joypad_autoconfig_dir="$HOME/.config/retroarch/autoconfig"
643+
fi
644+
645+
echo "Searching in: $joypad_autoconfig_dir"
646+
647+
if [ -d "$joypad_autoconfig_dir" ]; then
648+
grep -r "input_product_id = \"$input_vendor_id\"" "$joypad_autoconfig_dir"
649+
else
650+
echo "Autoconfig directory not found: $joypad_autoconfig_dir"
651+
fi
652+
653+
echo ""
654+
}
655+
656+
echo "--- Standard package install ---"
657+
search_autoconfig "$HOME/.config/retroarch"
658+
659+
echo "--- Flathub (Flatpak) install ---"
660+
search_autoconfig "$HOME/.var/app/org.libretro.RetroArch/config/retroarch"
661+
662+
echo "--- AppImage install ---"
663+
search_autoconfig "$HOME/Downloads/RetroArch-Linux-x86_64/RetroArch-Linux-x86_64.AppImage.home/.config/retroarch"
664+
```
665+
666+
With this you can search for existing autoconfig files matching your controller. This is especially useful to find if your loaded autoconfig has commented variables which happens if there are multiple autoconfigs of the same controller.
591667
592668
### Mapping
593669
@@ -624,7 +700,33 @@ input_menu_toggle_btn = "8"
624700
625701
Note: These variable values are examples and should not be directly copied to your configuration file.
626702
627-
#### Overview
703+
#### Input types
704+
705+
##### Buttons (digital inputs)
706+
707+
* These are defined by variable names ending with `_btn` (e.g., `input_a_btn`, `input_start_btn`).
708+
* The current RetroArch configurations have button values that ranges from `0` to `203`. However, if RetroArch does not limit the values to `203`, underlying controller hardware could offer an even wider range.
709+
* RetroArch interprets these IDs (usually 1 for pressed, 0 for not pressed) to determine the button state.
710+
711+
###### D-Pad directions (special digital inputs)
712+
713+
* D-pad directions use variable values beginning with `h0` (e.g., `input_up_btn = "h0up"`), for certain controller drivers (e.g udev, and android, but not sdl2).
714+
* Four `h0` variables exist (`h0up`, `h0down`, `h0left`, `h0right`) for each direction on the D-pad.
715+
* Note: The value `h1` is used by a single controller (Nintendo_Wii_Remote_Classic_Controller.cfg).
716+
717+
##### Axis (analog input)
718+
* Axis definitions use `+` and `-` to indicate positive or negative direction (e.g., full press vs. no press).
719+
* The current RetroArch configurations have axis values that ranges from `0` to `10`. However, if RetroArch does not limit the values to `10`, underlying controller hardware could offer an even wider range.
720+
721+
###### Mapping variables with analog L2/R2 triggers
722+
```
723+
input_l2_axis = "+[x]"
724+
input_r2_axis = "+[y]"
725+
```
726+
727+
Note: These variable values are examples and should not be directly copied to your configuration file, they will not work.
728+
729+
#### Controller elements
628730
629731
##### Axes (analog inputs)
630732
* They represent analog inputs from the controller, like joystick position (e.g., left joystick X-axis, right joystick Y-axis) or trigger pressure (e.g., L2 trigger, R2 trigger).
@@ -640,19 +742,12 @@ Note: These variable values are examples and should not be directly copied to yo
640742
| PlayStation 4 | DualShock 4 | 2013 | Yes | Yes |
641743
| PlayStation 5 | DualSense | 2020 | Yes | Yes |
642744
643-
###### Mapping variables
644-
* Axis definitions use `+` and `-` to indicate positive or negative direction (e.g., full press vs. no press).
645-
* The current RetroArch configurations have axis values that ranges from `0` to `10`. However, if RetroArch does not limit the values to `10`, underlying controller hardware could offer an even wider range.
646-
647-
Mapping variables with analog L2/R2 triggers:
648-
```
649-
input_l2_axis = "+2"
650-
input_r2_axis = "+5"
651-
```
652-
653-
Note: A common mistake These variable values are examples and should not be directly copied to your configuration file.
745+
###### Shoulder buttons with analog variables
746+
Give each button the same label as described by the manufacturer. Additionally:
747+
- For analog shoulder buttons, use the manufacturer’s label **and** append the word **" Trigger"** at the end.
748+
- For example: `input_l2_axis_label = "L2 Trigger"`
654749
655-
###### Label variables
750+
###### Analog sticks
656751
The term "Analog" is included in the variable values for the analog inputs to clearly indicate that these inputs are analog in nature.
657752
658753
Labels for analog thumb sticks:
@@ -667,27 +762,9 @@ input_r_y_plus_axis_label = "Right Analog Y+ (down)"
667762
input_r_y_minus_axis_label = "Right Analog Y- (up)"
668763
```
669764
670-
Labels for analog L2/R2 triggers:
671-
```
672-
input_l2_axis_label = "L2 Trigger"
673-
input_r2_axis_label = "R2 Trigger"
674-
```
675-
676-
##### Buttons (digital inputs)
677-
678-
* These are defined by variable names ending with `_btn` (e.g., `input_a_btn`, `input_start_btn`).
679-
* The current RetroArch configurations have button values that ranges from `0` to `203`. However, if RetroArch does not limit the values to `203`, underlying controller hardware could offer an even wider range.
680-
* RetroArch interprets these IDs (usually 1 for pressed, 0 for not pressed) to determine the button state.
681-
682-
###### D-Pad directions (special digital inputs)
683-
684-
* D-pad directions use variable values beginning with `h0` (e.g., `input_up_btn = "h0up"`).
685-
* Four `h0` variables exist (`h0up`, `h0down`, `h0left`, `h0right`) for each direction on the D-pad.
686-
* Note: The value `h1` is used by a single controller (Nintendo_Wii_Remote_Classic_Controller.cfg).
687-
688765
#### Input descriptors
689766
690-
The third part are *input descriptors* used by RetroArch to display the labels of the buttons as they are written on your joypad.
767+
The third part are *input descriptors* used by RetroArch to display the labels of the buttons as they are written on your joypad. RetroArch does not automatically generate button labels; therefore, you need to manually add them to your autoconfig file.
691768
692769
Generic input descriptors:
693770
```

0 commit comments

Comments
 (0)