USB Joystick with FlightGear?

I have a Microsoft SideWinder Precision Pro (USB), and on FreeBSD 14.1 it doesn't detect for FlightGear (pkg install flightgear).

dmesg:
Code:
ugen0.7: <Microsoft Microsoft SideWinder Precision Pro (USB)> at usbus0
usbhid3 on uhub1
usbhid3: <Microsoft Microsoft SideWinder Precision Pro (USB), class 0/0, rev 1.00/1.00, addr 9> on usbus0
hidbus4: <HID bus> on usbhid3
hgame0: <Microsoft Microsoft SideWinder Precision Pro (USB) Joystick> on hidbus4

Code:
/dev/input/event14

Without doing anything, FlightGear doesn't see the joystick (fgjs):

Code:
fgjs
Found 0 joystick(s)
Can't find any joysticks ...

Going to this gamepad test website without doing anything also doesn't show the joystick.

If I chown event14:

Code:
chown espionage724:espionage724 /dev/input/event14

It then shows fine on the gamepad test website, but fgjs (nor the game itself) doesn't see the joystick still.

There's a solution about uhidd but I don't quite understand it, tried a few commands for it on the joystick ugen0.7 and wasn't able to get it to report differently with fgjs: https://forums.freebsd.org/threads/flightgear-cant-see-thrustmaster-joystick.93402/#post-655108

I recall seeing something somewhere about FreeBSD having joysticks under a different /dev path than some games expect (js0? something about linux-joysticks package?) but I'm not sure if that's based on outdated info.

I have some of my FreeBSD config here.
Code:
groups
espionage724 wheel video
 
I got something figured out, mostly!

I put usb_load="YES" in loader.conf (replaced hw.usb.usbhid.enable=1)

That puts my joystick automatically on plug-in at a /dev/uhid# location

For lazy-setting permissions: chmod 777 /dev/uhid1

It seemingly just-works for neverball and flightgear now! But doesn't show up on the browser test website (not an issue, but kind of curious why it's different). Stick controls seem badly-mapped on neverball but I feel assigning different axis or inverting somehow might fix that (there's no in-game controller config afaik).

FlightGear doesn't seem to auto-pickup on my stick nor load a profile, and force-loading the Sidewinder Precision Pro XML (adding uhid1 as a name in the xml) doesn't really assign stuff right.
It seems like the axis all bind though but it's tricky to try to figure out what buttons register to what, along with trying to figure out what they were with practically little experience with FlightGear, flight sims, and joysticks in-general. At the very least I can control the plane in what feels like how I was doing it with some Aileron, Elevator, and Rudder bindings! I'm looking at Keyboard Shortcuts and compared what some stuff did, and found so far I only really need Flaps up/down since all I do it auto-start to the air :p Did a bunch of trial-and-error to figure out what column/row buttons tied to what physical joystick button, so as long as that doesn't change for some reason I can bind stuff to those later.

I tried some other USB load driver before that that also worked for the joystick and uhid#, but what I had initially didn't work for the joystick to show up on FlightGear without also messing with uhidd; I'll edit this with specific names later.

Basically, everything looks good now for getting my joystick to work with FlightGear on FreeBSD 14.1 with usb_load="YES" after a manual chmod on the uhid# for the joystick! But I have to understand the USB load thing a bit further because it looks like I lost my USB keyboard volume control.
 
Hmm, seems better to do hw.usb.usbhid.enable=1 and use uhidd. It looks like just running it to do a virtual device on the joystick (-h -u) and symlinking uvhid0 to uhid0 works fine without chmod! Fun stuff :p

Made even easier after reading the man page with uhidd -h -H 'uhid' -u '/dev/ugen0.6' now no longer requiring the symlink!
 
Hmm, seems better to do hw.usb.usbhid.enable=1 and use uhidd. It looks like just running it to do a virtual device on the joystick (-h -u) and symlinking uvhid0 to uhid0 works fine without chmod! Fun stuff :p

Made even easier after reading the man page with uhidd -h -H 'uhid' -u '/dev/ugen0.6' now no longer requiring the symlink!
Much more elegant and clean, rather than symlink by hand!
 
I wonder, is there a way to attach uhidd to a device without a specific ugen#.#? My joystick seems to always be on 0.6, but if I plug in another device before that or connect without my hub it seems like that might change?



I tried forcing uhidd in rc.conf on everything, my system hard-locked and rebooted, and I somehow lost the entire rc.conf file's contents; I'm back after a reinstall with even better settings now, noted that conf's contents to restore later if needed, and also learned how to mount UFS2 on a Linux LiveUSB :p
 
This devd.conf seems to work nicely! If I understand right, it looks like that whatever ugen becomes available on ATTACH that matches that vendor/product will execute the devd.conf script and thus the action to do uhidd on the ugen device that matched the vendor/product? It sounds fail-proof, but can ugen devices go above 9 (like ugen0.10)? Is it certain that uhidd will only be ran on the ugen that for-sure matches that specific vendor and product? Or any concern of that being able to be ran on any unrelated device?

Code:
ee '/usr/local/etc/devd/sidewinder-joystick-uhidd.conf'

Code:
notify 0 {
        match "type" "ATTACH";
        match "ugen" "ugen[0-9]+.[0-9]+";
        match "vendor" "0x045e";
        match "product" "0x0008";
        action "env LD_PRELOAD=/usr/lib/libcuse.so /usr/local/sbin/uhidd -h -H uhid -u /dev/$ugen";
};

Edit: Actually, it seems like I can remove the ugen match! (controller works still) Now it looks like the ugen is grabbed directly from the descriptor(?) data of the device that matched the vendor/product?

Code:
notify 0 {
        match "type" "ATTACH";
        match "vendor" "0x045e";
        match "product" "0x0008";
        action "env LD_PRELOAD=/usr/lib/libcuse.so /usr/local/sbin/uhidd -h -H uhid -u /dev/$ugen";
};

Or maybe it would be better to keep the ugen match in-case a different USB driver is ever used and the joystick ends up on a uhid# (or somewhere else) on its own? I use hw.usb.usbhid.enable=1 (usbhid) currently. I wonder if the ugen match rule could be done more-generic instead of hard-coding 0-9 (unless 9s the max?)
 
I can avoid using uhidd by temp-disabling usbhid before connecting my joystick!

I run this, plug-in my joystick within 3 seconds, and it's good-to-go for FlightGear (shows on fgjs and binds fine in-game):

Code:
su - root -c "sysctl 'hw.usb.usbhid.enable=0' && sleep 3 && sysctl 'hw.usb.usbhid.enable=1'"

I need to understand the USB system a bit better, but currently it's either I use usbhid and have working volume knob on my USB keyboard (while my U2F key and joystick need the workaround), or don't use usbhid and lose the USB volume knob (everything else seems fine USB-wise).

Is there a way to allow usbhid to use everything by-default, except for only 2 devices?
 
Back
Top