# Multimedia Keys



## CodeBlock (Aug 13, 2009)

I have a Logitech USB keyboard, and would like to get my multimedia keys playing nice. `xev` doesn't show anything for them, so I really have no clue where to start. Any insight?


----------



## graudeejs (Aug 13, 2009)

xmodmap(1)


----------



## graudeejs (Aug 13, 2009)

here's example
~/.xmodmaprc

```
keycode 153 = XF86Favorites
keycode 178 = XF86HomePage
keycode 236 = XF86Mail
keycode 144 = XF86AudioMute
keycode 174 = XF86AudioLowerVolume
keycode 176 = XF86AudioRaiseVolume
keycode 162 = XF86AudioPlay
```

then you need to assign shortcuts to these keys using these names
note: codes are keyboard dependant


----------



## CodeBlock (Aug 13, 2009)

killasmurf86 said:
			
		

> here's example
> ~/.xmodmaprc
> 
> ```
> ...



Right, but I have no way of getting the codes because the media keys aren't recognized by xev or similar programs.


----------



## graudeejs (Aug 13, 2009)

are you sure, xev doesn't show keycodes?
can you show screenshot [if it's possible to capture]

you can run xev in one terminal, and in other terminal run

```
$ sleep 10 && import -window root ~/screenshot.png
```
if you have ImageMagick installed


----------



## CodeBlock (Aug 13, 2009)

`xev` literally shows no output on the media keys, like they aren't recognized at all.... I'll attach a screenshot, but it's kind-of pointless as xev shows nothing.. It shows for the other keys, and for mouse, but nothing for the media keys:

*edit: okay, image was way too big to


----------



## graudeejs (Aug 13, 2009)

Well, then..... I have no clue..., sorry


----------



## avilla@ (Aug 13, 2009)

i had the same problem, and found an old thread on the lists which said that xev(1) doesn't know about some keys... so i started a live archlinux, used `$ showkey` to record the keycodes, and now i'm going to add them to ~/.Xmodmap
that should work!


----------



## SirDice (Aug 13, 2009)

Also have a look at the keyboard Xorg detected. Some might not produce all the keycodes. I've had mixed results trying to get multimedia keys working with different keyboards.


----------



## aragon (Aug 13, 2009)

It only works with PS/2 keyboards AFAIK.  I take it you're using a USB keyboard?


----------



## CodeBlock (Aug 14, 2009)

Yes, usb. I'll try booting a livecd and give that a shot like xzhayon said.


----------



## aragon (Aug 14, 2009)

I think you will have better luck if you connect your keyboard via a USB->PS2 adapter into the PS2 port.


----------



## CodeBlock (Aug 14, 2009)

The reason I can't do that is because it's a wireless keyboard and mouse combo, and only uses one usb port for the receiver, not one for keyboard and one for mouse... I guess it's kind of a lost cause for now, maybe worth submitting a PR and some driver hacker can look into it?


----------



## aragon (Aug 14, 2009)

Yea, go for it.  I suspect it's one of those "bugs" that haven't annoyed enough people yet for it to be fixed.


----------



## mart (Aug 14, 2009)

@CodeBlock

You don't say exactly which logitech model this is (sadly, it matters).  There was a similar thread here.  Arch and Gentoo have good keycode lists for most models (that should transfer across assuming your particular model has decent kernel support, which isn't a given).



			
				CodeBlock said:
			
		

> I guess it's kind of a lost cause for now, maybe worth submitting a PR and some driver hacker can look into it?



Please do, but don't be surprised if their fix is ignored.  My keyboard issue was 'fixed' years ago (PR patch), but has still not been integrated.  I have to patch the kernel manually to get the use of function keys.


----------



## segin (Jun 13, 2010)

I've a Compaq Internet Keyboard, 18 key variety, and I have discovered why your multimedia keys work on Linux and not FreeBSD, sorta.

It's like this: X gets it's mouse data from /dev/sysmouse and it's keyboard data from /dev/kbdmux0. All data from input devices passes through the FreeBSD kernel and ends up being fed to X from these endpoints. The FreeBSD kernel appears to be silently dropping keypresses for keys it doesn't recognize. 'xev' is reporting nothing because X isn't even receiving the keycodes as the kernel is dropping them before they get to X.


----------



## segin (Jun 13, 2010)

segin said:
			
		

> I've a Compaq Internet Keyboard, 18 key variety, and I have discovered why your multimedia keys work on Linux and not FreeBSD, sorta.
> 
> It's like this: X gets it's mouse data from /dev/sysmouse and it's keyboard data from /dev/kbdmux0. All data from input devices passes through the FreeBSD kernel and ends up being fed to X from these endpoints. The FreeBSD kernel appears to be silently dropping keypresses for keys it doesn't recognize. 'xev' is reporting nothing because X isn't even receiving the keycodes as the kernel is dropping them before they get to X.



Oh, as a solution, try using sysutils/uhidd as a user-mode input driver. According to the uhidd entry in the FreeBSD Wiki, this will give you what you want.


----------



## aragon (Jun 14, 2010)

segin said:
			
		

> Oh, as a solution, try using sysutils/uhidd as a user-mode input driver. According to the uhidd entry in the FreeBSD Wiki, this will give you what you want.


Thank you!  For the first time ever I can use the multimedia keys on my Logitech Wave keyboard.


----------



## hedgehog (Jul 13, 2010)

KDE4 users could try to choose their keyboard model (or similar) in the system settings.
System Settings - Regional & Language - Keyboard Layout - Keyboard model

This option allowed me to use all of the multimedia keys on my KB


----------



## aragon (Jul 13, 2010)

hedgehog said:
			
		

> This option allowed me to use all of the multimedia keys on my KB


Is your KB a USB KB?  Make & model?


----------



## hedgehog (Jul 13, 2010)

aragon said:
			
		

> Is your KB a USB KB?  Make & model?


nope, my keyboard is ps/2 KB: mitsumi, kfk-eb9hy. I chose "Logitech iTouch Internet Navigator Keyboard SE" to let my multimedia keys work. But there is also the same logitech model in the list, but for USB keyboard. I suppose it worth to try before installing any other drivers. Can't test it myself because I don't have an USB keyboard with media keys


----------



## aragon (Jul 13, 2010)

hedgehog said:
			
		

> nope, my keyboard is ps/2 KB


Yep, PS/2 keyboards generally work without fuss.


----------



## indulekha (Sep 2, 2010)

I found that better than the multimedia keys is just installing xbindkeys and then you can create keybindings that do the multimedia stuff (I think gnome and kde users already have that functionality, but then they have to deal with bloatiness). Especially great when you have to use multiple machines, plus of course you're not limited to only multimedia tasks.


----------



## ikbendeman (Sep 4, 2010)

I don't really get how to set up uhidd...


----------



## ikbendeman (Sep 4, 2010)

aragon said:
			
		

> Thank you!  For the first time ever I can use the multimedia keys on my Logitech Wave keyboard.



How do you find out which ugen to use? My usb keyboard is on my laptop and thus it is built in so I can't just unplug and plug-in and watch dmesg for it...

usbconfig reports only:

```
ugen0.1: <OHCI root HUB ATI> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON
ugen1.1: <OHCI root HUB ATI> at usbus1, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON
ugen2.1: <EHCI root HUB ATI> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON
ugen3.1: <OHCI root HUB ATI> at usbus3, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON
ugen4.1: <OHCI root HUB ATI> at usbus4, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON
ugen5.1: <EHCI root HUB ATI> at usbus5, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON
ugen2.2: <HP Webcam Vimicro Co.,ltd> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON
ugen4.2: <product 0x0001 vendor 0x0a12> at usbus4, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON
ugen2.3: <USB2.0-CRW Generic> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON
```


----------



## aragon (Sep 4, 2010)

ikbendeman said:
			
		

> How do you find out which ugen to use? My usb keyboard is on my laptop and thus it is built in so I can't just unplug and plug-in and watch dmesg for it...


Laptop keyboards usually interface via PS/2, in which case your multimedia keys should work.  Run xev from an xterm to get the keycodes.


----------



## hruodr (Jan 21, 2021)

I have the same problem the OP has. And I do not want to use X.
Any known solution?


----------



## frzburn (Jan 21, 2021)

hruodr said:


> I have the same problem the OP has. And I do not want to use X.
> Any known solution?


It's your lucky day. I've been working on the same issue on my desktop for a couple of days, without success in Xorg. BUT! It works in console. Here's what I've done, YMMV:

1. Find your keyboard USB device:
`# usbconfig`

