ivan stojic
life is a low fidelity experience

Mirrorboard - type with one hand, use the other for something else :-)

December 29th, 2008, 10:26.

For the longest time, I’ve been in love with this amazing keyboard. What it does, is that it shifts the characters on the left/right halves of the keyboard when you press and hold the space bar. Since I’m a thrifty bastard I cannot justify to myself the need to spend about 150 dollars on something that my keyboard can do quite well on it’s own, so I set out to replicate the behaviour.

Therefore, I’ve explored several options to get this type of functionality in Linux:

  • Custom XKB keymaps: couldn’t work because the system requires modifiers with a timeout as well as modifiers that emit symbols when pressed in burst (fast down-up) mode.
  • The XKCD mirrorboard: a variation on the 508 theme which uses the caps lock key to shift halves. However I’m an emacs freak so I have my capslock remapped to CTRL already, and I also use a custom keyboard layout to get at Croatian extended characters.
  • The MXK input remapping utility: a nifty evdev/uinput event remapper. Now we are getting somewhere. This little monster will catch events before they are processed by your X server and remap them at this lower level. However, after much fiddling with the source I couldn’t get it to work for any of it’s examples. Nothing. Nada. Zilch.

At that time it became pretty much obvious to me that if I want to have something done properly, I will have to do it myself. Enter mirrorboard.c.

It’s my own creation, written in pure C, and currently standing at about 400 lines of code (compared to over 24000 lines for MXK). Given a single command line parameter (the name of the evdev input device that represents your keyboard), it will make an exclusive grab of it, and then pass the events back into the kernel via uinput. It’s currently in a very ugly state however:

  • You need to determine the name of your evdev input device by some external means (eg by looking into /sys/class/input/inputX/name).
  • The path to the uinput device is hardcoded for the Debian filesystem standard.
  • Some keys are not sensibly remapped when “inside the mirror.”

However, I believe this to be a quite nice proof of concept piece of code, and I also plan to keep working on it to refine it, primarily because I like the idea of being able to type off a few sentences here and there with one hand only.

If there is anyone who is interested in compiling this and/or getting it to work on their systems and is having problems, feel free to contact me via the comments!

Technorati Tags: , , , , , , , , , ,

Leave a Reply