Help writing a UDEV rule for my Star Wars yoke
-
Normally, the
joystick
package has anudev
rule that restores any calibration info stored withjscal-store
, but that assumes you're calibrating your joystick usingjscal
(notevdev-joystick
).The
udev
rule looks like this (/lib/udev/rules.d/60-joystick.rules
).# Restore any stored calibration for the device ACTION=="add", KERNEL=="js*", RUN+="/usr/bin/jscal-restore %E{DEVNAME}"
You can add something similar (create a new file,
/etc/udev/rules.d/91-evdev-calibration.rules
), where you run the calibration when the/dev/input/eventX
device is created:ACTION=="add", KERNEL=="event*", SUBSYSTEM=="input", ATTRS{idVendor}=="ABCD" , ATTRS{idProduct}=="XYZT", "RUN+="/usr/bin/evdev-joystick --e %E{DEVNAME} --d 0"
- Replace ABCD and XZYT with the real values for the USB device, you can find them by running
cat /proc/bus/input/devices
and looking at the Vendor/Product ids shown for the device
- Replace ABCD and XZYT with the real values for the USB device, you can find them by running
-
Cool, i'll give that a try later today. I'm more a windows/mac person, this is quite new to me. Never come across this issue before because I was using digital controls. I'll let you know how I got on.
-
I've added the file as you suggested but its not setting the deadzone to zero. I've put the file in /etc/udev/rules.d/ as opposed to /lib/udev/rules.d/ so I hope this is the correct location. I've been reading similar posts and they all talk of the rule being implemented when the controller is connected. My controller is always connected, ie I'm not plugging it in each time I boot up, rather its always plugged into the USB port. Does this matter? My code is as follows:
ACTION=="add", KERNEL=="event" SUBSYSTEM=="input", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="572b", RUN+="/usr/bin/edev-joystick --e %E{usb-Alan-1_USB_Flight_Yoke_Adapter_0000-event-joystick} --d 0"
-
@james-milroy Just noticed a typo
/usr/bin/edev-joystick
should be/usr/bin/evdev-joystick
. Don't modify the-e
parameter, it's substituted byudev
at runtime. -
The more I research this topic, the more it looks to me like these 'rules' are implemented when the device is connected / plugged in. I really only need to execute the command below every time I boot up to set the deadzone to zero on the yoke.
evdev-joystick --e /dev/input/event0 --d 0
-
@james-milroy They should work even if your device is always connected.
EDIT: you can always run the command from
/etc/rc.local
:evdev-joystick --e /dev/input/usb-Alan-1_USB_Flight_Yoke_Adapter_0000-event-joystick --d 0
-
Well spotted, the typo is just in the code in my reply, its correct on the pi!
-
@mitu , what do you mean when you say don't modify the -e parameter, its substituted by UDEV at runtime?
-
You replaced
--e %E{DEVNAME}"
with
--e %E{usb-Alan-1_USB_Flight_Yoke_Adapter_0000-event-joystick}
-
@mitu I've got it working now, I had a typo in my file, I had missed out the / before dev/input/. Schoolboy error but sorted now. Many thanks for the pointers and your help. Working between my PC and the cabinet is quite tricky. I'll need to get SSH sorted out so I can do the edits from the PC direct.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.