Friday, October 14, 2005

Zaurus pdaXrom IR Keyboard Drivers (part 6)

(continued from part 5)

I've released an "alpha" version of Zkbdd for devices using the 2.4.18 pdaXrom kernel (C7X0, C860, 6000). The release notice on OESF has the details. Initial feedback is positive, so I need to look into getting modules built for the 2.4.20 kernel devices (C1000, C3000, C3100).

However, before I do that I'm tempted to implement a major change to how the keyboard specific portions are implemented. Currently, each supported keyboard has a source file that defines scancode mapping tables and a single function that implements the all of the keyboard handling logic. All these are compiled and linked into zkbdd at build time. However, only a tiny part of the keyboard handling logic is actually keyboard specific. That's the part that turns a sequence of bytes received on the IR port into a scancode. I'd like to have a way to define that logic that can be loaded at run-time and doesn't have to be compiled into a binary executable or library. Sounds like a job for a scripting language!

I'm a big fan of scripting languages. I've used Perl, Python, Lisp, etc. over the years with great success. Would it be possible to embed such a language in Zkbdd so that the keyboard specific portions of the driver could be scripted and supplied at run-time as a text file? Hmm, writing device drivers in a scripting language -- if that doesn't get me branded a "heretic" nothing will!

Now the "big" languages (Perl, Python, and Lisp) are probably total overkill for this application. We're talking about scripts that are maybe a dozen lines long. It's tough to justify growing the Zkbdd binary several hundred KB to support that. After all, the target here is a PDA, not a PC. I figured Forth is probably compact/capable enough to work here. I also thought that Ruby might be a candidate but I knew next to nothing about it so I set off to do some research. In the process I stumbled upon Lua. Lua fits the requirements almost perfectly! It's amazingly small (about 64KB), very easy to embed in a C program, and has a simple conventional syntax that can be learned in minutes (at least well enough to do a tiny keboard driver script). The only thing missing was bitwise operators and it turns out there's a Lua source patch to add those in.

Of course what looks good on paper, doesn't always work as well in the real world. At this point I need to hack out a proof-of-concept and put it to the test. I'll do that while I await more feedback on the alpha release -- the results should be quite interesting!

(part 7)

0 Comments:

Post a Comment

<< Home