home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / bios / bioskey.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-09  |  786 b   |  40 lines

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. /*
  3.  * BIOSKEY.C.
  4.  *
  5.  * Modified by Peter Sulyok 1995 <sulyok@math.klte.hu>.
  6.  *
  7.  * This file is distributed WITHOUT ANY WARRANTY; without even the implied
  8.  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9.  *
  10.  */
  11.  
  12. #include <bios.h>
  13. #include <dpmi.h>
  14.  
  15. int
  16. bioskey(int cmd)
  17. {
  18.   __dpmi_regs r;
  19.   r.h.ah = cmd;
  20.   __dpmi_int(0x16, &r);
  21.   switch ( cmd )
  22.   {
  23.   case 0x00:
  24.   case 0x10:
  25.     return r.x.ax & 0xffff;
  26.   case 0x01:
  27.   case 0x11:
  28.     if ((r.x.flags & 0x40 ) == 0x40 )
  29.       return 0;
  30.     else
  31.       /* CTRL-BREAK checking */
  32.       return (!r.x.ax) ? -1 : (r.x.ax & 0xffff);
  33.   case 0x02:
  34.     return r.h.al;
  35.   case 0x12:
  36.     return r.x.ax & 0xffff;
  37.   }
  38.   return 0;
  39. }
  40.