home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name kbshift -- Return the current shift status
- * (Formerly called UTSHFKEY.)
- *
- * Synopsis keywd = kbshift(pkeybd);
- *
- * int keywd Returned keyboard status as an integer
- * KEYSTATUS *pkeybd Returned keyboard status
- *
- * Description KBSHIFT returns the status of the shift key and other
- * control keys in the bit structure. If the bit is on,
- * the flag is set; otherwise it is off. The functional
- * value is simply the 8 bits as an integer returned by the
- * BIOS function call.
- *
- * Version 3.0 (C) Copyright Blaise Computing Inc. 1984, 1986
- *
- **/
-
- #include <bkeybd.h>
- #include <butility.h>
-
- int kbshift(pkeybd)
- KEYSTATUS *pkeybd;
- {
- int ax,bx,cx,dx,flags;
-
- ax = 0x0200; /* Make BIOS call 0x16 with */
- bios(22,&ax,&bx,&cx,&dx,&flags); /* AH = 2. It returns 8 bits */
- /* in AL. */
-
- /* Extract each bit of ax separately in order to avoid */
- /* assumptions about the order of bit fields in *pkeybd. */
-
- pkeybd->right_shift = ((ax & 0x01) != 0);
- pkeybd->left_shift = ((ax & 0x02) != 0);
- pkeybd->ctrl_shift = ((ax & 0x04) != 0);
- pkeybd->alt_shift = ((ax & 0x08) != 0);
- pkeybd->scroll_state = ((ax & 0x10) != 0);
- pkeybd->num_state = ((ax & 0x20) != 0);
- pkeybd->caps_state = ((ax & 0x40) != 0);
- pkeybd->ins_state = ((ax & 0x80) != 0);
-
- return utlobyte(ax);
- }