# Making unknown keycodes work

## miwalter

Hi,

I found out (using evtest), that my Microsoft Wireless Optical Elite Keyboards (connected using USB) produces events in /dev/input/event3 for several keys where I can't get xev to output something (e.g. Favorites-Keys, Tiltwheel on keyboard ...).

I get the following output:

```
type 1, code 269, value 1 (Wheel right)

type 2, code 9, value -1 (Wheel down)

type 3, code 44, value 1 (Favorite 1)
```

But I don't know how to translate these for everyday-usage (e.g. setkeycodes or similar tools). Does someone know how to translate these events to actually use them to activate these keys?

Thanks in advance,

Mirko

----------

## syagin

just make a .Xmodmap file in your home dir whre u specify the keycode to function keys e.g.: keycode 45 = F23

then u can set them to the functions u want in the kcontrolcenter or lineak or u can use xbindkeys.

here my xbindkey and xmodmap file:

xmodmap

! Volume + ()

keycode 176 = F13

! Volume - ()

keycode 174 = F14

! Scroll ()

keycode 245 = F15

! Standby ()

keycode 227 = F16

! WakeUp ()

keycode 223 = F17

! Mute ()

keycode 160 = F18

! Back ()

keycode 144 = F19

! Stop ()

keycode 164 = F20

! Play ()

keycode 162 = F21

! Forward ()

keycode 153 = F22

! FN Lock ()

keycode 244 = F23

! 1 ()

keycode 147 = F24

! Search ()

keycode 149 = F25

! Favorite ()

keycode 148 = F26

! WWW ()

keycode 146 = F27

! EMail ()

keycode 236 = F28

and now xbindkeysrc

# For the benefit of emacs users: -*- shell-script -*-

###########################

# xbindkeys configuration #

###########################

#

# Version: 1.7.1

#

# If you edit this file, do not forget to uncomment any lines

# that you change.

# The pound(#) symbol may be used anywhere for comments.

#

# To specify a key, you can use 'xbindkeys --key' or

# 'xbindkeys --multikey' and put one of the two lines in this file.

#

# The format of a command line is:

#    "command to start"

#       associated key

#

#

# A list of keys is in /usr/include/X11/keysym.h and in

# /usr/include/X11/keysymdef.h

# The XK_ is not needed.

#

# List of modifier:

#   Release, Control, Shift, Mod1 (Alt), Mod2 (NumLock),

#   Mod3 (CapsLock), Mod4, Mod5 (Scroll).

#

# The release modifier is not a standard X modifier, but you can

# use it if you want to catch release events instead of press events

# By defaults, xbindkeys does not pay attention with the modifiers

# NumLock, CapsLock and ScrollLock.

# Uncomment the lines above if you want to pay attention to them.

#keystate_numlock = enable

#keystate_capslock = enable

#keystate_scrolllock= enable

# Examples of commands:

"xbindkeys_show" 

  control+shift + q

# set directly keycode (here control + f with my keyboard)

"xterm"

  c:41 + m:0x4

# specify a mouse button

"xterm"

  control + b:2

"kfmclient openProfile webbrowsing"

  F27

"kmail &"

  F28

#Xmms Play/Pause

"xmms -t&"

F21

#Xmms Stop

"xmms -s&"

F20

#Xmms Next

"xmms -f&"

F22

#Xmms Prev

"xmms -r&"

F19

#"xterm -geom 50x20+20+20"

#   Shift+Mod2+alt + s

#

## set directly keycode (here control+alt+mod2 + f with my keyboard)

#"xterm"

#  alt + c:0x29 + m:4 + mod2

#

## Control+Shift+a  release event starts rxvt

#"rxvt"

#  release+control+shift + a

#

## Control + mouse button 2 release event starts rxvt

#"rxvt"

#  Control + b:2 + Release

##################################

# End of xbindkeys configuration #

##################################

and that should do the job

----------

## miwalter

I did that with some of the special keys already - but I'm still missing some of them (e.g. the Favorite-Keys). Did you solve this, too?

The keys don't send events to xev. They do appear in the event-interface, though. I think there might be a way to map these event-interface-events to some other interface which xev can read - and which I can map using Xmodmap then... maybe I'm not right here.

----------

## syagin

i've got the same problem first i worked with xev though...

then for 2 days now xev doesn't get the events of 5 keys i helped myself with pressing the key and then look for the output in dmesg.

there it says there was an event e.g. e074 to make the event known

do "setkeycodes e074 <keycode>"

for me it was "setkeycodes e074 188"

now xev recognizes the key with this code, so u can just do as u did with the other keys that xev knew.

the only problem i still have is that it's all gone when irestart my machine.

so still working on that , may be you know what i can do about that?

----------

## miwalter

 *syagin wrote:*   

> 
> 
> so still working on that , may be you know what i can do about that?

 

Maybe add "setkeycodes [...]" to /etc/conf.d/local.start?

Besides. Dmesg doesn't print anything when I press theses keys. Hm. I will try getting some more info on the event-interface, maybe that will help resolving this issue.

----------

## nix_newb