My usbconfig output shows:
`ugen1.1: <Intel EHCI root HUB> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen2.1: <0x1b21 XHCI root HUB> at usbus2, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen3.1: <Intel EHCI root HUB> at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen0.1: <0x8086 XHCI root HUB> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.2: <Logitech Gaming Mouse G502> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (300mA)
ugen1.2: <vendor 0x8087 product 0x800a> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen3.2: <vendor 0x8087 product 0x8002> at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen0.3: <ASUS OSD ASUS OSD> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (2mA)
ugen0.4: <ASUS TEK. ASM107x> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (100mA)
ugen0.5: <ASUS TEK. ASM107x> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (100mA)
ugen0.6: <vendor 0x131d product 0x0159> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (366mA)
ugen0.7: <American Power Conversion Back-UPS RS 1500G FW:865.L5 .D USB FW:L5> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (2mA)
ugen0.8: <Generic Flash Card Reader/Writer> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (250mA)
ugen0.9: <Logitech Logitech G710 Keyboard> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (400mA)
ugen0.10: <ASUS TEK. ASM107x> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (2mA)
ugen0.11: <ASUS TEK. ASM107x> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (2mA)`

My keyboard is on ugen0.9. Keep your device number in mind.


2. Install sysutils/uhidd

Wiki documentation: https://wiki.freebsd.org/uhidd

