home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 4.ddi / C / KBSHIFT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-05  |  1.4 KB  |  47 lines

  1. /**
  2. *
  3. * Name        kbshift -- Return the current shift status
  4. *        (Formerly called UTSHFKEY.)
  5. *
  6. * Synopsis    keywd = kbshift(pkeybd);
  7. *
  8. *        int      keywd   Returned keyboard status as an integer
  9. *        KEYSTATUS *pkeybd Returned keyboard status
  10. *
  11. * Description    KBSHIFT returns the status of the shift key and other
  12. *        control keys in the bit structure.  If the bit is on,
  13. *        the flag is set; otherwise it is off.  The functional
  14. *        value is simply the 8 bits as an integer returned by the
  15. *        BIOS function call.
  16. *
  17. *  Version    3.0 (C) Copyright Blaise Computing Inc.  1984, 1986
  18. *
  19. **/
  20.  
  21. #include <bkeybd.h>
  22. #include <butility.h>
  23.  
  24. int kbshift(pkeybd)
  25. KEYSTATUS *pkeybd;
  26. {
  27.     int ax,bx,cx,dx,flags;
  28.  
  29.     ax = 0x0200;              /* Make BIOS call 0x16 with     */
  30.     bios(22,&ax,&bx,&cx,&dx,&flags);  /* AH = 2.  It returns 8 bits   */
  31.                       /* in AL.               */
  32.  
  33.     /* Extract each bit of ax separately in order to avoid          */
  34.     /* assumptions about the order of bit fields in *pkeybd.          */
  35.  
  36.     pkeybd->right_shift  = ((ax & 0x01) != 0);
  37.     pkeybd->left_shift     = ((ax & 0x02) != 0);
  38.     pkeybd->ctrl_shift     = ((ax & 0x04) != 0);
  39.     pkeybd->alt_shift     = ((ax & 0x08) != 0);
  40.     pkeybd->scroll_state = ((ax & 0x10) != 0);
  41.     pkeybd->num_state     = ((ax & 0x20) != 0);
  42.     pkeybd->caps_state     = ((ax & 0x40) != 0);
  43.     pkeybd->ins_state     = ((ax & 0x80) != 0);
  44.  
  45.     return utlobyte(ax);
  46. }
  47.