搜尋此網誌
2012年8月22日 星期三
BIOS - KEYBOARD(Check/Get Keystroke, Get Shift Flags)
/*******************************************/
KEYBOARD - GET KEYSTROKE
Input:
AH = 00h
INT 16h
Return:
AH = BIOS scan code
AL = ASCII character
/*******************************************/
KEYBOARD - CHECK FOR KEYSTROKE
Input:
AH = 01h
INT 16h
Return:
ZF set if no keystroke available
ZF clear if keystroke available
AH = BIOS scan code
AL = ASCII character
/*******************************************/
KEYBOARD - GET SHIFT FLAGS
Input:
AH = 02h
INT 16h
Return:
AL = shift flags
Bitfields for keyboard shift flags:
Bit(s) Description
7 Insert active
6 CapsLock active
5 NumLock active
4 ScrollLock active
3 Alt key pressed (either Alt on 101/102-key keyboards)
2 Ctrl key pressed (either Ctrl on 101/102-key keyboards)
1 left shift key pressed
0 right shift key pressed
/*******************************************/
Example:
typedef struct _Key_Info{
u8 ScanCode;
u8 ASCiiCode;
u8 StatusCode;
u8 Reserved;
} Key_Info;
u8 wait_for_input(Key_Info *pKeyInfo)
{
u8 Scan = 0;
u8 ASCii = 0;
u8 Status = 0;
u8 key_press = 0;
__asm {
pusha
mov bl, 0x00
clearbuf:
mov ah, 0x01
int 16h
jz exit1
mov ah, 0x00
int 16h
mov Scan, ah
mov ASCii, al
mov ah, 0x02
int 16h
mov Status, al
mov bl, 0x01
jmp clearbuf
exit1:
mov key_press, bl
popa
}
pKeyInfo->ScanCode = Scan;
pKeyInfo->ASCiiCode = ASCii;
pKeyInfo->StatusCode = Status;
return key_press;
}
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言