[comp.sys.ibm.pc] Enhanced Keyboards...how does your machine recognize it?

walker@ug.cs.dal.ca (Paul D. Walker) (01/10/90)

First of all, thanks to all those who replied to me about the logitech mouse
driver.  I picked up the latest copy from their BBS only to discover that I 
still have the problem with my graphics... (Time to get an ATI Wonder...)

Anyway, on to my question.  I have an AT with an enhanced keyboard.  I am 
having a slight problem with it, however.  The machine does not want to 
recognize that it is an enhanced keyboard.  This means that it does not 
recognize the F11 and F12 keys, nor will it send seperate scan codes for 
the 'grey' keys.

I have a program called SYSID version 4.4.  From what I understand, it was
originally taken from BIX sometime in the past.  This program does a lot of
quick and dirty things and tells you a lot of information about your machine.

When I ran this program, there is one page of information that tells me 
	1) that I have BIOS support for an enhanced keyboard.
	2) that I do not have an enhanced keyboard present.

Well, I find that curious. I think that I am looking at a 101-key keyboard :)

Does anyone have any experience with this problem?  Anyone know of any 
software that will allow me to force my computer to recognize this 
keyboard?  Anyone have any suggestion on how I can fix this?

Some information:
	I have a 286 with an enhanced keyboard.
	The BIOS is dated Sept 25/88 
	The BIOS is made by American Megatrends Inc.

My keyboard does not have a switch that says XT/AT like some of them do.  

Any help in this matter would be greatly appreciated.  If you think that you 
might have an answer, but need more information, just ask. 

Thanks in advance.

	Paul.

PS:  If anyone is interested in the sysid program, then I have both source
	 and the executable.

- Paul D. Walker                 -       _   /|            - Dalhousie U. 
 - walker @ dalcsug               -      \'o.O'    Ackpth!  - Comp Science
  - walker @ ug.cs.dal.ca          -     =(___)=  /_Thptpth! - fourth year! 
   - {utai | uunet}!dalcs!ug!walker -       U                 - Gonna graduate 
    - 01WALKER @ DALAC.BITNET        - Bill for President!     - soon...

fisher@sc2a.unige.ch (Markus Fischer) (01/12/90)

In article <1990Jan10.023642.15851@ug.cs.dal.ca>, walker@ug.cs.dal.ca (Paul D. Walker) writes:
> [...]
> Anyway, on to my question.  I have an AT with an enhanced keyboard.  I am 
> having a slight problem with it, however.  The machine does not want to 
> recognize that it is an enhanced keyboard.  This means that it does not 
> recognize the F11 and F12 keys, nor will it send seperate scan codes for 
> the 'grey' keys.
> [...]

This is wrong.  You say: `` *it* does not recognize the F11 and F12 keys, nor
will *it* send seperate scan codes for the `grey' keys. ''

The probles is the two `it's are not the same...  The keyboard *does* send a
scan code whenever you push or release a key. It even sends the `pushed' scan
code repeatedly when you hold the key down.  These codes are then interpreted
by the keyboard driver (the internal BIOS one or a loaded keyboard driver), and
a resulting character or extended code is stored in the 15-char keyboard buffer,
which the current program might then read.

The first `it' is the keyboard driver, the second is the keyboard itself.

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...)

Hm, this grew longer than I expected, I hope this will be useful, though.

Markus Fischer, Dpt. of Anthropology, Geneva.

wjc@sppy00.UUCP (William J. Curry) (01/14/90)

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 <stdio.h>
#include <dos.h>

#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?" ==