Skip to content

Commit 747f8a2

Browse files
authored
Merge pull request #1062 from davidhedlund/patch-22
Update controller-autoconfiguration.md: Add "Manually finding Vendor ID and Product ID (VID:PID) on GNU/Linux" subsection
2 parents 1d6f4f7 + a33c141 commit 747f8a2

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

docs/guides/controller-autoconfiguration.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ The combination of Vendor ID and Product ID is often referred to as "vid:pid" in
123123

124124
This automated matching system allows RetroArch to support a vast array of controllers, reducing the need for manual setup in most situations.
125125

126+
126127
## Why is it needed?
127128

128129
RetroArch works many platforms. Each of these platforms has one or more input systems. These input systems in turn differ widely in the way they enumerate the pad buttons. For this reason, your joypad buttons may be mapped differently depending on if you are using Windows, Mac, or Linux.
@@ -549,6 +550,45 @@ input_vendor_id = "1356"
549550
input_product_id = "3570"
550551
```
551552

553+
#### Manually finding Vendor ID and Product ID (VID:PID) on GNU/Linux
554+
555+
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:
556+
557+
```
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+
565+
read -p "Connect your joypad and press ENTER."
566+
lsusb | nl -w2 -s': '
567+
read -p "Enter the number of your joypad device (or ENTER to skip): " n
568+
569+
if [[ -z "$n" ]]; then
570+
echo "No device selected. Only mapping will be re-generated."
571+
exit 0
572+
fi
573+
574+
line=$(lsusb | sed -n "${n}p")
575+
ids=$(echo "$line" | grep -oP 'ID \K[0-9a-fA-F]{4}:[0-9a-fA-F]{4}')
576+
vendor_hex=${ids%%:*}
577+
product_hex=${ids##*:}
578+
input_product_id=$((16#$vendor_hex))
579+
input_vendor_id=$((16#$product_hex))
580+
581+
echo -e "\ninput_vendor_id = \"$input_product_id\"\ninput_product_id = \"$input_vendor_id\"\n"
582+
583+
```
584+
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:
587+
588+
589+
`grep -r "input_product_id = \"$input_vendor_id\"" ~/.var/app/org.libretro.RetroArch/config/retroarch/autoconfig/`
590+
591+
552592
### Mapping
553593

554594
The second part is the mapping itself, where each button is assigned to a button of the RetroPad (the joypad abstraction of RetroArch).

0 commit comments

Comments
 (0)