The man page for setkeycodes mentions showkey.  showkey apparently reads dev/console...  I'm going to have to try this when I get home.  It looks like showkey would give you the hex for the event of the keypress and then setkeycodes would let you map the scancode to the keycode.  Then you could map the keycode to a function key like f15-f30 or something with .Xmodmap

Definitely going to have to try this when I get home.

Beware if you use gnome, creating a .Xmodmap file wont be necessary, and doing so could actually cause gnome to prevent you from letting you use your keyboard - I found this out when setting up a linux system for my mother to use.  If you use gnome you can use just the key mapping program under system preferences or wherever and it will take care of mapping the keycodes to whatever action you want without using a .Xmodmap file.

----------

## andyknownasabu

 *nix_newb wrote:*   

> The man page for setkeycodes mentions showkey.  showkey apparently reads dev/console...  I'm going to have to try this when I get home.  It looks like showkey would give you the hex for the event of the keypress and then setkeycodes would let you map the scancode to the keycode. 

 

After that "loadkeys" can be used to define the function of the new keys systemwide and/or if you don't want to use "xmodmap".

Therefore just set your own keymap in

```
/etc/conf.d/keymaps
```

(for example: KEYMAP="own-foo") and create the corresponding file own-foo.map.gz in a subdirectory of 

```
/usr/share/keymaps/
```

Just copy and use some other file and edit it afterwards to suit your needs.

----------

## dtor

setkeycodes does not work for USB keyboards. You will have to use event interface/X driver to make use of all your keys.

----------

## miwalter

 *dtor wrote:*   

> setkeycodes does not work for USB keyboards. You will have to use event interface/X driver to make use of all your keys.

 

That sounds good. Do you know where I may find Infos about how to configure xorg this way?

----------

## dtor

I think Gentoo's X already has all necessary patches so you should just adjust the config file like in the link below and the keys shoudl start producing events which you shoudl we able to map via xmodpap or XKB.

http://linux-universe.com/HOWTO/XFree-Local-multi-user-HOWTO/tweak_input_devs-xev1.html

----------

## miwalter

Thanks!

If I understand that right, I have to define usb-*/event* if I only have the devies /dev/input/event2 and /dev/input/event3 (I need both, checked it with evtest - the event2 delivers the normal keys and event3 the "specials").

What do you think?

edit:

I'm sorry. Just checked with https://forums.gentoo.org/viewtopic.php?t=198534 - I have to use the lines given in your link.

----------

## miwalter

If I use the event-interface I don't even get the multimedia-keys which I get by using the "standard"-interface (e.g. Volume or Mute).

Hm. I think I need to research some more... event-interface seems to be the way, but I don't think the configuration from the page is the correct one for me (I have to use two event-thingies - I guess the evdev only uses the first it finds).

----------

## dtor

It uses the one you told it to use, if you have several evdevs you probably need to define several input device sections in your config file. What does your /proc/bus/input/device show?

As far as volume and mute - evdev could emit just slightly different keycodes than thae classic keyboard interface, the most important question is whether xev shows any events when you are using evdev interface and pressing those volume/mute buttins.

----------

## mirko_3

Without going through the evdev stuff, I do this (credit goes to a member of these forums for having the patience to research and write this command):

setkeycodes e012 152 e023 160 e029 201 e01e 139 e01a 197 e026 154  e017 149 e025 205 e018 168 e031 167 e032 150 e028 200

at every boot; with that, keys that earlier didn't return any keycodes, no do (though not the keycode specified in the command, eg. e012 doesn't return 152.. if anyone can explain this, I'm eagerly listening)

----------

## dtor

 *mirko_3 wrote:*   

> Without going through the evdev stuff, I do this (credit goes to a member of these forums for having the patience to research and write this command):
> 
> setkeycodes e012 152 e023 160 e029 201 e01e 139 e01a 197 e026 154  e017 149 e025 205 e018 168 e031 167 e032 150 e028 200
> 
> 

 

AT keyboard, I presume?

 *mirko_3 wrote:*   

> 
> 
>  with that, keys that earlier didn't return any keycodes, no do (though not the keycode specified in the command, eg. e012 doesn't return 152.. if anyone can explain this, I'm eagerly listening)

 

152 is a scan code, see /drivers/char/keyboard.c::x86_keycodes for mapping between scancodes and keycodes.

----------

## miwalter

 *dtor wrote:*   

> It uses the one you told it to use, if you have several evdevs you probably need to define several input device sections in your config file. What does your /proc/bus/input/device show?
> 
> As far as volume and mute - evdev could emit just slightly different keycodes than thae classic keyboard interface, the most important question is whether xev shows any events when you are using evdev interface and pressing those volume/mute buttins.

 

