Reprogramming a USB Volume Knob

I want to reprogram a volume knob like this example:

I want to use it for SDR Radio programs.
Assuming this is a USB HID device I should be able to re-assign the device "events" to do other things correct?

On FreeBSD what would be the best approach? DEVD conf file for the vid/pid and reassigning events?
Since all the SDR Programs use a GUI I could just focus on a ./xorg.conf.d/10-device.conf type config file instead.

What do you think? devd is like Linux udev ?

Linux version of instructions:
 
Not sure how to re-program a knob like that, but when I made a Sound Voltex controller the encoder knobs showed under HID with an Arduino board: https://i.imgur.com/ibTtQBz.mp4

Iirc that HID app worked on Linux through Wine. I'm thinking the knob did show as a regular event or input device but wasn't bound to anything specific by-default (the HID app allowed selecting the knob on drop-down but not sure if it did specific device detection or just showed HID devices with axis inputs; mouse might have been selectable too and worked if I used that input config tool at the time)

2 rotary encoders, plastic knobs, and a Leonardo R3 board was about $25 and probably more flexible :D I forked some code for Arduino.
 
I ended up buying a USB Volume Control device off ebay.

Problem is no entry in /sys/dev/usb/usbdevs
Not even Vendor ID

Bastard device. Same exact device on Linux here:

The device shows up in usbconfig but not libinput or xinput. No events in libinput debug-events
ugen0.5: <product 0x553a vendor 0x413d> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (200mA)

On attachment it uses uhid0:
Code:
Jun 13 15:51:41 Dell-5540 kernel: ugen0.5: <vendor 0x413d product 0x553a> at usbus0
Jun 13 15:51:41 Dell-5540 kernel: uhid0 on uhub0
Jun 13 15:51:41 Dell-5540 kernel: uhid0: <vendor 0x413d product 0x553a, class 0/0, rev 1.10/0.00, addr 7> on usbus0

Is there any way to get the device working on FreeBSD without kernel recompile after adding VID/PID?

Would devd be able to help me? I saw NapoleonWils0n and this usbhidaction piqued my interest.

action "/usr/bin/usbhidaction -f $device-name -c /usr/local/etc/usbhidaction.conf"; };
How can it help me? Do I need to grin and bear a kernel recompile with bastard kernel??
 
I would like to see a system whereas layman could submit their VID&PID to a FreeBSD Wiki and a human screens them for validity.
Adding them to usbdevs in -CURRENT

Not pulling teeth with a PR and git gatekeepers.
Just to add devices.
 
I asked Gemini

Sometimes Gemini gets things completely wrong
other times it might point in the right direction

See if this help

The good news is: No, you do not need to recompile the kernel. Because the kernel log explicitly shows uhid0: <vendor 0x413d product 0x553a...> attaching successfully, FreeBSD's generic Human Interface Device (HID) driver has already claimed the hardware. The fact that it isn't listed in /sys/dev/usb/usbdevs just means the text database doesn't have a friendly name string for it—but functionally, the kernel sees it perfectly fine.

The reason libinput and xinput aren't seeing it is because they typically look for evdev devices (/dev/input/event*), whereas this has attached as a raw HID node (/dev/uhid0).

You can absolutely use devd and usbhidaction to get this working. Here is how to bridge the gap.

Step 1: Read the HID Report Descriptor
Before usbhidaction can map the volume knob, you need to know exactly what signals (usages) the knob is broadcasting when you turn or press it.

Plug in the device and run:

Code:
usbhidctl -f /dev/uhid0 -r

Note: Replace uhid0 with the exact number from your dmesg if it changes.

Turn the knob clockwise, counter-clockwise, and press it down. Look at the output. You are looking for names like Consumer:Volume_Increment, Consumer:Volume_Decrement, or generic relative XY axes/buttons.

Step 2: Create the usbhidaction Configuration
Create or edit the file /usr/local/etc/usbhidaction.conf.

Based on what usbhidctl showed you, define the actions. For a standard volume knob, the configuration usually looks something like this:

Code:
# Variable/Usage              Value   Action
Consumer:Volume_Increment     1       mixer vol +5
Consumer:Volume_Decrement     1       mixer vol -5
Consumer:Mute                 1       mixer vol toggle

(If your system uses OSS/mixer, the above commands work. If you use desktop-specific mixers like pactl for PulseAudio/PipeWire, swap the action commands accordingly, e.g., pactl set-sink-volume @DEFAULT_SINK@ +5%).

Step 3: Configure devd to Automate It
Now you can add a block to your /etc/devd.conf (or a dedicated file in /etc/devd/) using your device's specific Vendor ID (0x413d) and Product ID (0x553a).

Modify your template like this:

Code:
notify 100 {
    match "system"    "USB";
    match "subsystem" "DEVICE";
    match "type"      "ATTACH";
    match "vendor"    "0x413d";
    match "product"   "0x553a";
    action "/usr/bin/usbhidaction -f /dev/uhid0 -c /usr/local/etc/usbhidaction.conf";
};

Crucial Catch: In your original draft, you used $device-name inside the action statement. devd passes variables like $device-name for certain subsystem rules, but under a generic USB attach notification, it might evaluate to the generic parent ugen0.5 rather than /dev/uhid0. Hardcoding /dev/uhid0 works if it's your only extra HID device, but if you want it dynamically matched, ensure your block targets the DRIVER subsystem or use $cdev depending on your FreeBSD version layout.

After saving your devd configuration, restart the daemon to apply the changes:

Code:
sudo service devd restart

Why libinput isn't working (Alternative Route)
If you would rather have this knob act like a standard multimedia keyboard shortcut so X11/Wayland windows can natively capture it, you need the hkbd (USB HID keyboard) driver or the evdev interface to intercept it instead of generic uhid.

However, using devd + usbhidaction is the cleanest, most "FreeBSD-native" way to handle cheap, non-standard USB volume wheels without bloating your input stack.
 
Back
Top