/altalt

Primary LanguageC

Linux keycode remapper based on number of times alt key pressed

Altalt can be used to generate keycodes on keyboards with missing keys
based on the number of alt key presses. For example, Alt + Alt followed
by j produces the pipe character | as traditionally done on some PDAs
and phones.

Altalt attempts to keep the keycode mapping mostly generic where possible
trying to use the standard keys. Altalt only changes keycodes, and is
intended to be used together with other tools for user specific keyboard
mapping tools such as xmodmap.

The basic key mapping is the following:

Alt + Alt + 1 = Escape
Alt + Alt + 9 = [
Alt + Alt + 0 = ]
Alt + Alt + e = Euro
Alt + Alt + Backspace = Del
Alt + Alt + j = |
Alt + Alt + v = Shift + Insert
Alt + Alt + , = ;
Alt + Alt + . = :
Alt + Alt + / = \
Alt + Alt + Up = Page Up
Alt + Alt + Down = Page Down
Alt + Alt + Left = Home
Alt + Alt + Right = End

Alt + Alt + Alt + 1 = F1
...
Alt + Alt + Alt + 0 = F10
Alt + Alt + Alt + ' = ~

Additionally:
Shift + Alt + Alt + 9 = {
Shift + Alt + Alt + 0 = }

To use altalt, just start it from a start-up script on init with the sysfs
path to the selected keyboard as the argument. Or just start it manually to
try it:

$ tree /dev/input/by-path/
...
# altalt /dev/input/by-path/platform-4a31c000.keypad-event

N900 users probably want to pass KEY_LEFTCTRL as the modifier key to avoid
conflicts with Maemo keys. This can be done with --keycode option:

# altalt --keycode=29 /dev/input/by-path/...

To configure altalt to start automatically, see the scripts directory.
Addtionally /etc/conf.d/altalt file must be configured with:

ALTALT_OPTS='--keycode=56'
ALTALT_DEV="/dev/input/by-path/platform-4a31c000.keypad-event"

Where N900 users should use --keycode=29 and the device path to the keyboard.

Note that altalt relies on Linux uinput kernel module, and needs write access
to /dev/uinput. Multiple instances of altalt can be started to handle several
keyboards, and it can be used via udev for hot pluggable keyboards.

For remapping scancodes to keycodes, other tools need to be used. For example,
to remap droid4 OK key to KEY_LEFTMETA, create /etc/udev/hwdb.d/50-droid4.hwdb
with the following lines:

evdev:input:b0019v0001p0001e0001-*
 KEYBOARD_KEY_3b=leftmeta

Then update the hwdb with udevadm hwdb --update, reload udev or reboot system.
And then you might want to configure xmodmap for locale specific keys.