[comp.os.msdos.programmer] Output from F11 & F12 Keys

u-mwong%peruvian.utah.edu@cs.utah.edu (Michael Wong) (05/04/91)

    Hi...I'm trying to get the character codes from the F11 and F12 keys
(normal/shift/alt/control) but seem to have no luck.  Nothing seems to
come out when I read a keypress from them.  Do I have to do something
in order to "enable" these keys?  If so, how do I do it in C?  I'd appreciate
any responses to my query...

-Mike
----------
Michael Wong 
u-mwong@peruvian.utah.edu
University of Utah

tep@engr.uark.edu (Tim Peoples) (05/15/91)

u-mwong%peruvian.utah.edu@cs.utah.edu (Michael Wong) writes:


>    Hi...I'm trying to get the character codes from the F11 and F12 keys
>(normal/shift/alt/control) but seem to have no luck.  Nothing seems to
>come out when I read a keypress from them.  Do I have to do something
>in order to "enable" these keys?  If so, how do I do it in C?  I'd appreciate
>any responses to my query...
>
	If you are getting no response from the F11 and F12 keys it could
be either of two problems.  

	1.  It is possible that your BIOS does not support the
	extended keyboard.  If so, you need a new one ( BIOS
	that is ).

	2.  In order to access the keys in question you need
	to make a call to int 16h functions 11h and 10h in
	that order.  The call to f11h is to see if there is
	anything in the buffer ( Zflag set if buffer empty ).
	The call to f10h is to remove that key from the buffer.
	( f11h does not clear the keyboard buffer and f10h waits
	until a key is pressed before returning )

Try this:  ( TC2.0 or TC++ )

---------------------------------------------------------------------------- 
#include <dos.h>   /* for both routines */ 

int xkbhit( void )  /* Returns zero if buffer empty, one otherwise */ 
{
    union REGS regs;

    regs.h.ah = 0x11;
    int86( 0x16, &regs, &regs );
    if ( regs.x.flags & 0x0080 ) return 0;
    return 1;
}

int xgetch( void )
{
    union REGS regs;

    regs.h.ah = 0x10;
    int86( 0x16, &regs, &regs );
    return regs.x.ax;   /* Scan code in high byte, char in low byte */ 
}

---------------------------------------------------------------------------

	If this doesn't work, better check your BIOS date.

Hope this helps.     Tim -   ;-)