RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    Help writing a UDEV rule for my Star Wars yoke

    Scheduled Pinned Locked Moved Help and Support
    star warsyokeadvmame 3.9udev
    11 Posts 2 Posters 1.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      james.milroy
      last edited by

      I've built an upright Star Wars cabinet and was having issues with a deadzone on my controller. Its an Alan-1 replica yoke on an Alan-1 USB adapter. I've since worked out that it communicates with Advmame using the evdev API and not the usual Joystick API. I can set the deadzone on the controller to zero with the following command:

      evdev-joystick --e /dev/input/event0 --d 0

      If I then restart EmulationStation and start the Star Wars rom everything is sweet, no deadzone. But when I quit and switch off the Pi, the next time I restart, the deadzone has returned to its previous value (6.23%). I understand from a bit of hunting on the web that I need to create a UDEV rule to apply the above command every time I reboot. I don't have a clue as to how to write a rule and implement it.

      Can any one help or point me in the right direction?

      1 Reply Last reply Reply Quote 0
      • mituM
        mitu Global Moderator
        last edited by mitu

        Normally, the joystick package has an udev rule that restores any calibration info stored with jscal-store, but that assumes you're calibrating your joystick using jscal (not evdev-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
        1 Reply Last reply Reply Quote 0
        • J
          james.milroy
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • J
            james.milroy
            last edited by

            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"
            
            mituM 1 Reply Last reply Reply Quote 0
            • mituM
              mitu Global Moderator @james.milroy
              last edited by

              @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 by udev at runtime.

              1 Reply Last reply Reply Quote 0
              • J
                james.milroy
                last edited by

                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
                
                mituM 1 Reply Last reply Reply Quote 0
                • mituM
                  mitu Global Moderator @james.milroy
                  last edited by mitu

                  @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
                  
                  1 Reply Last reply Reply Quote 0
                  • J
                    james.milroy
                    last edited by

                    Well spotted, the typo is just in the code in my reply, its correct on the pi!

                    1 Reply Last reply Reply Quote 0
                    • J
                      james.milroy
                      last edited by

                      @mitu , what do you mean when you say don't modify the -e parameter, its substituted by UDEV at runtime?

                      1 Reply Last reply Reply Quote 0
                      • mituM
                        mitu Global Moderator
                        last edited by

                        You replaced

                        --e %E{DEVNAME}"

                        with

                        --e %E{usb-Alan-1_USB_Flight_Yoke_Adapter_0000-event-joystick}

                        1 Reply Last reply Reply Quote 0
                        • J
                          james.milroy
                          last edited by

                          @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.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post

                          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.