home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!cs.utexas.edu!convex!egsner!adaptex!sdf!mkhan
- From: mkhan@sdf.lonestar.org (Muhammad Khan)
- Subject: Re: Telling if the SHIFT key is down.
- Message-ID: <C1CLpG.2HL@sdf.lonestar.org>
- Organization: sdf public access Unix, Dallas -- 214-436-3281
- References: <00966E8E.9CED30C0@Msu.oscs.montana.edu>
- Date: Sun, 24 Jan 1993 07:48:52 GMT
- Lines: 36
-
-
- he he he....
- This was one of my surprises when I played a pinball game on a PC.
- Hitting the left SHIFT would move the left bat and right SHIFT the
- right bat. Actually PC BIOS gives this info. Interrupt 16, service
- 2. Following is a short program to detect left/right shift key presses.
- This is for Microsoft C, find appropriate subst. for _REGS, _int86 in
- Borland.
-
- #include <stdio.h>
- #include <dos.h>
-
- main()
- {
- union _REGS inregs, outregs;
- char LEFT_SHIFT=2, RIGHT_SHIFT=1;
-
- while (1) { //infinite loop, change this as you like
- inregs.h.ah=2; //request shift status
- _int86(0x16, &inregs, &outregs); //BIOS service 16H
-
- if (outregs.h.al & LEFT_SHIFT) //left shift pressed
- printf("Left shift pressed.\n");
- else if (outregs.h.al & RIGHT_SHIFT) //right shift pressed
- printf("Right shift pressed.\n");
-
- }
-
-
- }
-
- ===========================================================================
- signed amjad;
- Muhammad Amjad Khan
- mkhan@sdf.lonestar.org
-
-