```
I: Bus=0011 Vendor=0001 Product=0001 Version=ab41

N: Name="AT Translated Set 2 keyboard"

P: Phys=isa0060/serio0/input0

H: Handlers=kbd event0 

B: EV=120013 

B: KEY=4 2000000 3802078 f840d001 f2ffffdf ffefffff ffffffff fffffffe 

B: MSC=10 

B: LED=7 

I: Bus=0010 Vendor=001f Product=0001 Version=0100

N: Name="PC Speaker"

P: Phys=isa0061/input0

H: Handlers=kbd event1 

B: EV=40001 

B: SND=6 

I: Bus=0003 Vendor=045e Product=008a Version=7373

N: Name="Microsoft Microsoft Wireless Optical Desktop® 1.00"

P: Phys=usb-0000:00:1f.2-1/input0

H: Handlers=kbd event2 

B: EV=12000b 

B: KEY=10000 7 ff800000 7ff febeffdf f3cfffff ffffffff fffffffe 

B: ABS=100 0 

B: LED=1f07 

I: Bus=0003 Vendor=045e Product=008a Version=7373

N: Name="Microsoft Microsoft Wireless Optical Desktop® 1.00"

P: Phys=usb-0000:00:1f.2-1/input1

H: Handlers=kbd mouse0 event3 

B: EV=10000f 

B: KEY=1fffff ffff0000 0 1878 c800d408 1e0000 0 0 0 

B: REL=303 

B: ABS=3ff00 0 
```

I have to use event2 and event3.

Is it enough to simply write two keyboard-section in xorg.conf?

Btw. xev doesn't show anything - that's why I don't get the mm-keys working with the event*-interface.

----------

## dtor

I think it will work but you'll have to experiment. Btw, do you really have 2 keyboards (USB and PS/2) plugged in?

----------

## miwalter

I did some experimenting. But I haven't got it working yet.

e.g.

```
Section "InputDevice"

    Identifier "Keyboard1"

    Driver "kbd"

    Option "Protocol"     "evdev"

    Option "Dev Phys"     "usb-*/input0"

    Option "AutoRepeat" "500 30"

    Option "XkbRules" "xorg"

    Option "XkbModel" "pc105"

    Option "XkbLayout" "de"

EndSection

Section "InputDevice"

    Identifier "Keyboard2"

    Driver "kbd"

    Option "Protocol"     "evdev"

    Option "Dev Phys"     "usb-*/input1"

    Option "AutoRepeat" "500 30"

    Option "XkbRules" "xorg"

    Option "XkbModel" "pc105"

    Option "XkbLayout" "de"

EndSection
```

No. I don't have two keyboards. My keyboard is connected using USB - but it has a PS/2-Plug (which is, of course, not connected to the PC). Hm.

----------

## Zyne

I have the exact same setup, and I'm trying to get it to work too....  :Smile: 

strange thing is (imho) that when you do evtest /dev/input/event2, you get output from the MM keys, but not from the other keys.

If you do the evtest for /dev/input/event1, you only get output from the nomal keys, and nothing from the MM keys...

so I'm currently looking for a way to define the two keyboards in xorg  :Smile: 

here's the current layout of my xorg.conf (not working btw  :Smile:  )

```

Section "InputDevice"

    #Identifier "Keyboard1"

    Identifier  "Logitech Y-RJ20"

    Driver      "kbd"

    Option      "Protocol"      "evdev"

    Option      "Dev Name"      "Logitech USB Receiver"

    Option      "Dev Phys"      "usb-0000:00:02.1-2/input0"

    Option      "Device"        "/dev/input/event1"

    Option      "XkbModel"      "logiinkseusb"

    Option      "AutoRepeat"    "500 30"

    Option      "XkbLayout"     "be"

EndSection

Section "InputDevice

    Identifier          "Logitech Y-RJ20-bis"

    Driver              "kbd"

    Option "Vendor"     "Logitech"

    Option "Dev Name"   "Logitech USB Receiver"

    Option "Dev Phys"   "usb-0000:00:02.1-2/input1"

    Option "Protocol"   "evdev"

    Option "Device"     "/dev/input/event2"

    Option "XkbLayout"  "be"

EndSection

Section "InputDevice"

    Identifier  "Logitech MX700"

    Driver "mouse"

    Option "Vendor"     "Logitech"

    Option "Dev Name"   "Logitech USB Receiver"

    Option "Dev Phys"   "usb-0000:00:02.1-2/input1"

    Option "Protocol"   "evdev"

    Option "Device"     "/dev/input/event1"

    Option "Buttons"    "10"

    Option "ZAxisMapping" "9 10"

    Option "Resolution" "800"

EndSection

```

I also defined the 2 keyboards in my ServerLayout, but still not working...

```

Section "ServerLayout"

    Identifier  "Server Layout"

    Screen "Screen0"

    InputDevice "Logitech MX700"  "CorePointer"

    InputDevice "Logitech Y-RJ20" "CoreKeyboard"

    InputDevice "Logitech Y-RJ20-bis" "CoreKeyboard"

EndSection

```

I'll keep the search going  :Smile: 

----------

## miwalter

Zyne:

man xorg.conf says you can only have one CoreKeyboard. I'm going to try "SendCoreEvents" for the second keyboard - I will tell later if this is working.

----------

## miwalter

I tried that and many other things during the last few hours.

But I think I found some important information. The mm-keys are send over the same interface as mouse-events are. So using the same interface for both physicals things with different drivers should be a problem.

I tried setting both on Protocol "evdev", but then Xorg switches to a PS/2-Mouse (which I don't have connected - so no mouse). Tried "mousedev" too - but that crashes things somewhat.

Maybe we are thinking in the wrong direction. Maybe the mm-key-events are in reality _mouse_-events. So setting the mouse to the event-interface and using a apropriate driver should be the solution. I don't think IMPS/2 can handle these events (and even doesn't report them).

