1

I need to find a gamepad in my list of /dev/input/event* devices, and the only thing I know about it is that when I do evtest it shows up with the name G13. The problem is every time I reboot it gets a different number. I would like to automate finding the path so I can pass it to this command in the $G13 variable: I tried evtest | grep G13 but the problem is the evtest command doesn't terminate on its own, it's interactive, so my script gets stuck on a prompt.

xboxdrv --evdev $G13 --config ~/.config/xboxdrv/G13.conf &

1 Answer 1

1

You want to set up a udev rule to provide your device with a persistent symlink. Start by running udevadm info -a /dev/input/eventXX for whichever device currently represents your gamepad.

You'll see output like:

    ATTR{power/runtime_suspended_time}=="0"

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0/input/input29':
    KERNELS=="input29"
    SUBSYSTEMS=="input"
    DRIVERS==""
    ...
    ATTRS{id/product}=="c21d"
    ATTRS{id/vendor}=="046d"
    ...

Create a file /etc/udev/rules.d/90-gamepad.rules that contains:

SUBSYSTEMS=="input", ATTRS{id/product}=="c21d", ATTRS{id/vendor}=="046d", SYMLINK += "gamepad"

...replacing the values for product and vendor with the ones you see in your output.

Save the file and run:

udevadm control -R

Unplug the gamepad and plug it back in, and you should see there is now a symlink /dev/gamepad that points to the appropriate /dev/input/... device.

Now you can use the device path /dev/gamepad instead of the varying /dev/input path.

2
  • Thank you very much!
    – Poldovico
    Jun 6, 2022 at 19:47
  • One year later correction: this creates a symlink to the /dev/input/jsY path, not to the /dev/input/eventXX path. Unfortunately, the command in the question cannot work with that path. I can only assume they are different protocols or something
    – Poldovico
    Aug 10 at 18:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .