home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / keyboard / kybdext / kybdext.c next >
Encoding:
C/C++ Source or Header  |  1989-12-11  |  2.7 KB  |  117 lines

  1.  
  2. /*    kybdext.c  source code for iskybdext() and isbioskybdext()  */
  3.  
  4.  
  5. /******************************************************************************
  6.  
  7.     NAME    iskybdext -     tells if the extended keyboard is installed
  8.         isbioskybdext - tells if the BIOS supports the extended keyboard
  9.  
  10.     USAGE    #include "kybdext.h"
  11.         int iskybdext(void);
  12.         int isbioskybdext(void);
  13.  
  14.     PROTOTYPE    kybdext.h
  15.  
  16.     DESCRIPTION    iskybdext returns 1 if the extended keyboard is installed
  17.         (zero if not installed)
  18.         isbioskybdext returns 1 if the BIOS supports the extended
  19.         keyboard (zero if it does not support)
  20.  
  21.         See the test program included in this file for
  22.         an example usage.
  23.  
  24.     RETURNS    1 or zero (see description)
  25.  
  26.     NOTE
  27.  
  28.     PORTABILITY    MS-DOS specific, Turbo-C specific
  29.  
  30.     AUTHOR    Jim Drash
  31.         Software Development and Consulting
  32.         2256 Beechmont Avenue
  33.         Cincinnati, OH, 45230
  34.         Compuserve ID: 76607,70
  35.  
  36. ******************************************************************************/
  37.  
  38. #include <dos.h>
  39.  
  40. #define BIOS_DATA_SEG     0x0000
  41. #define KYBD_TYPE_OFF     0x0496
  42. #define KYBD_STAT_OFF     0x0417
  43. #define EXTENDED_KYDB       0x10
  44. #define INS_MODE_TOGGLE     0x80
  45. #define BIOS_KYBD_FUNCTION  0x16
  46. #define KYBD_GET_EXT_STATUS 0x12
  47.  
  48. int iskybdext(void)
  49. {
  50.     if (peekb(BIOS_DATA_SEG, KYBD_TYPE_OFF) & EXTENDED_KYDB)
  51.         return(1);
  52.     else
  53.         return(0);
  54. }
  55.  
  56. int isbioskybdext(void)
  57. {
  58.     char al;
  59.  
  60.     /*  check to see if the extended status service works */
  61.  
  62.     _AX = 0;
  63.     _AH = KYBD_GET_EXT_STATUS;
  64.     geninterrupt(BIOS_KYBD_FUNCTION);
  65.     al = _AL;
  66.  
  67.     /* check to see that the service reports the right stuff */
  68.  
  69.     if (al != peekb(BIOS_DATA_SEG, KYBD_STAT_OFF))
  70.         return(0);
  71.  
  72.     /* toggle the insert mode */
  73.  
  74.     pokeb(BIOS_DATA_SEG, KYBD_STAT_OFF, \
  75.         peekb(BIOS_DATA_SEG, KYBD_STAT_OFF) ^ INS_MODE_TOGGLE);
  76.  
  77.     /*  check to see if the extended status service works again */
  78.  
  79.     _AX = 0;
  80.     _AH = KYBD_GET_EXT_STATUS;
  81.     geninterrupt(BIOS_KYBD_FUNCTION);
  82.     al = _AL;
  83.  
  84.     /* check to see that the service reports the right stuff again */
  85.  
  86.     if (al != peekb(BIOS_DATA_SEG, KYBD_STAT_OFF))
  87.         return(0);
  88.  
  89.     /* toggle the insert mode back */
  90.  
  91.     pokeb(BIOS_DATA_SEG, KYBD_STAT_OFF, \
  92.         peekb(BIOS_DATA_SEG, KYBD_STAT_OFF) ^ INS_MODE_TOGGLE);
  93.  
  94.     return(1);
  95. }
  96.  
  97. /***********************************************************************/
  98.  
  99. /* #define TEST 1 */
  100.  
  101. #ifdef TEST
  102. #include <stdio.h>
  103.  
  104. main()
  105. {
  106.     if (iskybdext())
  107.         printf("Extended Keyboard is installed\n");
  108.     else
  109.         printf("Extended Keyboard is not installed\n");
  110.  
  111.     if (isbioskybdext())
  112.         printf("BIOS supports extended keyboard\n");
  113.     else
  114.         printf("BIOS does not support extended keyboard\n");
  115. }
  116. #endif
  117.