Load the vkbd kernel module. uhidd complains that it needs it, so:
`# kldload vkbd`

I can get uhidd to work and catch my multimedia keys with the -ou flags. Make sure that you have either another keyboard to plug in, or that you can SSH into your box, otherwise you could end up with no functioning input if you use the wrong flags. I had to experiment around a bit to find what worked for me.

Start uhidd on the command line with additionnal -dv flags so it runs in foreground, not in daemon mode and with verbose enabled, so you'll see it if it catches your keystrokes:
`# uhidd -douv /dev/ugen0.9`

Use the appropriate ugenX.X from usbconfig's output in the previous step.

You'll see a new line appear each time you press a new multimedia key. My output looks like this, after pressing, in that order, mute, volume up, volume down:
`uhidd 65233 - - open /usr/local/etc/uhidd.conf failed: No such file or directory
uhidd 65233 - - proceed without configuration file
ugen0.9[0]-> HID interface
ugen0.9[0]-> Report descriptor size = 65
ugen0.9[0]-> Find IN interrupt ep: 0x81 packet_size=0x8
ugen0.9[1]-> HID interface
ugen0.9[1]-> Report descriptor size = 149
ugen0.9[1]-> Find IN interrupt ep: 0x82 packet_size=0x20
ugen0.9[1]-> kbd device name: vkbdctl6
ugen0.9[1]-> HID interface task started
ugen0.9[1]-> remembered new hid key map: 0xe2 => 0x54
ugen0.9[1]-> remembered new hid key map: 0xe9 => 0x5a
ugen0.9[1]-> remembered new hid key map: 0xea => 0x5f`


Keep uhidd running. All registered keys are written in /var/run/uhidd.ugenX.X/cc_keymap. Copy that file in /usr/local/etc/uhidd.conf (or your can skip this, uhidd will scan them each time they are first used, according to the wiki). Still using ugen0.9 in my example:
`# cp /var/run/uhidd.ugen0.9/cc_keymap /usr/local/etc/uhidd.conf`


3. Install misc/kbdscan

Run kbdscan and hit your multimedia keys. It'll give you their keycodes. It will only work in console. Not in Xorg, not even in tmux.


4. Make uhidd run as a service

You can kill uhidd for now. Edit your /etc/rc.conf to add:
`vkbd_enable="YES"
uhidd_flags="-ou"
uhidd_enable="YES"`

Then start the service with
`# service uhidd start`


5. Use the keycodes that you found with kbdscan in whatever program you use in the console.


Good luck!


----------



## Menelkir (Jan 21, 2021)

Try sysutils/iichid, it works pretty well with some keyboards I have.


----------



## frzburn (Jan 21, 2021)

Menelkir said:


> Try sysutils/iichid, it works pretty well with some keyboards I have.


You are a goddam savior. I've search this for DAYS, never found even one mention of iichid.

I just installed it, loaded the module, and voila!!

Thanks a lot!!




> Not all heroes wear capes. Sometimes, they wear donkey heads.


