martin-ueding/think-rotate — pull request #9 by jturner314 (2013-10-06 07:11:23+00:00)
Title: Move keycode mappings to udev hwdb config file

This removes the need for the `think-keycodes` system startup script,
which makes the mappings work with other init systems by default, such
as systemd. The `90-X220T-keyboard.hwdb` file added in this commit is
modeled after the Lenovo X200 Tablet mappings that are part of upstream
udev.

Only the bindings necessary for the X220T are added in this commit. The
X200T config is already setup correctly upstream in udev, but if you
use an even older Thinkpad tablet, we may need to add support for it.

Note the following about the two keycode mappings:

- The screen rotation bezel key is still mapped to keycode 120
("scale") instead of the X200T's default of keycode 153 ("direction")
because keycode 120 is already mapped to an appropriate keysym in X.
Keycode 153 is not, so the user would have to use a utility such as
xmodmap to map the keycode to a keysym for use in X.

- The circular arrow bezel key is now mapped to keycode 154
("cyclewindows") to match the X200T. Before, it was mapped to nothing.

### Additional notes
- I wrote the pattern for matching the X220T keyboard alias (`keyboard:dmi:bvn*:bvr*:bd*:svnLENOVO*:pn*:pvrThinkPadX220Tablet*`) from the output of the following:

```
$ find /sys -name modalias -print0 | xargs -0 cat | grep dmi
```

- You can find the default X200T mappings mentioned in the commit message in `/usr/lib/udev/hwdb.d/60-keyboard.hwdb`.
- The keycode names (e.g. "scale" and "cyclewindows") are defined in `/usr/lib/include/linux/input.h`.
- In case we need to add mappings for older tablets, the scancodes for various models can be found at http://www.thinkwiki.org/wiki/Tablet_Hardware_Buttons.