www.delorie.com/djgpp/doc/libc/libc_65.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

_bios_keybrd

Syntax

 
#include <bios.h>

unsigned _bios_keybrd(unsigned cmd);

Description

The _bios_keybrd function uses INT 0x16 to access the keyboard services. The cmd argument can be any of the following manifest constants:

_KEYBRD_READ
read the next key pressed.

_NKEYBRD_READ
read the next extended key pressed. Unlike _KEYBRD_READ, this command knows about keys introduced with the AT-style 101-key keyboards, such as F11 and F12, and can distinguish between the editing keys on the numeric pad and the grey keys of the edit pad. On the other hand, some of the extended keys return two-byte sequences which typically begin with the E0h (224 decimal) prefix, so code that uses _NKEYBRD_READ should deal with this complexity.

_KEYBRD_READY
check if a key is waiting in the keyboard buffer.

_NKEYBRD_READY
check if an extended key is waiting in the keyboard buffer. Like _KEYBRD_READY, but recognizes extended keys such as F12, which _KEYBRD_READY ignores.

_KEYBRD_SHIFTSTATUS
read keyboard shift state (the byte at the address 40h:17h in the BIOS data area):

 
7654 3210  Meaning
---- ---X  Right SHIFT is pressed
---- --X-  Left SHIFT is pressed
---- -X--  CTRL is pressed
---- X---  ALT is pressed
---X ----  Scroll Lock locked
--X- ----  Num Lock locked
-X-- ----  Caps Lock locked
X--- ----  Insert locked

_NKEYBRD_SHIFTSTATUS
read keyboard shift and extended shift state (the byte at the address 40h:17h in the BIOS data area combined with the extended shift flags from the bytes at addresses 40h:18h and 40h:96h):

 
FEDC BA98  7654 3210  Meaning
---- ----  ---- ---X  Right SHIFT is pressed
---- ----  ---- --X-  Left SHIFT is pressed
---- ----  ---- -X--  CTRL is pressed
---- ----  ---- X---  ALT is pressed
---- ----  ---X ----  Scroll Lock locked
---- ----  --X- ----  Num Lock locked
---- ----  -X-- ----  Caps Lock locked
---- ----  X--- ----  Insert locked

---- ---X  ---- ----  Left CTRL is pressed
---- --X-  ---- ----  Left ALT is pressed
---- -X--  ---- ----  Right CTRL is pressed
---- X---  ---- ----  Right ALT is pressed
---X ----  ---- ----  Scroll Lock is pressed
--X- ----  ---- ----  Num Lock is pressed
-X-- ----  ---- ----  Caps Lock is pressed
X--- ----  ---- ----  SysReq is pressed

Return Value

With the *_READ and *_SHIFTSTATUS arguments, the _bios_keybrd function returns the contents of the AX register after the BIOS call. For the *_READ arguments, this is the combination of scan code and ASCII code for alphanumeric keys, or a scan code and either zero or the E0h prefix for special keys.

With the *_READY arguments, _bios_keybrd returns 0 if no key is waiting in the BIOS keyboard buffer. If there is a key, _bios_keybrd returns the key waiting to be read (that is, the same value as the corresponding *_READ would return).

With the *_READ and *_READY arguments, the _bios_keybrd function returns -1 if Ctrl+BREAK has been pressed and is the next keystroke to be read.

Portability

ANSI/ISO C No
POSIX No

Example

 
while( !_bios_keybrd(_KEYBRD_READY) )
  try_to_do_something();


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2004   by DJ Delorie     Updated Apr 2004