--frzburn


----------



## Snurg (Feb 12, 2021)

To make full use of what you learned here, I would like to point you to this thread and particularly to what SirDice told there. Personally, I found that _extremely useful_ for customizing.


----------



## sidetone (Feb 13, 2021)

Instructions for setting up sysutils/iichid are at: https://github.com/wulf7/iichid, as stated in the `pkg-message` file. https://larastechlab.blogspot.com/2020/01/i2c-touchpads-on-freebsd-130-current.html is a little less informative on setting it up.

It says load it through /boot/loader.conf so the other hid driver won't conflict with it. It also mentions reloading the driver manually as an option.

When running `make config`, USB (HID over USB support) is unchecked by default. It may be meant to work this way, as compiling it with this option may conflict with the default HID driver.

Multimedia keys didn't work for me. When I made a /usr/local/etc/x11/xorg.conf.d/ file for this, my arrow keys stopped working. A few of these buttons seemed to react to being pressed, but didn't do their function. When I deleted this file and restarted Xorg, my arrow keys started working again.


----------



## ethoms (Jun 3, 2021)

Menelkir said:


> Try sysutils/iichid, it works pretty well with some keyboards I have.


Thank you very much for this post. I have spent the best part of a day trying to get this working on my bedroom mediacentre PC with TV as display.

My USB soundcard is connected to to my HiFi amplifier and a nice pair of speakers. I'm using audio/musicpd (mpd server) to play my music collection and SomaFM internet radio. And using SMPlayer for bespoke video playback, but otherwise using KODI for video entertainment. Enlightenment is my DE, and it is setup nicely now, so beautiful and functional. The last thing I needed was to get my Multimedia keys working on my main keyboard (Velocifire TKL02WS) and a small wireless keyboard and touchpad (see link below of similar product) which is ideal for controlling KODI. Both of which did not have any multimedia keys working. But now work perfectly without any other configuration in Xorg or Enlightenment. I deleted the default key bindings for XF86AudioMute, XF86AudioRaiseVolume and XF86AudioLowerVolume in Enlightenment settings panel. Now SMPlayer will pick them up for application specific volume and mute control. I assume the same will apply for KODI. This is useful to me because the mixer gadget which normally is controlled by those multimedia key bindings changes the system mixer 'vol', which affects my mpd playback volume. With application level volume control, I get exactly what I want. Super sweet setup now! 

Only thing left now is to get Widevine support so I can watch Netflix in KODI. Until then, I may need to order a 'ROKU Express'. I'm in no hurry, but must please the spouse.

Easytone mini wireless keyboard

I could not get sysutils/uhidd to work after much trial and error and following all the instructions I could find. Thanks to frzburn for pointing out it only works in console, which I managed to achieve and test with `kbdscan`.

These are my steps to get it working (as root/toor user) on FreeBSD 12.2:

EDIT: I just noticed that the 'USB' port option is not required for multimedia keys to work on my wireless USB keyboard. So the binary package will do fine.

install sysutils/iichid


```
pkg install sysutils/iichid
ee /boot/loader.conf
```

add the following to the boot loader config file contents.


...
ig4_load="YES"
iicbus_load="YES"
iichid_load="YES"
hw.usb.usbhid.enable=1
....


reboot et voila.


----------



## Menelkir (Jun 3, 2021)

ethoms said:


> Only thing left now is to get Widevine support so I can watch Netflix in KODI.


There's no widevine for FreeBSD atm, but you can install a linux browser that have using this: https://github.com/mrclksr/linux-browser-installer



ethoms said:


> ig4_load="YES"
> iicbus_load="YES"
> iichid_load="YES"
> hw.usb.usbhid.enable=1


For FreeBSD 13 and beyond, this is everything you need since iichid is part of the kernel.


----------



## ethoms (Jun 3, 2021)

That's good to know Menelkir, I was wondering if/when this would make it into FreeBSD base.

I haven't ventured into 13.0 land yet. I need to do some reading up on the new ZFS implementation yet. I feel confident with 12.x for now. Even though no dot-zero version has really let me down. _Well, apart from major breakage of ipfilter in 10.0-RELEASE, which had the silver lining of forcing me onto pf_. I may wait until 13.1 comes out, there are some big changes in 13 which I have not had time to read up on yet.

I updated my post above, the port option is not required. I think I just needed a reboot after the pkg version was installed to get it working.


