_________
¦bioskey_ Keyboard interface. _
_________ _
_
Syntax: _
int bioskey(int cmd); _
_
Prototype in: _
bios.h _
_
Remarks: _
bioskey performs various keyboard operations using BIOS interrupt 0x16. _
_
The parameter cmd determines the exact operation. _
_
Return Value: _
The value returned by bioskey depends on the task it performs, determined by _
the value of cmd: _
cmd ¦
Value ¦ Description
--------+-------------------------------------------------------------
0 ¦ If the lower 8 bits are nonzero, bioskey returns the ASCII
¦ character for the next keystroke waiting in the queue or the
¦ next key pressed at the keyboard.
¦ If the lower 8 bits are zero, the upper 8 bits are the extended
¦ keyboard codes defined in the IBM PC Technical Reference manual.
1 ¦ Tests whether a keystroke is available to be read.
¦ A return value of zero means no key is available.
¦ The return value is 0xFFFFF (-1) if Ctrl-Brk has been pressed.
¦ Otherwise, the value of the next keystroke is returned.
¦ The keystroke itself is kept to be returned by the next call to
¦ bioskey that has a cmd value of zero.
2 ¦ Requests the current shift key status.
The shift key status is obtained by ORing the following values together:
First ¦ Second ¦ Shift Key
Value ¦ Value ¦ Status
---------+--------+---------------------
Bit 7 ¦ 0x80 ¦ Insert on
Bit 6 ¦ 0x40 ¦ Caps on
Bit 5 ¦ 0x20 ¦ Num Lock on
Bit 4 ¦ 0x10 ¦ Scroll Lock on
Bit 3 ¦ 0x08 ¦ Alt pressed
Bit 2 ¦ 0x04 ¦ Ctrl pressed
Bit 1 ¦ 0x02 ¦ Left Shift pressed
Bit 0 ¦ 0x01 ¦ Right Shift pressed
Portability:
bioskey works with IBM PCs and compatibles only.
Example:
Code:
#include <stdio.h>
#include <bios.h>
#include <ctype.h>
#define RIGHT 0x01
#define LEFT 0x02
#define CTRL 0x04
#define ALT 0x08
int main(void)
{
int key, modifiers;
/* function 1 returns 0 until a key is pressed */
while (bioskey(1) == 0);
/* function 0 returns the key that is waiting */
key = bioskey(0);
/* use function 2 to determine if shift keys were used */
modifiers = bioskey(2);
if (modifiers)
{
printf("[");
if (modifiers & RIGHT) printf("RIGHT");
if (modifiers & LEFT) printf("LEFT");
if (modifiers & CTRL) printf("CTRL");
if (modifiers & ALT) printf("ALT");
printf("]");
}
/* print out the character read */
if (isalnum(key & 0xFF))
printf("'%c\n", key);
else
printf("%#02x\n", key);
return 0;
}
poz.
PS. ako te zanima mogu da postujem jedan primer koji sam ja pisao.