Does anyone know about a different mousedriver which might send these "not-mouse-events-over-the-mouse-interface" to userland, so they might be getting catched by e.g. xev?

----------

## firephoto

I think you are running into what I did with my logitech mx duo which is that the keys have codes higher than 255 so they aren't recognized in a usable way. As far as I know this is a kernel limitation. I tried to use evdev with my keyboard but it resulted in X not working or the mouse not working. Some of the keys are shared between keyboard and mouse event interfaces and some aren't so it was an issue.

----------

## alv

Hey. I noticed the request from the thread, and have decided that the issue is exactly as the one I see.

I will guess that the usbhid driver does not have builtin for some vendor-specific keys, and proceeds to ignore them or guess what they mean. Take a look at the thread I started, which includes the patch for the wireless mouse: https://forums.gentoo.org/viewtopic.php?t=280772. There is a link to my site.

The patch enables debug in the HID driver, which will start dumping the parsed structure of HID into dmesg. There you will see the exact reports and the codes that the keyboard uses. Those reports are crucial in order to get the keyboard to work.

On my site there are some reports for another device that I have (but have not updated since long time ago), they will give you a clue what to look for: http://lestrade.dyndns.org/homepage/compiled/commander.xhtml

(not IE friendly link as IE does not understand xhtml). Anyway...if you can produce some of those reports, I can take a look and try to figure out if your issue is caused by the vendor specific "usage ids" as HID protocol calls them.

If you wish a faster response....use my email address given on the home page of my site. And please ignore the ugliness.

----------

## miwalter

I've patched my kernel with the debugging-patch - but this lead to severe problems. When the boot-process comes to coldplugging the system puts out a great amount of debugging-infos and... hangs.

Is it just me?   :Question: 

----------

## jaccort

I may have found a workaround - Google is your friend  :Wink: .

What you need to do is:

1. Copy the code below into a file, chmod +x it and run it as root.

```

#!/bin/sh

setkeycodes e064 89

setkeycodes e03c 90

setkeycodes e005 91

setkeycodes e016 92

setkeycodes e03b 59

setkeycodes e008 116

setkeycodes e007 85

setkeycodes e03e 126

setkeycodes e03f 93

setkeycodes e040 94

setkeycodes e041 118

setkeycodes e042 120

setkeycodes e043 121

setkeycodes e023 122

setkeycodes e057 123

```

2. This should make most of the extra keys work - certainly does with my Microsoft Natural Multimedia PS/2 keyboard, YMMV.

3. Now, run xev from a shell window.  Press each key which doesn't work in turn, note the keycode you get back.

4. Create/edit a file for xmodmap, with a line for each key taking the following form:

keycode <CODE> = <SYMBOLIC MEANING>

example:

keycode 239 = XF86Documents

keycode 211 = XF86Pictures

keycode 128 = XF86Music

This is for my keyboard, your values will be different

5. Type xmodmap <FILE>, where <FILE> is the file you've just created.

6. Comment out all the codes you don't need from the script you saved in step 1.

7. Edit /etc/conf.d/local.start so the script runs every time you reboot.

8. Edit your .xsession/.xinitrc so it runs xmodmap with the config file you created in step 4 every time you start X/log in.

9. Configure KDE/Gnome/Window Manager Of Your Choice as appropriate.

Enjoy!

----------

## miwalter

Nope   :Sad: 

But thanks.

----------

## alv

Sorry about the patch. The patch does not simply enable debugging, but also does some extra things so that my Intellimouse Explorer works, and it works perfectly. I suppose that the vendor specific codes that are good for me, are causing some issues for you.

So, do the following. Remove my patch (this can be done by applying my patch in reverse). I suppose you already did that. Second: just do the part that enables debug, and none of my mouse specific things.

```

diff -urN -X dontdiff linux-2.6.10-orig/drivers/usb/input/hid-core.c linux-2.6.10/drivers/usb/input/hid-core.c

--- linux-2.6.10-orig/drivers/usb/input/hid-core.c   2004-12-24 16:34:58.000000000 -0500

+++ linux-2.6.10/drivers/usb/input/hid-core.c   2005-01-12 21:25:23.713236488 -0500

@@ -25,8 +25,8 @@

 #include <asm/byteorder.h>

 #include <linux/input.h>

 

-#undef DEBUG

-#undef DEBUG_DATA

+#define DEBUG

+#define DEBUG_DATA

 

 #include <linux/usb.h>

```

This will do nothing but enable the DEBUG in the HID. If this crashes your machine.....ummm.....send a bug report to the kernel people, as this does nothing more than add some printks.

I have mentioned in my previous post what the reports should look like.

Also I read your discussion more deeply, and noticed the whole 2-device, and how some multimedia keys appear on the device. Here is my take on the issue. The HID driver in the kernel IMO is a crappy hack, full of workarounds. I will guess that your keyboard identifies itself as a single device, but the driver has a special quirk for your system that splits the device into 2 virtual devices. There is a generic way to do that in the kernel, but it does not work for your system. (Basically, the device is split at the point where multiple reports exist, and it just happens that multimedia keys appear after the mouse report, and therefore tossed in with the mouse).

