[LispM-Hackers] Keyboard problem

Nyef nyef@softhome.net
Sat Mar 23 19:53:01 2002


On Sat, 23 Mar 2002, John Morrison wrote:

> Hi;

Hello.

> The Bad News is that I can neither remember who nor find the email
> from some kind soul on this list who told me my problem with getting
> only one keyboard interrupt was because one is not really finished
> servicing a keyboard interrupt until one has read the scan code from
> I/O space.
>
> The Good News is that he was right (Thank You whoever told me), and
> now I can read repeated key presses (up events, down events, repeat
> events, etc.).

You're welcome.

> The other other Bad News is that I guess we will have an issue with
> supporting mice, eh?  USB?  PS/2?

PS/2 mice are easy. There's another interrupt to worry about (I'm not sure
which one, maybe 12), but you also check the value of port 0x64 before you
acknowledge the byte recieved (same data port and everything). If the 0x20
bit is high, then it's a mouse byte, otherwise it's a keyboard byte. Mouse
data is sent in 3-byte packets. Unfortunately, I forget the exact format,
and am too tired to decypher my code right now. It should be fairly simple
to figure out if you remember that the X and Y movement fields are 9 bits
wide (8 bits each in two bytes, and 1 bit each in the byte with the button
states and such). This also means that you could use almost the same
interrupt handling code for both mouse and keyboard interrupts (the only
exception being the interrupt acknowledge code).

> -jm

---------------------------
All programming can be viewed as an exercise.
---------------------------
Alastair Bridgewater
e-mail: nyef@softhome.net