summaryrefslogtreecommitdiff
path: root/reference/C/CONTRIB/SNIP/isxkbrd.c
blob: b104a7c5c2bf6d74d24dbe5f7267c81bc1ba6b5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
**  ISXKBRD.C - public domain by Ed Kowalski.
**
**  isxkeybrd() - detects enhanced kbd
*/

#include <dos.h>

/*
**  Check for enhanced keyboard support.
*/

int isxkeybrd(void)
{
      union REGS rg;
      unsigned kbdflags;

      rg.h.ah = 0x02;               /* check BIOS supports enhanced kbd */
      int86(0x16, &rg, &rg);        /* get kbd flags                    */
      kbdflags = rg.h.al;

      /* mess 'em up, get enhanced flags */

      rg.x.ax = 0x1200 + kbdflags ^ 0xff;
      int86(0x16, &rg, &rg);
      if (rg.h.al == kbdflags)      /* BIOS supports enhanced keyboard  */
      {
            /* if bit 4 at 40:96h is set machine has an enhanced kbd */

            if ((*(( char far *) 0x400096L) & 0x10))
                  return 1;         /* enhanced keyboard present        */
      }
      return 0;                     /* don't use enhanced keyboard calls */
}

#ifdef TEST

#include <stdio.h>
main()
{
      if (isxkeybrd())
            puts( "Enhanced Keyboard supported" );
      else  puts( "Enhanced Keyboard NOT supported ");
      return 0;
}

#endif /* TEST */