Anyway......I can't wait to get my hands on the description of the reports. Hopefully, I can work blindly with them, without actually having the device, but based on the information (especially considering the probable quirk -- and that I will need to work around the idiotic quirk system), it will be a bit of a journey that will involve quite a few hacks, and system hangs.

Anyway...feel free to contact me over email. If you wish to work on this more realtime, I can send my ICQ number...(although I do not wish to share it publicly on a forum).

----------

## alv

jaccort

Does your keyboard have a native USB connector or a native PS/2 connector. If it is a PS/2 connector, I believe your keyboard does not even speak HID (even though it connects to usb), and therefore goes through a different driver. But I may be wrong in that regard.

If you wish to help me out...it would be nice if you can turn on the debugging, and send out the HID information print out.

Unfortunately I am not sure how the setkeycode works....but I there is a IOCTL on the driver that can remap keys in the driver (I think this enables keys that actually identify themselves as keys, and not as vendor specific features. This happens on the PS/2 keyboards -- where all keys are identied as keys, but may not be the case on the newer usb-only devices).

----------

## miwalter

Tadaaa!! I finally come back with some more informationen using this "slowing-everything-down-but-giving-usefull-info"-patch:

```

Fav1

hid-debug: input ff00.ff05 = 1

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 00 00 00

hid-debug: input ff00.ff05 = 0

Fav2

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 40 00 00

hid-debug: input ff00.ff05 = 2

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 00 00 00

hid-debug: input ff00.ff05 = 0

Fav3

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 80 00 00

hid-debug: input ff00.ff05 = 4

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 00 00 00

hid-debug: input ff00.ff05 = 0

Fav4

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 00 01 00

hid-debug: input ff00.ff05 = 8

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 00 00 00

hid-debug: input ff00.ff05 = 0

Fav5

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 00 02 00

hid-debug: input ff00.ff05 = 16

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 00 00 00

hid-debug: input ff00.ff05 = 0

Favoritenliste (unsicher)

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 10 00 00

hid-debug: input Hotkey.0182 = 1

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 00 00 00

hid-debug: input Hotkey.0182 = 0

Eigene Dateien / My Files:

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 02 00 00

hid-debug: input Hotkey.01a7 = 1

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

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 00 00 00

hid-debug: input Hotkey.01a7 = 0

Eigene Bilder / My Pictures:

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 04 00 00

hid-debug: input Hotkey.01b6 = 1

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

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 00 00 00

hid-debug: input Hotkey.01b6 = 0

Eigene Musik (unsicher) / My Music (not sure if these are the right infos):

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 08 00 00

hid-debug: input Hotkey.01b7 = 1

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 00 00 00

hid-debug: input Hotkey.01b7 = 0

Tiltwheel right (keyboard-wheel)

drivers/usb/input/hid-core.c: report (size 4) (numbered)

drivers/usb/input/hid-core.c: report 6 (size 3) =  00 01 00

hid-debug: input Hotkey.0238 = 1

drivers/usb/input/hid-core.c: report (size 8) (unnumbered)

drivers/usb/input/hid-core.c: report 0 (size 8) =  00 00 52 00 00 00 00 00

hid-debug: input Keyboard.0052 = 1

drivers/usb/input/hid-core.c: report (size 2) (numbered)

drivers/usb/input/hid-core.c: report 7 (size 1) =  01

Tiltwheel left (keyboard wheel)

drivers/usb/input/hid-core.c: report (size 4) (numbered)

drivers/usb/input/hid-core.c: report 6 (size 3) =  00 ff 00

hid-debug: input Hotkey.0238 = -1

drivers/usb/input/hid-core.c: report (size 4) (numbered)

drivers/usb/input/hid-core.c: report 6 (size 3) =  00 ff 00

hid-debug: input Hotkey.0238 = -1

Tiltwheel down

drivers/usb/input/hid-core.c: report (size 4) (numbered)

drivers/usb/input/hid-core.c: report 6 (size 3) =  ff 00 00

hid-debug: input GenericDesktop.0038 = -1

drivers/usb/input/hid-core.c: report (size 4) (numbered)

drivers/usb/input/hid-core.c: report 6 (size 3) =  ff 00 00

hid-debug: input GenericDesktop.0038 = -1

drivers/usb/input/hid-core.c: report (size 4) (numbered)

drivers/usb/input/hid-core.c: report 6 (size 3) =  fd 00 00

hid-debug: input GenericDesktop.0038 = -3

drivers/usb/input/hid-core.c: report (size 4) (numbered)

drivers/usb/input/hid-core.c: report 6 (size 3) =  fe 00 00

hid-debug: input GenericDesktop.0038 = -2

drivers/usb/input/hid-core.c: report (size 4) (numbered)

drivers/usb/input/hid-core.c: report 6 (size 3) =  fc 00 00

hid-debug: input GenericDesktop.0038 = -4

drivers/usb/input/hid-core.c: report (size 4) (numbered)

drivers/usb/input/hid-core.c: report 6 (size 3) =  fc 00 00

hid-debug: input GenericDesktop.0038 = -4

drivers/usb/input/hid-core.c: report (size 4) (numbered)

drivers/usb/input/hid-core.c: report 6 (size 3) =  fd 00 00

hid-debug: input GenericDesktop.0038 = -3

Tiltwheel up

drivers/usb/input/hid-core.c: report (size 4) (numbered)

drivers/usb/input/hid-core.c: report 6 (size 3) =  01 00 00

hid-debug: input GenericDesktop.0038 = 1

drivers/usb/input/hid-core.c: report (size 4) (numbered)

drivers/usb/input/hid-core.c: report 6 (size 3) =  02 00 00

hid-debug: input GenericDesktop.0038 = 2

Media:

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  80 00 00 00 00 00

hid-debug: input Hotkey.0183 = 1

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 00 00 00

hid-debug: input Hotkey.0183 = 0

Abmelden (Logoff):

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 02 00 00 00

hid-debug: input Hotkey.019c = 1

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

drivers/usb/input/hid-core.c: report (size 7) (numbered)

drivers/usb/input/hid-core.c: report 4 (size 6) =  00 00 00 00 00 00

hid-debug: input Hotkey.019c = 0

Standby:

drivers/usb/input/hid-core.c: report (size 2) (numbered)

drivers/usb/input/hid-core.c: report 5 (size 1) =  02

hid-debug: input GenericDesktop.0082 = 1

drivers/usb/input/hid-core.c: report (size 2) (numbered)

drivers/usb/input/hid-core.c: report 7 (size 1) =  01

drivers/usb/input/hid-core.c: report (size 2) (numbered)

drivers/usb/input/hid-core.c: report 5 (size 1) =  00

hid-debug: input GenericDesktop.0082 = 0

```

