Path: utzoo!utgpu!watserv1!watmath!iuvax!cica!tut.cis.ohio-state.edu!sppy00!wjc From: wjc@sppy00.UUCP (William J. Curry) Newsgroups: comp.sys.ibm.pc Subject: Re: Enhanced Keyboards...how does your machine recognize it? Message-ID: <684@sppy00.UUCP> Date: 13 Jan 90 20:36:32 GMT Reply-To: wjc@sppy00.UUCP (William J. Curry) Organization: Online Computer Library Center, Dublin, Ohio. Lines: 100 In article <158@sc2a.unige.ch>, fisher@sc2a.unige.ch (Markus Fischer) claims: >[..] >I also have an AT with an extended keyboard, and it's true that the >`grey'-Home >and the `Shift-7'-Home, for instance, are treated the same way by my keyboard >driver (i.e. the same extended code is send to the buffer). BTW: the same is >true for `keypad'-7 and `numpad'-7, if you havn't noticed... It's true also >that *no* extended code is send for F11 and F12, but then there isn't either >for(say) Ctrl-`keypad'-4. > >Maybe you have noticed that some programs use `numpad'-5 (several TSR's), or >Ctrl-PgUp (DOS-EDIT, WordPerfect), even though these key-combinations arn't >recognized by the keyboard driver (i.e. no extended code is send to the >keyboard buffer). This is because these programs hook the keyboard interrupt >themselves, and thus override the standard interpretation of scan-codes. > >But let's go back to the F11 and F12 keys. Most programs wouldn't recognize >the extended codes send by the keyboard driver anyway (it's still a shame >that no codes are generated, I agree). If you want to use them, you will >have to hook the keyboard interrupt yourself. (WP 5 does this, and you can >assign a macro to these keys...) Well, the article started correct, and went downhill from there. Most bios's (usually revised XT on), have two "read from keyboard buffer" routines. Both are INT16 services. One being a standard read (which will not return anything for F11 and F12 or keypad-5). This is the routine used by most C compilers for the getch() routine and the one DOS uses to get keystrokes. The other routine is for enhanced keyboards and will return codes for F11, F12 and keypad-5. (It also returns different codes for keypad-home and cursor row-home.) The downfall of using this that if the machine's bios does not support this enhanced call, you will never read the keyboard and probably hang your application. (I refer to the far right hand set of keys on an enhanced keyboard as the keypad keys and and the set of keys to the left of that as the cursor row keys.) (FYI: To determine between the cursor row keys and the keypad keys (ie home, end, page up, page down, etc.) most bios's place a 0xe0 in the character returned for a cursor row key and a 0x00 for a keypad key. See example below for where the character is returned.) If you have ever tried to write a keyboard driver (both INT9 and INT16) you would realize what a pain it is to create and maintain it when bios usually will give you what you want. Below is an example of how to determine if the machine's bios supports the enhanced keyboard reads and how to use the enhanced keyboard reads. I have tested this scheme on many various machines (IBM, Wyse, Compaq, NCR, NEC, AST, Zenith, etc.) and have had no problems with it. I hope this answers any questions. -Bill --cut here-- #include #include #define BIOS_KBID 0x00400096 int main(void) { union REGS r; unsigned char kbread_cmd = 0x00; /* assume no enhanced support */ /* if bit 4 set at 0x00400096 bios supports the call AND an */ /* enhanced keyboard is attached. */ if (*(char far *)BIOS_KBID & 0x10) { #ifdef DEBUG printf("Enhanced keyboard"); #endif kbread_cmd = 0x10; /* now can use enhanced read */ } else { #ifdef DEBUG printf("Standard keyboard"); #endif } /* read a keystroke using the correct routine */ r.h.ah = kbread_cmd; int86(0x16, &r, &r); /* scan code is returned in ah, character in al */ printf("key scan code is %x, char is %x (%c)\n", r.h.ah, r.h.al, r.h.al); return(0); } -- William Curry UUCP:wjc@sppy00.UUCP or {att|pyramid|killer}!osu-cis!sppy00!wjc Snail: OCLC, 6565 Frantz Road Dublin, Ohio 43017-0702 614-761-5031 == "Of course the standard disclaimer applies, why wouldn't it?" ==