home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / KBGETKEY.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  1.3 KB  |  52 lines

  1. /**
  2. *
  3. * Name        KBGETKEY -- Return character and scan code from the
  4. *                keyboard.
  5. *
  6. * Synopsis    ch = kbgetkey (pscan);
  7. *
  8. *        int  ch     Character code of key pressed.
  9. *
  10. *        int *pscan    Returned scan code of key pressed.
  11. *
  12. * Description    This function waits for a key sequence to be pressed
  13. *        (unless one is already waiting in the BIOS typeahead
  14. *        buffer) and then returns both the ASCII and scan
  15. *        codes for the character.
  16. *
  17. *        If the global variable b_kbusex is set to KB_USE_EXTEND
  18. *        and if the extended BIOS keyboard services are
  19. *        available, then they are used.    Otherwise the
  20. *        traditional keyboard service is used.
  21. *
  22. * Returns    ch        Character code of key pressed.
  23. *        pscan        Scan code of key pressed.
  24. *
  25. * Version    6.00 (C)Copyright Blaise Computing Inc.  1987,1989
  26. *
  27. **/
  28.  
  29. #include <dos.h>
  30.  
  31. #include <bkeybrd.h>
  32.  
  33. int  kbgetkey (pscan)
  34. int *pscan;
  35. {
  36.     union REGS regs;
  37.  
  38.         /* Set up for BIOS call to retrieve key from        */
  39.         /* keyboard buffer, or wait for a key if none is    */
  40.         /* present.                        */
  41.     regs.h.ah = ((   b_kbusex  != KB_USE_NORMAL
  42.           && kbequip() == KB_EXTENDED)    ? 0x10 : 0x00);
  43.  
  44.         /* Do the call.                     */
  45.     int86 (KB_BIOS_INT, ®s, ®s);
  46.  
  47.         /* Return appropriate values: scan and character    */
  48.         /* codes.                        */
  49.     *pscan = (int) regs.h.ah;
  50.     return ((int) regs.h.al);
  51. }
  52.