Is this useful for you? I recognize a certain pattern here, but I don't know what to do with this information.

Thanks,

Mirko

----------

## alv

Excellent. Most of it is more than needed -- for example the reports you see are practically raw usb packets. The usage codes are showing up though....

I will highlight the interesting parts:

```

Fav1

hid-debug: input ff00.ff05 = 1

Fav2

hid-debug: input ff00.ff05 = 2

Fav3

hid-debug: input ff00.ff05 = 4

Fav4

hid-debug: input ff00.ff05 = 8

Fav5

hid-debug: input ff00.ff05 = 16

Favoritenliste (unsicher)

hid-debug: input Hotkey.0182 = 1

Eigene Dateien / My Files:

hid-debug: input Hotkey.01a7 = 1

Eigene Bilder / My Pictures:

hid-debug: input Hotkey.01b6 = 1

Eigene Musik (unsicher) / My Music (not sure if these are the right infos):

hid-debug: input Hotkey.01b7 = 1

Tiltwheel right (keyboard-wheel)

hid-debug: input Hotkey.0238 = 1

hid-debug: input Keyboard.0052 = 1

WHAT???? Keyboard.52 fired as well. This is strange....

Tiltwheel left (keyboard wheel)

hid-debug: input Hotkey.0238 = -1

hid-debug: input Hotkey.0238 = -1

Tiltwheel down

hid-debug: input GenericDesktop.0038 = -1

hid-debug: input GenericDesktop.0038 = -1

hid-debug: input GenericDesktop.0038 = -3

hid-debug: input GenericDesktop.0038 = -2

hid-debug: input GenericDesktop.0038 = -4

hid-debug: input GenericDesktop.0038 = -4

hid-debug: input GenericDesktop.0038 = -3

Tiltwheel up

hid-debug: input GenericDesktop.0038 = 1

hid-debug: input GenericDesktop.0038 = 2

Media:

hid-debug: input Hotkey.0183 = 1

Abmelden (Logoff):

hid-debug: input Hotkey.019c = 1

Standby:

hid-debug: input GenericDesktop.0082 = 1

```

From this info, I can see immediately where the problems are.

First of all the tiltwheel is on the code Hotkey.238, the same place as the tiltwheel on my mouse is. That modification is in my patch. The tilting probably does not work.

The wheel itself is on GenericDesktop.38. I believe this is the right location for it....so if you are not getting the events, that means for some reason the wheel does not end up in the mouse subsystem, but the events are sent.

The Hotkeys are the right place for those multimedia keys, and there is an area which is defined for them. The tiltwheel, being not a key is an exception, but is defined in the same area.

That leaves the favorites keys, which I bet are misreported as a joystick axis, while in fact they are an array of codes, but I am not sure. In either case they will not be recognized properly, as the table that used (the left side of ff00.ff05) indicates microsoft specific items. Unless they get lucky in the catchall code....but I digress. Those may be the hardest ones to make into keys, but it should be doable.

If you can post which of the keys work, and which ones do not, that would be also useful.

Also, if you rmmod usbhid, then modprobe usbhid, in dmesg you will get a summary of all the declarations of all codes. It will look something like this: 

