Saturday, October 08, 2005

Zaurus pdaXrom IR Keyboard Drivers (part 3)

(continued from part 2)

So if I want to avoid juggling for different key maps, its back to having kbdd convert the IR keyboard scancodes into the system scancodes. That does have the additional advantage that I'll be able to use the IR keyboard and built-in keyboard at the same time because I haven't changed the keymaps that the built-in keyboard is relying on. But the existing kbdd scancode tables are no good because they convert to a custom iPaq keymap that doesn't even come close to what the Zaurus built-in keyboard uses.

Modifying the conversion tables seems simple enough at first. For the most part each key on the IR keyboard has a matching key on the Zaurus. When you start to look at combinational keys (eg. shift + something) however, things get more complicated. If I convert shift + 2 on the IR keyboard to shift + 2 on the Zarus keyboard, I'll get a double quote. But what I want is an @ because that's what's marked on the 2 key on my IR keyboard. Why can't anything ever be simple!

Digging through the Zaurus keymaps burried in Sharp's Linux kernel source reveals that nearly all of the "symbols" on the Zaurus that you get using shift plus another key or FN plus another key actually have their own scancodes. So the solution is to hide the IR keyboard's shift key from the Zaurus. I modified kbdd to keep track of the IR keyboard's shift key internally and use that information in the scancode conversion. If the IR keyboard shift plus key combination results in a symbol that can be sent to the Zaurus with a single scancode, I send just that code and the Zaurus never sees the shift. In the cases where I really do want the Zaurus to see the shift(eg. shifted letter keys), I send a shift down, key down, key up,
shift up sequence.

Almost there! There are a couple of special cases where shift plus key needs to turn into FN plus key (such as {}) but those are easy enough to special case in the driver. My initial testing in a console login revealed that I had a few lookups wrong, but with those corrected I can now get every key on the keyboard to generate the right character on the Zaurus. For the real moment of truth, I do a startx, open Abiword and start typing ...

Success! All the character keys on the IR keyboard are doing the right thing in both the console and X with no juggling of kernel or X keymaps. Caps Lock is a little broken and will need some logic tweaks in the driver, but clearly this solution is a winner. Performance is excellent (CPU load sits at zero when I'm not typing) and auto repeat works perfectly (it's handled by the kernel so I don't have to deal with it in kbdd).

Now what remains to be done is create the kbdd maps for other keyboards (not everyone has a Belkin F8U1500). The original kbdd source lumps all the keymaps and IR protocols into a couple files, but I'm going to break them out so there's one file per keyboard. That should make it much easier for those that want to add support for
additional keyboards. I'll add the driver for the Micro Innovations Pocketop keyboard (since I have one to test with) and I may take a shot at the Targus IR keyboard since the maps and protocols are captured in the original Zaurus IRK source code.

That will get this to a beta release. From there I'll add more keyboards (if I can get assistance from keyboard owners to figure out the maps/protocols). I also want a GUI applet to launch and kill kbdd. I may also need to put some thought into supporting non-english letters (probably using "compose" sequence support already in the kernel). Last but not least I have some ideas for adding a "mouse mode" where the arrow keys on the keyboard could be used to move the mouse cursor. Suggestions are welcome.

(part 4)


At 7:31 AM, Blogger Graham Jones said...

Brings back memories.

In fact, you might like my novel.

At 2:58 AM, Anonymous Anonymous said...

Don't forget to send patches to kbdd authors :)


Post a Comment

<< Home