home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c100 / 1.ddi / OOPWLD.ZIP / SHAPES / DOSKEY.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-11  |  1.2 KB  |  55 lines

  1. // DOSKEY.HPP: scan codes returned by bios.  Allows reading of cursor
  2. // pad, ctrl, alt, shift, etc.  Not a complete set.
  3. #ifndef _DOSKEY_HPP_
  4. #define  _DOSKEY_HPP_
  5. #include <bios.h>
  6.  
  7. static enum doskey {
  8.   CAP_A = 0x1e41,  // Capital Letter A
  9.   LC_A = 0x1e61,  // Lower-Case letter a
  10.   CAP_B = 0x3042,
  11.   LC_B = 0x3062,
  12.   CAP_C = 0x2e43,
  13.   LC_C = 0x2e63,
  14.   CAP_E = 0x1245,
  15.   LC_E = 0x1265,
  16.   CAP_N = 0x314e,
  17.   LC_N = 0x316e,
  18.   CAP_P = 0x1950,
  19.   LC_P = 0x1970,
  20.   CAP_R = 0x1352,
  21.   LC_R = 0x1372,
  22.   CAP_S = 0x1f53,
  23.   LC_S = 0x1f73,
  24.   CAP_T = 0x1454,
  25.   LC_T = 0x1474,
  26.   LEFT_ARROW = 0x4b00,
  27.   RIGHT_ARROW = 0x4d00,
  28.   UP_ARROW = 0x4800,
  29.   DOWN_ARROW = 0x5000,
  30.   ESCAPE = 0x11b
  31. };
  32.  
  33. inline doskey get_doskey() {
  34.   while(!bioskey(1));  // wait for a keypress
  35.   return (doskey)bioskey(0);
  36. }
  37.  
  38. #endif  _DOSKEY_HPP_
  39. #if 0  // above keys are found with the following program:
  40. #include <stdio.h>
  41. #include <bios.h>
  42.  
  43. int main(void)
  44. {
  45.    char ch;
  46.    while(1) {
  47.      printf("Input a character:");
  48.      while(!bioskey(1));
  49.      int key = bioskey(0);
  50.      printf("key = 0x%x\n", key);
  51.      if(key == 0x11b) return 0; // escape to quit
  52.    }
  53. }
  54. #endif
  55.