```

  INPUT(1)[INPUT]

    Field(0)

      Physical(GenericDesktop.0001)

      Usage(3)

        GenericDesktop.0030

        GenericDesktop.0031

        GenericDesktop.0035

      Logical Minimum(-512)

      Logical Maximum(511)

      Physical Minimum(0)

      Physical Maximum(1023)

      Report Size(10)

      Report Count(3)

      Report Offset(0)

      Flags( Variable Absolute )

    Field(1)

      Usage(2)

        Undefined.GenericDesktop

        Undefined.GenericDesktop

      Logical Minimum(-512)

      Logical Maximum(511)

      Physical Minimum(0)

      Physical Maximum(1023)

      Report Size(1)

      Report Count(2)

      Report Offset(30)

      Flags( Constant Array Absolute )

    Field(2)

      Usage(12)

        Button.0001

        Button.0002

        Button.0003

        Button.0004

        Button.0005

        Button.0006

        Button.0007

        Button.0008

        Button.0009

        Button.000a

        Button.000b

        Button.000c

      Logical Minimum(0)

      Logical Maximum(1)

      Physical Minimum(0)

      Physical Maximum(1)

      Report Size(1)

      Report Count(12)

      Report Offset(32)

      Flags( Variable Absolute )

    Field(3)

      Usage(3)

        Button.000d

        Button.000e

        Button.000f

      Logical Minimum(1)

      Logical Maximum(3)

      Physical Minimum(0)

      Physical Maximum(1)

      Report Size(2)

      Report Count(1)

      Report Offset(44)

      Flags( Array Absolute NoPrefferedState )

    Field(4)

      Usage(2)

        Undefined.GenericDesktop

        Undefined.GenericDesktop

      Logical Minimum(1)

      Logical Maximum(3)

      Physical Minimum(0)

      Physical Maximum(1)

      Report Size(1)

      Report Count(2)

      Report Offset(46)

      Flags( Constant Array Absolute )

  FEATURE(1)[FEATURE]

    Field(0)

      Logical(LED.003c)

      Usage(6)

        LED.0041

        LED.003d

        LED.0040

        LED.0040

        LED.0040

        LED.0040

      Logical Minimum(0)

      Logical Maximum(2)

      Physical Minimum(0)

      Physical Maximum(1)

      Report Size(2)

      Report Count(6)

      Report Offset(0)

      Flags( Array Absolute NoPrefferedState NullState )

    Field(1)

      Logical(LED.003c)

      Usage(3)

        LED.0041

        LED.003d

        LED.0040

      Logical Minimum(0)

      Logical Maximum(2)

      Physical Minimum(0)

      Physical Maximum(1)

      Report Size(2)

      Report Count(1)

      Report Offset(12)

      Flags( Array Absolute NoPrefferedState NullState )

    Field(2)

      Usage(2)

        Undefined.GenericDesktop

        Undefined.GenericDesktop

      Logical Minimum(0)

      Logical Maximum(2)

      Physical Minimum(0)

      Physical Maximum(1)

      Report Size(1)

      Report Count(2)

      Report Offset(14)

      Flags( Constant Array Absolute )

  FEATURE(2)[FEATURE]

    Field(0)

      Usage(1)

        LED.0045

      Logical Minimum(1)

      Logical Maximum(255)

      Physical Minimum(1)

      Physical Maximum(255)

      Unit Exponent(2)

      Unit(SI Linear : Seconds)

      Report Size(8)

      Report Count(1)

      Report Offset(0)

      Flags( Array Absolute NoPrefferedState NullState )

    Field(1)

      Usage(1)

        LED.0046

      Logical Minimum(1)

      Logical Maximum(255)

      Physical Minimum(1)

      Physical Maximum(255)

      Unit Exponent(2)

      Unit(SI Linear : Seconds)

      Report Size(8)

      Report Count(1)

      Report Offset(8)

      Flags( Array Absolute NoPrefferedState NullState )

```

This is extremely useful as well. You have collected good info on the keyboard...but this will give you some hidden information, and can also help with the code writing, especially if you are writing being blind to the device. It may be useful to do this from the remote computer, so that dmesg output does not get filled with debug information.

But if it is too much trouble...it is not really needed, as the most important part -- the usage code -- has already been found.

Anyway...I will put in some time, and get a non-debug patch out. Hopefully one that will not hang your system. Give me till tomorrow....

----------

## alv

In case anyone is interested here are the current mappings for hotkeys:

