Re: Keyboard hacking?

Martin Mares (mj@atrey.karlin.mff.cuni.cz)
Fri, 2 Jan 1998 10:04:35 +0100


Hi,

> Has anybody ever modified keyboard.c (presumably the handle_scancode()
> routine, mostly) to cope with chorded input? The pseudocode'd be
> something like this:
>
> if scancode indicates a key-press event
> add this key to the array of currently-pressed keys
> else (key-release event)
> if previous scancode indicates a key-press event
> lookup the key that maps to the array of currently-pressed keys and
> return that.
> if there isn't one, beep or something
> endif
> remove this key from the array of currently-pressed keys
> endif
>
> I could probably figure out the code for it if I poked hard enough,
> but C isn't my forte so I thought I'd ask first.

There already _is_ an array of currently-pressed keys (key_down in keyboard.c),
you can simply use it. I would recommend adding a new keyboard mode in addition
to the cooked, raw and medium raw modes and handle it directly in the
handle_scancode() function.

Have a nice fortnight

-- 
Martin `MJ' Mares   <mj@gts.cz>   http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
"A LISP programmer knows value of everything, but cost of nothing."