From: Arndt S. <ab...@sr...> - 2001-07-09 14:33:37
|
Hi folks, here is another input device driver for Linux 2.4 and ruby; it allows to use Handykey's Twiddler (the original, RS232 version) as a joystick. The Twiddler (http://www.handykey.com) is probably the most famous and popular input device for wearable computers, many of which run Linux. It is actually meant as a chording keyboard; you press multiple keys simultaneously (a chord), and a keystroke is generated as soon as the keys are released. To make this work, the Twiddler continuously sends data packets describing the state of the keys up the serial line, and a daemon process picks them up, analyzes them, consults a chord-to-keystroke mapping table, and inserts the resulting keystrokes into the system. The Linux version of this daemon currently does this using the TIOCSTI ioctl, if a text console is active, or by means of the external program a2x, if the current console is the one where the X server runs. This approach has a couple of disadvantages; it would be much nicer if the Twiddler was handled by a kernel module that could directly inject the keystrokes into the system just like the keystrokes from other keyboards, perhaps totally obviating the need for the daemon process, but at least obviating the need to maintain different sets of chord-to-keystroke mappings for X and console applications. With this goal in mind, I went through the Linux 2.4. kernel sources to look for ways how it could be done. This was when I first discovered Vojtech's great new input framework that does not only make things like this possible, but even easy. And after some more searching and browsing, I came across The Linux Console Project and its Sourceforge pages. So here is my first shot. The attached Twiddler driver, "twidjoy", is quite simple, and it does a lot less than the chord-to-keystroke mapping daemon mentioned above, but what it does is very useful in its own right: It turns the Twiddler into a joystick with 2 analog axes (did I mention that the Twiddler also has a built-in tilt sensor?!) and whopping 18 buttons! (And yes, all of them can be used with Unreal Tournament!) The driver comes together with the appropriate additions to inputattach which allow to select the "twidjoy" driver and check that the Twiddler is present. I plan on writing another driver module, code-named "twidkbd", that will then implement the Twiddler's standard chording behaviour (i.e. generating keystrokes from button chords and mouse events from the tilt sensor), so support for this upcoming driver is already present in the submitted inputattach code, too. (My priority for the implementation of "twidkbd" is a bit lower, though, because I will first try to improve the Linux support for the newly available Twiddler2, but if someone needs this and/or wants to help writing it, let me know.) To develop the code, I checked out ruby from the CVS on Friday, modified the file "utils/inputattach.c" and created "twidjoy.c" from the template "linux/drivers/input/stinger.c". Since the relevant source files of the input system in stock 2.4.5, 2.4.6, and ruby are mostly the same, I assume that the driver should work with all of these Linux flavors. However, I have myself only tried it with kernel 2.4.5 (stock, i.e. without ruby). If the module passes your introspection and tests, I would very much like to see it included into the 2.4 kernel branch. Have fun with it! Arndt PS: This driver does NOT support the Twiddler2, which directly connects to the PS/2 keyboard and mouse ports. The Twiddler2 does not need any special drivers, so it works with Linux out of the box -- albeit not as a 18 buttons joystick ;-) -- Arndt Schoenewald <ab...@sr...> Ostenhellweg 31, 44135 Dortmund, Germany Tel: +49 231 556075 |