```

                                case 0x000: usage->code = 0; break;

                                case 0x034: usage->code = KEY_SLEEP;            break;

                                case 0x036: usage->code = BTN_MISC;             break;

                                case 0x08a: usage->code = KEY_WWW;              break;

                                case 0x095: usage->code = KEY_HELP;             break;

                                case 0x0b0: usage->code = KEY_PLAY;             break;

                                case 0x0b1: usage->code = KEY_PAUSE;            break;

                                case 0x0b2: usage->code = KEY_RECORD;           break;

                                case 0x0b3: usage->code = KEY_FASTFORWARD;      break;

                                case 0x0b4: usage->code = KEY_REWIND;           break;

                                case 0x0b5: usage->code = KEY_NEXTSONG;         break;

                                case 0x0b6: usage->code = KEY_PREVIOUSSONG;     break;

                                case 0x0b7: usage->code = KEY_STOPCD;           break;

                                case 0x0b8: usage->code = KEY_EJECTCD;          break;

                                case 0x0cd: usage->code = KEY_PLAYPAUSE;        break;

                                case 0x0e0: is_abs = 1;

                                            usage->code = ABS_VOLUME;

                                            break;

                                case 0x0e2: usage->code = KEY_MUTE;             break;

                                case 0x0e5: usage->code = KEY_BASSBOOST;        break;

                                case 0x0e9: usage->code = KEY_VOLUMEUP;         break;

                                case 0x0ea: usage->code = KEY_VOLUMEDOWN;       break;

                                case 0x183: usage->code = KEY_CONFIG;           break;

                                case 0x18a: usage->code = KEY_MAIL;             break;

                                case 0x192: usage->code = KEY_CALC;             break;

                                case 0x194: usage->code = KEY_FILE;             break;

                                case 0x21a: usage->code = KEY_UNDO;             break;

                                case 0x21b: usage->code = KEY_COPY;             break;

                                case 0x21c: usage->code = KEY_CUT;              break;

                                case 0x21d: usage->code = KEY_PASTE;            break;

                                case 0x221: usage->code = KEY_FIND;             break;

                                case 0x223: usage->code = KEY_HOMEPAGE;         break;

                                case 0x224: usage->code = KEY_BACK;             break;

                                case 0x225: usage->code = KEY_FORWARD;          break;

                                case 0x226: usage->code = KEY_STOP;             break;

                                case 0x227: usage->code = KEY_REFRESH;          break;

                                case 0x22a: usage->code = KEY_BOOKMARKS;        break;

                                default:    usage->code = KEY_UNKNOWN;          break;

```

According to this, all the following keys will be assigned to key_unknown..and will send KEY_UNKNOWN+i, where i is an incrementing variable...I think all of these can be fixed using setkeycode, but I am not sure.

In fact all the keys that you mentioned in the report are not present.

By any chance -- did you just press only those keys which you can not report? Are there other keys that do work?

Do not hurry in replying -- this is just more of a curiosity for me. Thanks.

----------

## alv

Post superceeded by the next post.Last edited by alv on Wed Jan 19, 2005 6:59 pm; edited 1 time in total

----------

## alv

Ok. So I should declare myself legally blind.

I missed a couple of keys: First the logoff, which has been added in the new revision. The second is the media key, which according to the source code (if you still trust my eyesight), already maps to KEY_CONFIG, which is keycode 171 (dec).

Anyway, here is the new patch for the hotkeys:

```

diff -urN -X dontdiff linux-2.6.10-orig/drivers/usb/input/hid-input.c linux-2.6.10-keyb/drivers/usb/input/hid-input.c

--- linux-2.6.10-orig/drivers/usb/input/hid-input.c     2004-12-24 16:34:32.000000000 -0500

+++ linux-2.6.10-keyb/drivers/usb/input/hid-input.c     2005-01-19 13:42:03.318963392 -0500

@@ -252,10 +252,15 @@

                                case 0x0e9: usage->code = KEY_VOLUMEUP;         break;

                                case 0x0ea: usage->code = KEY_VOLUMEDOWN;       break;

 

-                               case 0x183: usage->code = KEY_CONFIG;           break;

-                               case 0x18a: usage->code = KEY_MAIL;             break;

-                               case 0x192: usage->code = KEY_CALC;             break;

-                               case 0x194: usage->code = KEY_FILE;             break;

+                               case 0x182: usage->code = KEY_FAVORITESLIST;    break;

+                               case 0x183: usage->code = KEY_CONFIG;           break;

+                               case 0x18a: usage->code = KEY_MAIL;             break;

+                               case 0x192: usage->code = KEY_CALC;             break;

+                               case 0x194: usage->code = KEY_FILE;             break;

+                               case 0x19c: usage->code = KEY_LOGOFF;           break;

+                               case 0x1a7: usage->code = KEY_MYFILES;          break;

+                               case 0x1b6: usage->code = KEY_MYPICTURES;       break;

+                               case 0x1b7: usage->code = KEY_MYMUSIC;          break;

                                case 0x21a: usage->code = KEY_UNDO;             break;

                                case 0x21b: usage->code = KEY_COPY;             break;

                                case 0x21c: usage->code = KEY_CUT;              break;

diff -urN -X dontdiff linux-2.6.10-orig/include/linux/input.h linux-2.6.10-keyb/include/linux/input.h

--- linux-2.6.10-orig/include/linux/input.h     2004-12-24 16:34:32.000000000 -0500

+++ linux-2.6.10-keyb/include/linux/input.h     2005-01-19 13:41:28.025328840 -0500

@@ -328,6 +328,12 @@

 #define KEY_BRIGHTNESSUP       225

 #define KEY_MEDIA              226

 

+#define KEY_LOGOFF              235

+#define KEY_FAVORITESLIST       236

+#define KEY_MYFILES             237

+#define KEY_MYPICTURES          238

+#define KEY_MYMUSIC             239

+

 #define KEY_UNKNOWN            240

 

 #define BTN_MISC               0x100

```

This one should handle all the buttons, except favorites. Tiltwheel will not work yet...

If you applied the patch described in the previous post, you will need to remove it first.

EDIT: OK -- so I am also forgetful. Your Suspend/standby key is already mapped to KEY_SLEEP, so it should have worked before.

----------

