Last updated: 2019-02-24
My keyboard has some multimedia keys (and mice can have them too). Pressing these keys without the uhidd driver installed crashes my USB on FreeBSD. Not kidding.
Basically here is what this does: uhidd replaces your standard USB keyboard driver. Now when you press your multimedia keys the driver will send a fake key number to X11 that you can remap with xmodmap to any other key (usually the multimedia key you want but it could be anything). This is a complex procedure requiring you to run the driver, get the results, check the results in xev, and map them again in xmodmap.
You will need to read some outside help:
I think this doesn't disable the standard USB keyboard driver on boot. At login, I get double keys entered until I replug the keyboard.
You need the uhidd package
pkg install uhidd
You need to add to /etc/rc.conf
uhidd_flags="-kmohs"
uhidd_enable="YES"
Load the uhidd module by rebooting or
kldload uhidd
Find your USB device
usbconfig
My mouse and keyboard
ugen1.3: Logitech Gaming Mouse G502
ugen1.4: vendor 0x04b4 Gaming Keyboard
To start and stop this driver (X.Y are the USB ugen numbers)
/usr/local/etc/rc.d/uhidd start /dev/ugenX.Y
/usr/local/etc/rc.d/uhidd stop /dev/ugenX.Y
Press the keys on your keyboard you want to map and look in /var/run/uhidd.ugenX.Y/cc_keymap (where X.Y is your keyboard (/dev/ugenX.Y).<\p>
Copy the contents of that file to /usr/local/etc/uhidd.conf and restart the daemon.<\p>
Note: This is only created when you don't have a map file already! Delete the file if you need to re-do something.
Here's what my /usr/local/etc/uhidd.conf looks like for my keyboard:
#Nixeus keyboard
# idVendor = 0x04b4 idProduct = 0x0802
0x04b4:0x0802={
mouse_attach="NO"
kbd_attach="YES"
cc_attach="YES"
vhid_attach="YES"
vhid_strip_id="YES"
detach_kernel_driver="YES"
cc_keymap={
Scan_Next_Track="0x62"
Scan_Previous_Track="0x74"
Stop="0x70"
Play/Pause="0x54"
Mute="0x63"
Volume_Increment="0x75"
Volume_Decrement="0x5f"
}
}
Restart the driver for your USB device (1.4 is my keyboard)
/usr/local/etc/rc.d/uhidd start /dev/ugen1.4
At this point the keys still won't do what you want. They merely produce the number code when you press the key. For example, in my file pressing Mute sends the keynumber "0x63" to X11 and that does nothing. All the numbers should be set to things that do nothing.
Install xbindkeys
pkg install xbindkeys
Run xev and press each of your multimedia keys and watch the output to see the number it produces. For each number you receive, put it in the appropriate section of this file and save it to .xmodmap in your home directory:
keycode 219 = XF86AudioPrev
keycode 92 = XF86AudioPlay
keycode 189 = XF86AudioNext
keycode 208 = XF86AudioStop
keycode 190 = XF86AudioMute
keycode 184 = XF86AudioLowerVolume
keycode 220 = XF86AudioRaiseVolume
Note: if a key doesn't produce any number you will have to change the number code it produces in uhidd.conf.
Run xmodmap .xmodmap and have working multimedia keys. (I add this line to my /home/darren/.xinit)
xmodmap .xmodmaprc
Something need fixing? Contact me: