home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / KB_DATA.H < prev    next >
C/C++ Source or Header  |  1997-07-05  |  3KB  |  93 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. **  by: Dan Kozak
  5. **  Revisions:
  6. **  30-Mar-96  Ed Blackman  OS/2 mods
  7. */
  8.  
  9. /*
  10. **  For use with your code, strip out the demo main() and make this into
  11. **  a header file.
  12. */
  13.  
  14. #ifndef KB_DATA__H
  15. #define KB_DATA__H
  16.  
  17. #include "extkword.h"
  18. #include "snipkbio.h"
  19.  
  20. typedef struct                            /* Keyboard status structure  */
  21. {
  22.   unsigned short                          /* Least Significant Bit      */
  23.   right_shift_down  : 1,                  /* Right Shift key depressed  */ 
  24.   left_shift_down   : 1,                  /* Left Shift key depressed   */
  25.   ctrl_down         : 1,                  /* Ctrl key depressed         */
  26.   alt_down          : 1,                  /* Alt key depressed          */
  27.   scroll_on         : 1,                  /* Scroll Lock is on          */
  28.   num_on            : 1,                  /* Num Lock is on             */
  29.   caps_on           : 1,                  /* Caps Lock is on            */
  30.   ins_on            : 1,                  /* Insert state is active     */
  31.   left_ctl          : 1,                  /* Left Ctl key depressed     */
  32.   left_alt          : 1,                  /* Left Alt key depressed     */
  33. #if defined (__OS2__)
  34.   right_ctl         : 1,                  /* Right Ctl key depressed    */
  35.   right_alt         : 1,                  /* Right Alt key depressed    */
  36. #else       /* assume DOS */
  37.   sys_rq            : 1,                  /* SysRq depressed            */
  38.   pause_on          : 1,                  /* Pause is active            */
  39. #endif
  40.   scroll_down       : 1,                  /* Scroll Lock key depressed  */
  41.   num_down          : 1,                  /* Num Lock key depressed     */
  42.   caps_down         : 1,                  /* Caps Lock key depressed    */
  43. #if defined (__OS2__)
  44.   sys_rq            : 1,                  /* SysRq depressed            */
  45. #else       /* assume DOS */
  46.   ins_down          : 1;                  /* Insert key depressed       */
  47. #endif
  48. } biosshiftstate;                         /* Most Significant Bit       */
  49.  
  50. biosshiftstate FAR * volatile kbd_status =
  51.       (biosshiftstate FAR * volatile)(peekkey());
  52.  
  53. #ifdef TEST
  54.  
  55. #include <stdio.h>
  56. #include <time.h>
  57.  
  58. main()
  59. {
  60.       clock_t start = clock();
  61.  
  62.       puts("Press some key stuff and I'll tell you what in 3 seconds...\n");
  63.  
  64.       while (((clock() - start) / CLOCKS_PER_SEC) < 3)
  65. #if defined(__OS2__)
  66.           /* to store key info where peekkey() can find it */
  67.             if(kbhit()) ext_getch()
  68. #endif
  69.             ;
  70.  
  71.  
  72.       printf("right_shift_down = %d\n",kbd_status->right_shift_down);
  73.       printf("left_shift_down = %d\n",kbd_status->left_shift_down);
  74.       printf("ctrl_down = %d\n",kbd_status->ctrl_down);
  75.       printf("alt_down = %d\n",kbd_status->alt_down);
  76.       printf("scroll_on = %d\n",kbd_status->scroll_on);
  77.       printf("num_on = %d\n",kbd_status->num_on);
  78.       printf("caps_on = %d\n",kbd_status->caps_on);
  79.       printf("ins_on = %d\n",kbd_status->ins_on);
  80.       printf("filler = %d\n",kbd_status->filler);
  81.       printf("ctrl_numloc = %d\n",kbd_status->ctrl_numloc);
  82.       printf("scroll_down = %d\n",kbd_status->scroll_down);
  83.       printf("num_down = %d\n",kbd_status->num_down);
  84.       printf("caps_down = %d\n",kbd_status->caps_down);
  85.       printf("ins_down = %d\n",kbd_status->ins_down);
  86.  
  87.       return 0;
  88. }
  89.  
  90. #endif /* TEST */
  91.  
  92. #endif /* KB_DATA__H */
  93.