45 lines
1000 B
C
45 lines
1000 B
C
#include <stdio.h>
|
|
#include "../hal/keyboard/keyboard.h"
|
|
|
|
uint8 inportb (uint16 _port) {
|
|
uint8 rv;
|
|
__asm__ __volatile__ ("inb %1, %0" : "=a" (rv) : "dN" (_port));
|
|
return rv;
|
|
}
|
|
|
|
Key ReadKey()
|
|
{
|
|
Key key;
|
|
|
|
do {
|
|
KeyboardLastScancode = 0xFF ;
|
|
while (KeyboardLastScancode == 0xFF) ;
|
|
|
|
key.Scancode = KeyboardLastScancode;
|
|
|
|
} while (KeyboardLastStatus & 1);
|
|
|
|
if (KeyboardGetKeyStatus(KeyboardKeyLeftShift) || KeyboardGetKeyStatus(KeyboardKeyRightShift))
|
|
key.Character = KeyboardMapShift[key.Scancode];
|
|
else key.Character = KeyboardMap[key.Scancode];
|
|
|
|
return key;
|
|
}
|
|
|
|
KeyEvent ReadKeyEvent()
|
|
{
|
|
KeyEvent key;
|
|
|
|
KeyboardLastScancode = 0xFF ;
|
|
while (KeyboardLastScancode == 0xFF) ;
|
|
|
|
key.Scancode = KeyboardLastScancode;
|
|
key.Pressed = 1 - (KeyboardLastStatus & 1);
|
|
|
|
if (KeyboardGetKeyStatus(KeyboardKeyLeftShift) || KeyboardGetKeyStatus(KeyboardKeyRightShift))
|
|
key.Character = KeyboardMapShift[key.Scancode];
|
|
else key.Character = KeyboardMap[key.Scancode];
|
|
|
|
return key;
|
|
}
|