3

I have a new mechanical keyboard and I want to use some custom key build-in (C1, C2, C3, C4, C5).

The problem I encounter is that those keys are not detected in Xorg when I run xev.

I am able to see them when I run :

$ sudo showkey --keycodes keycode 264 press keycode 264 release caught signal 2, cleaning up... 

When I try to map the given keycode with xmodmap, for example, it does not work. Nothing happen when I press this key.

xmodmap -e 'keycode 264=a' 

I suspect it might be because my keyboard is spitted in two virtual code keyboard (not sure why?)

$ xinput list ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ USB OPTICAL MOUSE id=8 [slave pointer (2)] ⎜ ↳ Genius USB Optical Mouse id=9 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ Power Button id=6 [slave keyboard (3)] ↳ Power Button id=7 [slave keyboard (3)] ↳ Mad Catz Mad Catz S.T.R.I.K.E.TE Mechanical Gaming Keyboard id=10 [slave keyboard (3)] ↳ Mad Catz Mad Catz S.T.R.I.K.E.TE Mechanical Gaming Keyboard id=11 [slave keyboard (3)] 

When I run sudo evtest /dev/input/event2 "normal" key are detected but not those custom key.

And when I run sudo evtest /dev/input/event3 "normal" key are not detected anymore but the custom one are, and output the same keycodes previously found using the showkey command.


I also tried to run xev from a clean X session but the result is the same...

Are there any other tests I can run, or other suggestions?

1 Answer 1

1

(1) X keycodes and kernel keycodes are not the same, you have to add 8 to the latter to get the former. Try it with xev, showkey and a normal letter, say a.

(2) If I remember correctly, keycodes greater than 256 are not supported under X.

So you need a custom kernel keyboard or HID mapping that maps your keycode 264 and the rest to other unused keycodes that are in the admissable range.

Edit

You can do this globally with getkeycodes resp. setkeycodes, or per device with the udev hw database, or per device using your own program with EVIOCGKEYCODE_V2 and EVIOCSKEYCODE_V2 ioctl's.

1
  • Thanks for your answer. I was aware of (1), for me I add to add 9 but this still does not work with custom key. Any direction on how to custom keyboard or HID mapping ? Thanks again. Commented Sep 15, 2017 at 8:15

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.