[comp.sys.ibm.pc] AT keyboards, ports, and other things

stanton@Polya.Stanford.EDU (Scott Stanton) (06/21/89)

Is it possible for an extended (101 key) keyboard to do chording on an
AT (clone)?  i.e. Can I detect if more than one key is being pressed
at the same time?  I have no qualms about going straight to the
hardware interrupts on this one, assuming I can find any info on
those.

Which brings me to my next question:  Could someone provide me
with a description of how INT 9H works?  Is it triggered by both
key press and key release?  How do I query the keyboard to
determine which key(s) are currently being held down?  I assume
the info is available on some port, but I'm having trouble
finding any books that will tell me anything about this.  (or
anything about ports at all, for that matter)

--Scott (stanton@polya.stanford.edu)

dross@umn-d-ub.D.UMN.EDU (david ross) (06/21/89)

In article <10146@polya.Stanford.EDU> stanton@Polya.Stanford.EDU (Scott Stanton) writes:
>Is it possible for an extended (101 key) keyboard to do chording on an
>AT (clone)?  i.e. Can I detect if more than one key is being pressed
>at the same time?  I have no qualms about going straight to the
>hardware interrupts on this one, assuming I can find any info on
>those.

I know of at least one word processing program that detects keypress
makes and breaks, and therefore lets you chord; I believe, however, 
they use port polling and not interrupts.  Unfortunately, port polling
will keep your program from working with many useful TSR utilities.

toma@tekgvs.LABS.TEK.COM (Tom Almy) (06/21/89)

In article <10146@polya.Stanford.EDU> stanton@Polya.Stanford.EDU (Scott Stanton) writes:
>Is it possible for an extended (101 key) keyboard to do chording on an
>AT (clone)?  i.e. Can I detect if more than one key is being pressed
>at the same time?  I have no qualms about going straight to the
>hardware interrupts on this one, assuming I can find any info on
>those.

Yes you can, and you don't need to take over the hardware interrupt (!).  I
had just such an application.  I chained into interrupt 15H (system intercept)
handling only the cases when AH=4FH (keycode function).  In this case, AL has
the key scan code (which has make/break encoded in the msb).  If you return
with carry clear, then the key is ignored.  I would "snarf" the keycodes
I was interested in into my own ring buffer, which my program would then
empty.  If you return with carry set, then the value in AL is used as the
key code -- I made use of this in my oft-posted TSR KBDR.COM which makes the
caps lock key behave as an additional control key.

>Which brings me to my next question:  Could someone provide me
>with a description of how INT 9H works?

You need to find a copy of the Technical reference manual, which unfortuately
is now out of print.  It also lists all the keycodes.

>Is it triggered by both
>key press and key release?  
Normally.  It turns out the keyboard can be programmed to run in three
different modes!

>How do I query the keyboard to
>determine which key(s) are currently being held down?  

You can't.  I maintained a bit-per-key table to keep track of depressions.
To make matters worse, the "typamatic" action causes multiple depress codes
(without release codes) to be sent!  My app required no repeating keys, so
if I got a depress code when the table indicated already depressed, I ignored
the code.

Tom Almy
toma@tekgvs.labs.tek.com
Standard Disclaimers Apply

cjdb@tank.uchicago.edu (Charles Blair) (07/05/89)

In article <5404@tekgvs.LABS.TEK.COM> toma@tekgvs.LABS.TEK.COM (Tom Almy) writes:
>[...]
>You need to find a copy of the Technical reference manual, which unfortuately
>is now out of print.  It also lists all the keycodes.

A more than decent substitute is the Technical Reference Manual that
Hewlett-Packard puts out for its HP Vectra CS PC. Other clone-makers
might have their own tech ref manuals which could do in a pinch as well.

-- 
Bitnet:			      pmrcjdb@uchimvs1
Internet: 		cjdb@tank.uchicago.edu
uucp:         ...!uunet!mimsy!oddjob!tank!cjdb