[comp.sys.ibm.pc] Keyboard Detection Question

jbeard@ntvax.uucp (Jeff Beardsley) (10/31/89)

Does anyone out there know how to detect the presence of an enhanced
keyboard (101 keys, F11, F12, etc).  I do know how to use it once it's
there, but assuming it to be there will cause most machines without it
to lock up.

jbeard

-- 
-------- Jeff Beardsley at UNT ----------- <jbeard@dept.csci.unt.edu> --------

wjc@sppy00.UUCP (William J. Curry) (11/01/89)

In article <1989Oct31.054436.20492@ntvax.uucp> jbeard@ntvax.UUCP 
(Jeff Beardsley) asks

>Does anyone out there know how to detect the presence of an enhanced
>keyboard (101 keys, F11, F12, etc).  I do know how to use it once it's
>there, but assuming it to be there will cause most machines without it
>to lock up.

Simple, take the byte at 0x00400096 and AND it with 0x10.  If you get a
non-zero value, you have an enhanced keyboard attached to the machine and
may use the enhanced functions of int16h.

For example,

#include <stdio.h>

#define TRUE  1
#define FALSE 0

int CheckForEnhanced(void)
{
   unsigned char far *p;

   p = (unsigned char far *) 0x00400096;

   if (*p & 0x10)    /* is it an enhanced keyboard? */
      return(TRUE);  /* yep, let caller know	    */

   return(FALSE);    /* must not be enhanced        */
}

int main(void)
{
   if (CheckForEnhanced())
      printf("Enhanced!\n");
   else
      printf("Not Enhanced!\n");
   return(0);
}

Hope it helps!

-Bill

-- 
William Curry  UUCP:wjc@sppy00.UUCP or {att|pyramid|killer}!osu-cis!sppy00!wjc
Snail: 6565 Frantz Road  Dublin, Ohio 43017-0702                614-761-5031
    == "Of course the standard disclaimer applies, why wouldn't it?" ==