You are not logged in.

#1 2014-11-20 10:33:43

Triver
Member
Registered: 2009-03-29
Posts: 71

Having trouble understanding scancodes (and their udev mapping)

First off, I know that scancodes are basically the raw byte interpretation of keyboard presses which I can display for example with showkey --scancodes.

However why does showkey display at least two bytes for each key that I press (is it for press/release?) and for some keys even 4 and more? And how can I dump that down to a single byte which I can specify in a hwdb database for udev?

For example, this is the output for Fn+Brightness Up/Down:

showkey --scancodes
kb mode was UNICODE
[ if you are trying this under X, it might not work
since the X server is also reading /dev/console ]

press any key (program terminates 10s after last keypress)...
0x9c 
0x1c 0x9c    # pressed Enter
0xe0 0x54 0xe0 0xd4   # pressed Fn+Brightness Up
0xe0 0x4c 0xe0 0xcc   # pressed Fn+Brightness Down

The according mappings for brightness up/down in the udev database for my keyboard model are:

KEYBOARD_KEY_88=!brightnessup                          # Fn+Up
KEYBOARD_KEY_89=!brightnessdown                        # Fn+Down

So assuming 0x54/0xd4 and 0x4c/0xcc are my "relevant" bytes, how do they lead to the scancodes 0x88 and 0x89 in the hwdb?

Offline

#2 2014-11-22 05:05:35

grubenm
Member
Registered: 2014-02-25
Posts: 35

Re: Having trouble understanding scancodes (and their udev mapping)

The scancodes you've provided are for pressing and releasing different keys.

As for how scancodes and keycodes play with each other, ArchWiki

Offline

#3 2014-11-23 15:40:15

Triver
Member
Registered: 2009-03-29
Posts: 71

Re: Having trouble understanding scancodes (and their udev mapping)

Yes thats what I assumed, however what I dont understand is which one do I need in case I want to overwrite or add a new key in a (custom) udev hwdb file.

The wiki doesn't mention anything specific about the difference between key press and key release and in the example I provided I was wondering how these scancodes for press/release of a key combination from showkey -s (like 0xe0 0x54 0xe0 0xd4) led to the specified value (0x88) in the udev hwdb file, since the wiki suggest that one should use showkey -s[ to figure out the scancode of a key.

Last edited by Triver (2014-11-23 16:13:07)

Offline

#4 2021-04-29 11:27:50

yahu
Member
Registered: 2021-04-29
Posts: 1

Re: Having trouble understanding scancodes (and their udev mapping)

I also have the same question. Anyone could be able to answer this?

Offline

Board footer

Powered by FluxBB