----------



## ethoms (Jun 3, 2021)

Menelkir said:


> There's no widevine for FreeBSD atm, but you can install a linux browser that have using this: https://github.com/mrclksr/linux-browser-installer



Wow, that sounds great. Thanks for the heads up. I will take a look at it soon. I did some pretty extensive searching around for a solution about a month or two ago, and I did not find a solution for Netflix support. I'm really glad now, that I went off-topic on my previous post. May have saved me buying that ROKU and yet another device to setup and maintain.


----------



## scottro (Jun 3, 2021)

There's also a post on the forums about getting chrome or brave-browser to work to play widevine, that worked quite well for me.









						[Linuxulator] How to install Brave (Linux app) on FreeBSD 13.0+
					

Important notes: 1) This guide is for FreeBSD 13.0 and newer only!! For FreeBSD 12, please see: https://forums.freebsd.org/threads/linuxulator-how-to-run-google-chrome-linux-binary-on-freebsd.77559/ 2) This method should be valid for installing any other Chromium-based web browser (Google...




					forums.freebsd.org
				




But I have to admit, this link seems quicker and easier.


----------



## ethoms (Jun 3, 2021)

Interesting side-note to this. The iichid seems to have fixed my issue with my USB-C keyboards and FreeBSD. They work fully in Linux on the same hardware. 

But on FreeBSD, prior to using iichid, they would only work if plugged into the laptop before boot and direct to the laptop USB 2.0 interface . If plugged in after boot or into the dock, they would not work at all. If unplugged, and plugged in again, not working.

And with FreeBSD with iichid setup, they now work in all these scenarios, even after repeated unplug/plug cycles. However, the modifiers do not work, which makes it almost useless. The one I'm using now, my wireless 'Velocifire TKL02WS', works fully with the wireless USB dongle, but not when using the wired USB-C cable. So iichid seems to have fixed the connectivity, but caused another issue with modifiers (two keys at once). I suspect it's to do with N-key rollover.


----------



## ethoms (Jun 3, 2021)

OK, more on the modifier keys not working issue. My other USB-C keyboard works fine, the shift gives me capitals and Alt +... works. It is a custom mechanical keyboard: *KBDfans KBD8x*.

The *Velocifire TKL02WS* needs a usb quirk added to /boot/loader.conf:


```
hw.usb.quirk.0="0x062a 0x8503 0 0xffff UQ_KBD_BOOTPROTO"
```

I think this is a seperate issue from the connectivity issue solved by iichid.

See this thread for more info on this and other USB keyboard issues:








						USB Keyboard not working properly (10.2)
					

I'm interested in using FreeBSD on my desktop, but the keyboard might be a problem. During installation I thought the keyboard wasn't detected at all but after some testing through virtual machines and connecting the keyboard to a FreeBSD laptop, I've found out that 95% of the keys don't do...




					forums.freebsd.org


----------



## Menelkir (Jun 3, 2021)

ethoms said:


> Interesting side-note to this. The iichid seems to have fixed my issue with my USB-C keyboards and FreeBSD. They work fully in Linux on the same hardware.
> 
> But on FreeBSD, prior to using iichid, they would only work if plugged into the laptop before boot and direct to the laptop USB 2.0 interface . If plugged in after boot or into the dock, they would not work at all. If unplugged, and plugged in again, not working.
> 
> And with FreeBSD with iichid setup, they now work in all these scenarios, even after repeated unplug/plug cycles. However, the modifiers do not work, which makes it almost useless. The one I'm using now, my wireless 'Velocifire TKL02WS', works fully with the wireless USB dongle, but not when using the wired USB-C cable. So iichid seems to have fixed the connectivity, but caused another issue with modifiers (two keys at once). I suspect it's to do with N-key rollover.


Make a bug report, maybe is something easy to fix by the devs.


----------



## ethoms (Jun 3, 2021)

I will make some bug reports soon.

Just for clarity; I have all my keyboard issues resolved now. The sysutils/iichid port fixes multimedia keys not working on my two wireless (USB dongle) keyboards and it fixes my KBD8x USB-C connectivity issue. The usb quirk in /boot/loader.conf fixes the modifier keys not working on my Velocifire TKL02WS when used with a USB-C cable. The TKL02WS on wireless dongle does not have the modifier keys issue.


----------

