# Logitech multimedia keyboard

## Loke

Ive recently purchased a logitech wireless optical desktop, and the keyboard has "multimedia" keys. However my dmesg log is flowing over with:

```

keyboard.c: Cant emulate raw mode for keykode: 272

```

This entry is repeated many hundred times, making it impossible to see the useful information dmesg produce. To solve this, Id either have to fix the keyboard.c file, or somehow make dmesg ignore this message - or perhaps fix the keyboard layout somehow. Any suggestions? Thanks, and cheers!

----------

## nitro322

what exactly is causing the problem?  Does it occur everytime you press one of the keys?  Or is it happening on it's own?  I've had a couple multimedia keyboards that I've used under Linux, and I don't recall seeing those error messages, so I'm a little curious about why you're getting them (unless you are pressing the buttons, in which case it's probably just telling you that it doesn't know what to do).

By default, multimedia (and other miscellaneous) buttons do not work under Linux (nor Windows - they need certain drivers/apps from the manufacturer).  You can get these to work by tweaking various keyboard map files, but I've had the most luck by using a program called lineak.  This program runs as a daemon and has built-in support for many types of multimedia keyboards.  There's no ebuild for it (unfortunately), but you can download it from the link above.

Hope this helps.

----------

## Loke

It happens automagically  :Smile:  Im using xmms-itouch to enable my multimedia keys, its a plugin for xmms. But I still need to load xmms in order to use them. However, I get these errors in dmesg even though I dont load it. In fact, right after boot its already about 10 entries in dmesg showing this... Really strange.

----------

## Loke

Ok, my last post wasnt entirely accurate - I do have to actually use the keyboard before such entries appear in the log. But no matter if its fluxbox or kde, they still appear for no special reason. Even if I dont try to configure them  (which could have explained the error messages)

Annoying as h***... Must be a config problem with XF86Config... Ill play with that and see what I can archieve.

Edit: Ok, now Ive found some more. Actually it isnt KDE, or X or some other program. It happens ALL the time! Doesnt matter if Im in X or a virtual terminal. Whenever I press my mouse, or one of the F1-F12 keys or any of the "multimedia" keys I get:

```

keyboard.c: can't emulate rawmode for keycode 272

```

or some other number, changing according to what key I press. The event over was generated by pressing my mouse =/ Now that the problem is identified, how the #¤""% do I get rid of it. Its not even remotely amuzing, because I used dmesg alot before to check whats going on but now its crowded with such messages. This happened after I bought my new "Logitech Wireless Optical Desktop", and not with my old Logitech wireless desktop. Please, any suggestion is appreciated bigtime! And please note: Im not interested in configuring the keys or whatever, I just dont want these error messages to appear in dmesg!  :Sad:  Im fine with the fact that the kernel doesnt know what to do when/if I press these keys, just as long as it doesnt bother me in the logs...

----------

## kybber

Does your keyboard offer you a choice between using the USB or the PS/2 port? If so, then I suggest you use the PS/2. For some reason the keycodes for the special keys are different on the two ports. The kernel only accepts keycodes up to 255, and when your keyboard produces some in the 270's, the kernel complains. But the keycodes through the PS/2 port are all below 255. 

I know it's a pain to not use USB when you can, but at least this solution worked for me with the same keyboard.

----------

## Loke

Yes, I am using USB, but tbh Id use PS/2 any day over USB. But for some strange reason I cant. If using the ps2 ports instead of usb, in windows my mouse isnt detected and in linux if I cat /proc/driver/nvidia/bios, I get bios revision showing as ???? ???? ???? and thus the NVdriver fail to load. Ive verified this over and over again, and it is indeed the keyboard and mouse combo on ps2 which is causing this in conjunction with my motherboard. Trying it on another computer with ps2 ports works as expected. Ive emailed Gigabyte about this issue, but they failed to reproduce it... 

What daemon is responsible for writing to dmesg btw? Im using metalog as a logger, so I expect its this one? Maybe I can instruct it not to log such events? Damn, this is annoying.

----------

## kybber

You might be able to get away with making a small change to keybdev.c (which seems to be responsible for outputting the error, not keyboard.c as indicated) and then recompile your kernel. I have not tested this, but this is what I'd do:

cd into /usr/src/linux/input

cp keybdev.c keybdev.c.bak

edit keybdev.c

Locate the following line:

```
if (keycode > 255 || !x86_keycodes[keycode])
```

(line 110) inside the function emulate_raw.

Change it to

```
if (!x86_keycodes[keycode])
```

Then recompile your kernel, make sure you have a backup of your old kernel, and try it out. If it doesn't work, replace keybdev.c with the bak-file, and either recompile or exchange your new kernel with your old one.

If you try this, then please let me know how it went!

----------

## Loke

Hehe, the crowd goes wild! Of course this will work!  :Very Happy:  Thank you for grepping through the kernel source for me, cant believe I didnt think of that so /me slaps myself again. I didnt remove the keycode > 255 in the if-statement, I changed 255 to 273 since I dont see any errors over 273 afair. If I do, I'll just change it to the according number. 

Again, thank you very much  :Smile:  Im recompiling my kernel now...

----------

## slak

if u are using gnome, u should grab acme; i think that it's better than xmms-itouch; otherwise i'd use hotkeys

----------

## Loke

In case anyone else stumbles upon the problems described above, the attached solution posted before is NOT correct. This is what the keybdev.c maintainer says:

```

> Hello,

> 

> Ive just bought a logitech usb keyboard and using it under linux, but in

> dmesg I see alot of:

> 

> keyboard.c: can't emulate rawmode for keycode 272

> 

> repeated several hundred times. The above was generated by pressing

> my mouse1 button. Every other multimedia key also generates a

> keycode error. 

> 

> In keybdev.c I see you have defined a x86_keycode array, and

> perform the  following test:

> 

>     if (keycode > 255 || !x86_keycodes[keycode])

> 

> At first i thought your code must be faulty, that it should be AND (&&) 

> instead of OR (||), but trying that produced unexpected results.  The

> way i interpreted the code was that if a keycode is reported greater

> than 255, AND that keycode is not in the x86_keycode array, then the

> function should return -1. But I must have mistaken about this.

The || is unfortunately correct.

The PS/2 raw mode can only report so many different keys (about 240,

as far as I remember), and those are all used up already. The correct

way would be to teach X not to use raw mode for keyboard input, and

get rid of this code completely.

> So now im wondering what the appropriate way to handle this is? I can

> of course set keycode > 27X something, but wanted to check with you

> first. This probably requires a change of code anyway, since we cant

> have dmesg flodded with the above error message. 

For local use, you can tweak the code to subtract something from

keycodes above 255. Then they will alias with some other keycodes (which is bad), but your keyboard probably doesn't have them.

-- 

Vojtech Pavlik

SuSE Labs

```

By changing the value for (keycode > 2XX), I got unexpected results in KDE for example , see  this post: https://forums.gentoo.org/viewtopic.php?t=25622 - so this is not a solution. My suggestion if someone experience this, is to prevent keybdev.c to trigger the kernel print kprint warning completely. This is of course a temporary fix.

----------

