Friday, October 07, 2005

Zaurus pdaXrom IR Keyboard Drivers (part 2)

(continued from part 1)

I thought that the additional kernel drivers would be the difficult part of porting kbdd to pdaXrom, but the kernel work proved to be the easy part. Getting the kbdd daemon to build and run on the Zaurus is easy -- getting it to do the right thing is a little more difficult!

The first problem is that kbdd is written for the iPaq and the iPaqs for which Familiar Linux has been developed, don't have built in keyboards. So kbdd is designed to work with its own kernel keymap which would normally be loaded via the kernel's "loadkeys" command before kbdd is started. The kbdd daemon then translates the keycodes it gets from the IR keyboard into scancodes that when looked up in the loaded key map by the kernel's keyboard driver will ultimately put the right characters into the input queue.

Not a bad solution, and I was able to get some limited tests with this architecture to work from a console login, but the dual lookup table approach (keyboard to kbdd map and then kbdd map to kernel) seemed a little redundant. Why not just install a map matching the IR keyboard in the kernel and let kbdd just directly pass the keyboard's scan codes to the kernel without an intermediate lookup?

So I coded things up that way and sure enough it worked in a console login -- almost. A few keys wouldn't make it through. Checked the map, double checked the map, tripple checked the map, still no go. I could see the correct scan codes going to the device drivers, so it had to be a driver problem. A little digging revealed that the keybdev driver assumes that the kernel is using a normal x86 keyboard map and attempts to translate incoming keycodes to x86 scancodes. However I've replaced the kernel's key map with one that matches the codes from my IR keyboard, so keybdev's little conversion is getting in the way.

Modifying keybdev so that when built for the Zaurus it passes all keycodes through with no translation corrected the problem. Now I can see all the keys correctly in a console login.

Next step -- try it in XFree86. Not being an XFree86 or pdaXrom expert, I foolishly expected that since my kbdd worked in the console it would work in X. No such luck. Key bindings in X were totally wrong. A little poking around revealed that when pdaXrom starts X11, it loads a Zaurus specific keyboard mapping for X.

So sticking with my "no mapping in kbdd" approach is going to mean I need a keyboard specific kernel mapping and a keyboard specific X mapping. And I'd need a way to automatically load them when kbdd is started and restore the previous mappings when kbdd is shut down (or the Zaurus built-in keyboard won't work). On top of that, this approach makes it impossible to use both the Zaurus and IR keyboards at the same time.

Time to re-think things ... (part 3)


Post a Comment

<< Home