Welcome!

My name is Ivan Stojic. I'm a CEO and a programmer. This is my personal blog.

For commercial software, check out my company - Algis.

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

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.

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 or e-mail!

Edit: this project is now hosted on GitHub.

[tags]matias, half keyboard, halfkeyboard, 508 keyboard, 508, accessibility, input, linux, evdev, uinput, remap[/tags]

2 Responses to “Mirrorboard – type with one hand, use the other for something else :-)”

  1. Seth says:

    This looks really excellent, I’m excited to try it out!

    Can you give an example of what a final command might look like? I’m kinda fuzzy on how uinput/evdev work. (I am using the evdev driver for my keyboard in xorg.conf.)

    This looks like a human-readable name which I’m guessing isn’t the parameter the program is expecting:

    $ cat /sys/class/input/input12/name
    Apple, Inc Apple Keyboard

    So I tried this which appears to work, but no key input appears or affects the computer other than the following debug output (I had to ctrl-c the program via another keyboard to exit):

    $ sudo ./mirrorboard /dev/input/event12
    Okay… mirrorboard activating on /dev/input/event12 in 1 second. Release all keys!
    /dev/input/event12: Apple, Inc Apple Keyboard
    Unable to create UINPUT device.Debug: rewrite requested, but no rewrite for this event. Passing as-is!
    Debug: rewrite requested, but no rewrite for this event. Passing as-is!

    Am I way off-base?

  2. Ivan Stojic says:

    Hm… It doesn’t look like you are off-base for what you are trying to do. But what is strange is that the keyboard which you are targeting does not seem to be producing the type of events that the code is expecting.

    I have a somewhat similar situation with an IBM keyboard with a touchpad+trackpoint combo. It is represented by several nodes in evdev, and targetting the wrong one usually causes the situation you described.

    Can you check in /sys/class/input if there’s anything else that might resemble your keyboard?

Leave a Reply