workinghard / jslisten

listen to gamepad inputs and trigger a command
GNU General Public License v3.0
31 stars 18 forks source link

Hotplug and --device argument #27

Open Norde opened 4 years ago

Norde commented 4 years ago

It seems that jslisten does'nt detect hotplug (at least when using --device argument).

I dunno if it's a bug or if jslisten isn't planned to handle this.

Howether it can be easily bypassed with a udev rule triggering restart of jslisten service. If jsliten isn't intended to detect hotplug i can push a "how to" for some udev rule in the README.md.

pilgrim556 commented 4 years ago

I have this exact issue with Bluetooth 8bitdo controllers when they sleep. Can you describe what you’re doing in udev to make this work?

Norde commented 3 years ago

Connect your controller when run cmd: > udevadm info --name=/dev/input/jsX --attribute-walk (with X according to your controller adress number)

Note values of "SUBSYSTEMS" and "ATTRS{phys}".

Then create a rule file under /etc/udev/rules.d/ e.g: > sudo nano /etc/udev/rules.d/99-persistent-joystick.rules

Then fill it with values obtained previously:

SUBSYSTEM=="SUBSYSTEM_VALUE", \ ATTRS{uniq}=="ATTRS{phys}_VALUE", \ TAG+="systemd", \ ENV{SYSTEM_USER_WANTS}="jslisten.service", \

Give rights to your newly created file: > sudo chmod 755 /etc/udev/rules.d/99-persistent-joystick.rules

Reload and apply new udev rules: > sudo udevadm control --reload-rules > sudo udevadm test -a -p $(udevadm info -q path -n /dev/input/jsX)

Optionally you can attribute a symbolic link to your controller (very useful to identify a given controller if you have multiple ones). Simply add "SYMLINK+="input/joy1", \" to your 99-persistent-joystick.rules file (with joy1 as name for the controller, for exemple). Now your controller will have a fixed symbolic adress that you can refer to (instead of random /dev/input/jsX at each unplug/plug).