summaryrefslogtreecommitdiff
path: root/src/SW/xf86-input-evdev/document.en.rest.txt
blob: 04dafaaf94de75f2fe0726e9c2632fde45d8e278 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
=========================================
 Code-remapping for ``xf86-input-evdev``
=========================================
:CreationDate: 2009-09-15 12:49:41
:Id: SW/xf86-input-evdev
:tags: - software
       - keyboard
 
The standard ``xf86-input-evdev`` driver that comes with `xorg` only
uses keycodes between 8 and 255, dropping all others. This is fine
most of the time (who ever saw a keyboard with more than 247 keys on
it?), but it causes problems when the keycodes generated are not
compact.
 
For example, the Apple Aluminum Keyboard (USB ID ``05ac:0221``)
produces at least one code above 255: the "fn" key is 464. People have
found other cases, and have `reported them as a bug
<http://bugs.freedesktop.org/show_bug.cgi?id=11227>`_.
 
Since I needed my keyboard to work as I want it, I did the only
sensible thing: I `cloned the repository
<http://www.thenautilus.net/cgit/xf86-input-evdev/>`_ and patched the
code.
 
My patch adds a configuration option, called ``event_key_remap``. Its
value must be a (whitespace-separated) list of "assignments" of the
format ``$evdev_code = $x11_code``; the ``$evdev_code`` can be
obtained with ``showkey -k``, the ``$x11_code`` can be found in
``/usr/share/X11/xkb/keycodes/evdev`` (or wherever your distribution
put it).
 
The implementation is rather simple, creating a look-up table from the
configuration; the table is not implemented as a simple array, since
that would have meant taking 64KiB for each device (`evdev` uses 16
bits for a key event). Instead, I allocate "pages" of 256 bytes, and
only the pages needed. This way, devices with no remapping use only
one more pointer in their structures, and devices with very few codes
to remap use only 256 bytes.
 
Of course, the configuration can be set in the ``xorg.conf``
file. Mine contains::
 
  Section "InputClass"
   Identifier "keyboard-generic"
   Driver "evdev"
   Option "XkbOptions" "compose:ralt,altwin:meta_win,terminate:ctrl_alt_bksp"
  
   MatchIsKeyboard "on"
  EndSection
  
  Section "InputClass"
   Identifier "keyboard-apple-alu"
   Driver "evdev"
   Option "XkbLayout"  "dakkar"
   Option "XkbModel"   "applealu_iso"
   Option "XkbVariant" "dvorak-apple-al"
   Option "event_key_remap" "464=118 120=210 204=211"
  
   MatchIsKeyboard "on"
   MatchProduct    "Apple, Inc Apple Keyboard"
  EndSection
 
(Details about my keyboard layout are `elsewhere <../my-layout/>`_.