This commit is contained in:
2021-09-14 18:46:50 +03:00
parent d605c6a016
commit b6ddeca1c3
180 changed files with 5909 additions and 2039 deletions

View File

@@ -0,0 +1,16 @@
@echo off
rem NASM and DJGPP executable paths:
set nasm_path=C:\nasm
set djgpp_path=C:\mingw\bin
set objpath=../../objects
set incpath=../../include
@echo on
%djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o %objpath%/drivers/keyboard.o keyboard.c
@echo off
@echo .
@echo Done!
@pause

View File

@@ -0,0 +1,135 @@
*0x00 Pause/Break
0x01 F9
0x02 F7
0x03 F5
0x04 F3
0x05 F1
0x06 F2
0x07 F12
0x08 Print Screen
0x09 F10
0x0A F8
0x0B F6
0x0C F4
0x0D Tab
0x0E `~
0x0F
0x10
0x11
0x12
0x13
0x14
0x15 Q
0x16 1!
0x17
0x18
0x19
0x1A Z
0x1B S
0x1C A
0x1D W
0x1E 2@
0x1F LeftWin
0x20
0x21 C
0x22 X
0x23 D
0x24 E
0x25 4$
0x26 3#
0x27 RightWin
0x28
0x29 Space
0x2A V
0x2B F
0x2C T
0x2D R
0x2E 5%
0x2F Menu
0x30
0x31 N
0x32 B
0x33 H
0x34 G
0x35 Y
0x36 6^
0x37
0x38
0x39
0x3A M
0x3B J
0x3C U
0x3D 7&
0x3E 8*
0x3F
0x40
0x41 ,<
0x42 K
0x43 I
0x44 O
0x45 0)
0x46 9(
0x47
0x48
0x49 .>
0x4A /?
0x4B L
0x4C ;:
0x4D P
0x4E -_
0x4F
0x50
0x51
0x52 '"
0x53
0x54 [{
0x55 =+
0x56
0x57
0x58
0x59 Numpad Enter
0x5A Enter
0x5B ]}
0x5C
0x5D \|
0x5E End
0x5F Left
0x60 Home
0x61 Insert
0x62 Delete
0x63 Down
0x64 Right
0x65 Up
0x66 Backspace
0x67 PageDown
0x68 PageUp
0x69 Numpad 1 (end)
0x6A Numpad /
0x6B Numpad 4 (left)
0x6C Numpad 7 (Home)
0x6D
0x6E
0x6F
0x70 Numpad 0 (insert)
0x71 Numpad . (del)
0x72 Numpad 2 (down)
0x73 Numpad 5
0x74 Numpad 6 (right)
0x75 Numpad 8 (up)
0x76 Esc
0x77
0x78 F11
0x79 Numpad +
0x7A Numpad 3 (pgdwn)
0x7B Numpad -
0x7C Numpad *
0x7D Numpad 9 (pgup)
0x7E
0x7F

View File

@@ -0,0 +1,306 @@
#include <system.h>
#include <drivers/keyboard.h>
const char KeyMap[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\t', '`', 0,
0, 0, 0, 0, 0, 'q', '1', 0, 0, 0, 'z', 's', 'a', 'w', '2', 0,
0, 'c', 'x', 'd', 'e', '4', '3', 0, 0, ' ', 'v', 'f', 't', 'r', '5', 0,
0, 'n', 'b', 'h', 'g', 'y', '6', 0, 0, 0, 'm', 'j', 'u', '7', '8', 0,
0, ',', 'k', 'i', 'o', '0', '9', 0, 0, '.', '/', 'l', ';', 'p', '-', 0,
0, 0, '\'', 0, '[', '=', 0, 0, 0, '\n', '\n', ']', 0, '\\', 0, 0,
0, 0, 0x7F, 0, 0, 0, '\b', 0, 0, '1', '/', '4', '7', 0, 0, 0,
'0', '.', '2', '5', '6', '8', 0, 0, 0, '+', '3', '-', '*', '9', 0, 0
};
const char KeyMapShift[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\t', '~', 0,
0, 0, 0, 0, 0, 'Q', '!', 0, 0, 0, 'Z', 'S', 'A', 'W', '@', 0,
0, 'C', 'X', 'D', 'E', '$', '#', 0, 0, ' ', 'V', 'F', 'T', 'R', '%', 0,
0, 'N', 'B', 'H', 'G', 'Y', '^', 0, 0, 0, 'M', 'J', 'U', '&', '*', 0,
0, '<', 'K', 'I', 'O', ')', '(', 0, 0, '>', '?', 'L', ':', 'P', '_', 0,
0, 0, '\"', 0, '{', '+', 0, 0, 0, '\n', '\n', '}', 0, '|', 0, 0,
0, 0, 0x7F, 0, 0, 0, '\b', 0, 0, '1', '/', '4', '7', 0, 0, 0,
'0', '.', '2', '5', '6', '8', 0, 0, 0, '+', '3', '-', '*', '9', 0, 0
};
volatile unsigned char KeyArray[16];
volatile unsigned char KeyboardNewData;
volatile unsigned char KeyModifierStatus;
volatile unsigned char KeyScancodePrefix;
volatile unsigned char KeyLightsStatus;
unsigned char KeyboardScancodeSet;
void KeyboardSetKey(unsigned char scancode, unsigned char val)
{
unsigned char pos = scancode/8;
unsigned char offset = scancode%8;
if (val) {
KeyArray[pos] |= 1<<offset;
KeyboardNewData = scancode;
}
else KeyArray[pos] &= 0xFF - (1<<offset);
}
unsigned char KeyIsPressed(unsigned char scancode)
{
unsigned char pos = scancode/8;
unsigned char offset = scancode%8;
return (KeyArray[pos]&(1<<offset));
}
void i86_KeyboardHandler(ISR_stack_regs *r) {
unsigned char scancode = inportb(0x60);
switch (scancode) {
case 0x00: // Error 0x00
case 0xFC: // Diagnostics failed (MF kb)
case 0xFD: // Diagnostics failed (AT kb)
case 0xFF: KeyboardWaitInput(); outportb(0x60, 0xF4); // Error 0xFF
break;
case 0xAA: // BAT test successful.
case 0xFA: // ACKnowledge
case 0xFE: // Last command invalid or parity error
case 0xEE: break; // Echo response
// Gray or break
case 0xE0: KeyScancodePrefix |= 1; break;
case 0xE1: KeyScancodePrefix |= 4; break;
case 0xF0: KeyScancodePrefix |= 2; break;
// Alt, ctrl...
case 0x11: if ((KeyScancodePrefix&1) == 0) { // Left alt
if ((KeyScancodePrefix&2) == 0) KeyModifierStatus |= 1<<2;
else KeyModifierStatus &= 0xFF - (1<<2);
}
else { // Right alt
if ((KeyScancodePrefix&2) == 0) KeyModifierStatus |= 1<<3;
else KeyModifierStatus &= 0xFF - (1<<3);
}
KeyScancodePrefix = 0; break;
case 0x12: if ((KeyScancodePrefix&1) == 0) { // Left shift
if ((KeyScancodePrefix&2) == 0) KeyModifierStatus |= 1<<0;
else KeyModifierStatus &= 0xFF - (1<<0);
}
else { // Fake shift
if ((KeyScancodePrefix&2) == 0) KeyModifierStatus |= 1<<6;
else KeyModifierStatus &= 0xFF - (1<<6);
}
KeyScancodePrefix = 0; break;
case 0x14: if (KeyScancodePrefix&4) { // Pause/break
if ((KeyScancodePrefix&2) == 0) KeyboardSetKey (0, 1);
else KeyboardSetKey (0, 0);
KeyScancodePrefix |= 8; break;
}
else if ((KeyScancodePrefix&1) == 0) { // Left ctrl
if ((KeyScancodePrefix&2) == 0) KeyModifierStatus |= 1<<4;
else KeyModifierStatus &= 0xFF - (1<<4);
}
else { // Right ctrl
if ((KeyScancodePrefix&2) == 0) KeyModifierStatus |= 1<<5;
else KeyModifierStatus &= 0xFF - (1<<5);
}
KeyScancodePrefix = 0; break;
case 0x59: // Right shift
if ((KeyScancodePrefix&2) == 0) KeyModifierStatus |= 1<<1;
else KeyModifierStatus &= 0xFF - (1<<1);
KeyScancodePrefix = 0; break;
// LEDs
case 0x58: if ((KeyScancodePrefix&2) == 0) {
KeyLightsStatus ^= 4; KeyboardSetLEDs(KeyLightsStatus);
} KeyScancodePrefix = 0; break; // Caps
case 0x77:
if ((KeyScancodePrefix&4) && (KeyScancodePrefix&8)) KeyScancodePrefix=0;
else if ((KeyScancodePrefix&2) == 0) {
KeyLightsStatus ^= 2; KeyboardSetLEDs(KeyLightsStatus);
} KeyScancodePrefix = 0; break; // Num
case 0x7E: if ((KeyScancodePrefix&2) == 0) {
KeyLightsStatus ^= 1; KeyboardSetLEDs(KeyLightsStatus);
} KeyScancodePrefix = 0; break; // Scroll
case 0x83: scancode = 0x02; // Put F7 under the 0x80 (128bit) barrier
default:
// Remap gray keys
if (KeyScancodePrefix&1) switch (scancode) {
case 0x7C: scancode=0x08; break; // PrintScreen
case 0x4A: scancode=0x6A; break; // Numpad /
case 0x5A: scancode=0x59; break; // Numpad Enter
case 0x69: scancode=0x5E; break; // End
case 0x6B: scancode=0x5F; break; // Left
case 0x6C: scancode=0x60; break; // Home
case 0x70: scancode=0x61; break; // Insert
case 0x71: scancode=0x62; break; // Delete
case 0x72: scancode=0x63; break; // Down
case 0x74: scancode=0x64; break; // Right
case 0x75: scancode=0x65; break; // Up
case 0x7A: scancode=0x67; break; // PageDown
case 0x7D: scancode=0x68; break; // PageUp
}
if ((KeyScancodePrefix&2) == 0) KeyboardSetKey(scancode, 1);
else KeyboardSetKey(scancode, 0);
KeyScancodePrefix = 0; break;
}
}
KeyboardKey GetKey()
{
KeyboardKey ret;
KeyboardNewData = 0xFF;
while (KeyboardNewData==0xFF); // wait for keypress
ret.Scancode = KeyboardNewData; // Send scancode for non-chars
ret.ModifierStatus = KeyModifierStatus; // Shift, ctrl... state
ret.Lights = KeyLightsStatus; // Num, caps.... state
if ((ret.ModifierStatus & 1) || (ret.ModifierStatus & 2)) // Shift is on
ret.Character = KeyMapShift[ret.Scancode];
else ret.Character = KeyMap[ret.Scancode]; // Shift is off
return ret; // And send it.
}
/***************************************
* Set repeat rate/delay *
***************************************
Values for inter-character delay (bits 4-0)
(characters per second; default is 10.9)
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
----+----+----+----+----+----+----+----+----
0 |30.0|26.7|24.0|21.8|20.0|18.5|17.1|16.0
8 |15.0|13.3|12.0|10.9|10.0|9.2 |8.6 |8.0
16 |7.5 |6.7 |6.0 |5.5 |5.0 |4.6 |4.3 |4.0
24 |3.7 |3.3 |3.0 |2.7 |2.5 |2.3 |2.1 |2.0
Values for delay:
(miliseconds; default is 500)
0 | 1 | 2 | 3
-----+-----+-----+-----
250 | 500 | 750 | 1000
***************************************/
void KeyboardSetRepeatRate(unsigned char rate, unsigned char delay)
{
if (rate>3 || delay>31) return;
unsigned char out = rate<<5 | delay;
while ((inportb(0x64)&2) != 0);
outportb(0x60, 0xF3);
while ((inportb(0x64)&2) != 0);
outportb(0x60, out);
}
/***************************************
* Set keyboard LEDs *
***************************************
+-----------+-------+-------+--------+
| Bits 7-3 | Bit 2 | Bit 1 | Bit 0 |
| 0 | Caps | Num | Scroll |
|(reserved) | lock | lock | lock |
+-----------+-------+-------+--------+
***************************************/
void KeyboardSetLEDs(unsigned char status)
{
while ((inportb (0x64)&2)!=0);
outportb (0x60, 0xED);
while ((inportb (0x64)&2)!=0);
outportb (0x60, status);
}
/***************************************
* Set scancode set *
***************************************
0 Get current scancode set
1 Set to scancode set 1
2 Set to scancode set 2
3 Set to scancode set 3
***************************************/
void KeyboardSetScancodeSet(unsigned char set)
{
if (set>3) return;
while ((inportb (0x64)&2)!=0);
outportb (0x60, 0xF0);
while ((inportb (0x64)&2)!=0);
outportb (0x60, set);
KeyboardScancodeSet = set;
}
/*unsigned char i86_kb_get_scancodeset() {
return KeyboardScancodeSet;
}*/
void KeyboardWaitInput()
{
int fail_safe=200000;
while ((inportb(0x64)&2)!=0 && fail_safe>0) fail_safe--;
}
void KeyboardWaitOutput()
{
int fail_safe=200000;
while ((inportb(0x64)&1)==0 && fail_safe>0) fail_safe--;
}
void KeyboardInstallA()
{
KeyboardWaitInput(); outportb(0x60, 0xFF); // Reset kb
// Initialize variables
KeyboardNewData = 0;
KeyModifierStatus = 0;
KeyScancodePrefix = 0;
KeyLightsStatus = 0;
KeyboardScancodeSet = 0;
memset((void*)KeyArray, 0, 16);
}
void KeyboardInstallB()
{
// Wait for BAT test results
unsigned char temp;
do temp = inportb(0x60);
while (temp!=0xAA && temp!=0xFC);
// Error
if (temp == 0xFC) return;
// Set new repeat rate
KeyboardSetRepeatRate(1, 11);
// Set scancode set 2
KeyboardSetScancodeSet(2); // Set new scancode set
KeyboardWaitInput();
outportb(0x64, 0x20); // Get "Command unsigned char"
do { temp = inportb(0x60);
} while (temp==0xFA || temp==0xAA);
temp &= 0xFF - (1<<6); // Set bit6 to 0: disable conversion
KeyboardWaitInput(); outportb(0x64, 0x60); // Function to write cmd unsigned char
KeyboardWaitInput(); outportb(0x60, temp); // Send it
}

View File

@@ -0,0 +1,135 @@
#define KB_KEY_LSHIFT 0x81 // 1000 0001
#define KB_KEY_RSHIFT 0X82 // 1000 0010
#define KB_KEY_LALT 0X84 // 1000 0100
#define KB_KEY_RALT 0x88 // 1000 1000
#define KB_KEY_LCTRL 0x90 // 1001 0000
#define KB_KEY_RCTRL 0xA0 // 1010 0000
#define KB_KEY_FSHIFT 0xC0 // 1100 0000
extern volatile unsigned char KeyModifierStatus;
#define KB_PREFIX_GRAY 0x01 // Gray
#define KB_PREFIX_BREAK 0x02 // Break code
#define KB_PREFIX_PAUSE 0x04 // Pause/break key
#define KB_PREFIX_PAUSE1 0x08 // Recieved first unsigned char from pause/break
extern volatile unsigned char KeyScancodePrefix;
#define KB_KEY_SCROLL 0xF1 // 1111 0001
#define KB_KEY_NUM 0xF2 // 1111 0010
#define KB_KEY_CAPS 0xF4 // 1111 0100
extern volatile unsigned char KeyLightsStatus;
extern unsigned char KeyboardScancodeSet;
enum KeyboardKeys {
KeyboardKeyPAUSE = 0x00,
KeyboardKeyF9 = 0x01,
KeyboardKeyF7 = 0x02,
KeyboardKeyF5 = 0X03,
KeyboardKeyF3 = 0x04,
KeyboardKeyF1 = 0x05,
KeyboardKeyF2 = 0x06,
KeyboardKeyF12 = 0x07,
KeyboardKeyPRINTSCRN = 0x08,
KeyboardKeyF10 = 0x09,
KeyboardKeyF8 = 0x0A,
KeyboardKeyF6 = 0x0B,
KeyboardKeyF4 = 0x0C,
KeyboardKeyTAB = 0x0D,
KeyboardKeyTILDA = 0x0E,
KeyboardKeyQ = 0x15,
KeyboardKey1 = 0x16,
KeyboardKeyZ = 0x1A,
KeyboardKeyS = 0x1B,
KeyboardKeyA = 0x1C,
KeyboardKeyW = 0x1D,
KeyboardKey2 = 0x1E,
KeyboardKeyLWIN = 0x1F,
KeyboardKeyC = 0x21,
KeyboardKeyX = 0x22,
KeyboardKeyD = 0x23,
KeyboardKeyE = 0x24,
KeyboardKey4 = 0x25,
KeyboardKey3 = 0x26,
KeyboardKeyRWIN = 0x27,
KeyboardKeySPACE = 0x29,
KeyboardKeyV = 0x2A,
KeyboardKeyF = 0x2B,
KeyboardKeyT = 0x2C,
KeyboardKeyR = 0x2D,
KeyboardKey5 = 0x2E,
KeyboardKeyMENU = 0x2F,
KeyboardKeyN = 0x31,
KeyboardKeyB = 0x32,
KeyboardKeyH = 0x33,
KeyboardKeyG = 0x34,
KeyboardKeyY = 0x35,
KeyboardKey6 = 0x36,
KeyboardKeyM = 0x3A,
KeyboardKeyJ = 0x3B,
KeyboardKeyU = 0x3C,
KeyboardKey7 = 0x3D,
KeyboardKey8 = 0x3E,
KeyboardKeyCOMMA = 0x41,
KeyboardKeyK = 0x42,
KeyboardKeyI = 0x43,
KeyboardKeyO = 0x44,
KeyboardKey0 = 0x45,
KeyboardKey9 = 0x46,
KeyboardKeyPERIOD = 0x49,
KeyboardKeySLASH = 0x4A,
KeyboardKeyL = 0x4B,
KeyboardKeySEMICOLON = 0x4C,
KeyboardKeyP = 0x4D,
KeyboardKeyDASH = 0x4E,
KeyboardKeyAPOSTROPHE = 0x52,
KeyboardKeyLBRACKET = 0x54,
KeyboardKeyEQUAL = 0x55,
KeyboardKeyNUMPAD_ENTER = 0x59,
KeyboardKeyENTER = 0x5A,
KeyboardKeyRBRACKET = 0x5B,
KeyboardKeyBACKSLASH = 0x5D,
KeyboardKeyEND = 0x5E,
KeyboardKeyLEFT = 0x5F,
KeyboardKeyHOME = 0x60,
KeyboardKeyINSERT = 0x61,
KeyboardKeyDELETE = 0x62,
KeyboardKeyDOWN = 0x63,
KeyboardKeyRIGHT = 0x64,
KeyboardKeyUP = 0x65,
KeyboardKeyBACKSPACE = 0x66,
KeyboardKeyPGDOWN = 0x67,
KeyboardKeyPGUP = 0x68,
KeyboardKeyNUMPAD_1 = 0x69,
KeyboardKeyNUMPAD_SLASH = 0x6A,
KeyboardKeyNUMPAD_4 = 0x6B,
KeyboardKeyNUMPAD_7 = 0x6C,
KeyboardKeyNUMPAD_0 = 0x70,
KeyboardKeyNUMPAD_COLON = 0x71,
KeyboardKeyNUMPAD_2 = 0x72,
KeyboardKeyNUMPAD_5 = 0x73,
KeyboardKeyNUMPAD_6 = 0x74,
KeyboardKeyNUMPAD_8 = 0x75,
KeyboardKeyESC = 0x76,
KeyboardKeyF11 = 0x78,
KeyboardKeyNUMPAD_PLUS = 0x79,
KeyboardKeyNUMPAD_3 = 0x7A,
KeyboardKeyNUMPAD_MINUS = 0x7B,
KeyboardKeyNUMPAD_ASTERISK = 0x7C,
KeyboardKeyNUMPAD_9 = 0x7D
};
typedef struct {
unsigned char status;
unsigned char lights;
unsigned char scancode;
unsigned char character;
} kb_key;
extern char getch();
extern kb_key get_key();
extern char scancode_to_ascii(unsigned char scancode);
extern unsigned char get_key_status(unsigned char scancode);
extern void kb_set_repeat(float rate, int delay);
extern void kb_set_LEDs(unsigned char status);

View File

@@ -0,0 +1,135 @@
#define KB_KEY_LSHIFT 0x81 // 1000 0001
#define KB_KEY_RSHIFT 0X82 // 1000 0010
#define KB_KEY_LALT 0X84 // 1000 0100
#define KB_KEY_RALT 0x88 // 1000 1000
#define KB_KEY_LCTRL 0x90 // 1001 0000
#define KB_KEY_RCTRL 0xA0 // 1010 0000
#define KB_KEY_FSHIFT 0xC0 // 1100 0000
extern volatile unsigned char KeyModifierStatus;
#define KB_PREFIX_GRAY 0x01 // Gray
#define KB_PREFIX_BREAK 0x02 // Break code
#define KB_PREFIX_PAUSE 0x04 // Pause/break key
#define KB_PREFIX_PAUSE1 0x08 // Recieved first unsigned char from pause/break
extern volatile unsigned char KeyScancodePrefix;
#define KB_KEY_SCROLL 0xF1 // 1111 0001
#define KB_KEY_NUM 0xF2 // 1111 0010
#define KB_KEY_CAPS 0xF4 // 1111 0100
extern volatile unsigned char KeyLightsStatus;
extern unsigned char KeyboardScancodeSet;
enum KB_KEYS {
KB_KEY_PAUSE = 0x00,
KB_KEY_F9 = 0x01,
KB_KEY_F7 = 0x02,
KB_KEY_F5 = 0X03,
KB_KEY_F3 = 0x04,
KB_KEY_F1 = 0x05,
KB_KEY_F2 = 0x06,
KB_KEY_F12 = 0x07,
KB_KEY_PRINTSCRN = 0x08,
KB_KEY_F10 = 0x09,
KB_KEY_F8 = 0x0A,
KB_KEY_F6 = 0x0B,
KB_KEY_F4 = 0x0C,
KB_KEY_TAB = 0x0D,
KB_KEY_TILDA = 0x0E,
KB_KEY_Q = 0x15,
KB_KEY_1 = 0x16,
KB_KEY_Z = 0x1A,
KB_KEY_S = 0x1B,
KB_KEY_A = 0x1C,
KB_KEY_W = 0x1D,
KB_KEY_2 = 0x1E,
KB_KEY_LWIN = 0x1F,
KB_KEY_C = 0x21,
KB_KEY_X = 0x22,
KB_KEY_D = 0x23,
KB_KEY_E = 0x24,
KB_KEY_4 = 0x25,
KB_KEY_3 = 0x26,
KB_KEY_RWIN = 0x27,
KB_KEY_SPACE = 0x29,
KB_KEY_V = 0x2A,
KB_KEY_F = 0x2B,
KB_KEY_T = 0x2C,
KB_KEY_R = 0x2D,
KB_KEY_5 = 0x2E,
KB_KEY_MENU = 0x2F,
KB_KEY_N = 0x31,
KB_KEY_B = 0x32,
KB_KEY_H = 0x33,
KB_KEY_G = 0x34,
KB_KEY_Y = 0x35,
KB_KEY_6 = 0x36,
KB_KEY_M = 0x3A,
KB_KEY_J = 0x3B,
KB_KEY_U = 0x3C,
KB_KEY_7 = 0x3D,
KB_KEY_8 = 0x3E,
KB_KEY_COMMA = 0x41,
KB_KEY_K = 0x42,
KB_KEY_I = 0x43,
KB_KEY_O = 0x44,
KB_KEY_0 = 0x45,
KB_KEY_9 = 0x46,
KB_KEY_PERIOD = 0x49,
KB_KEY_SLASH = 0x4A,
KB_KEY_L = 0x4B,
KB_KEY_SEMICOLON = 0x4C,
KB_KEY_P = 0x4D,
KB_KEY_DASH = 0x4E,
KB_KEY_APOSTROPHE = 0x52,
KB_KEY_LBRACKET = 0x54,
KB_KEY_EQUAL = 0x55,
KB_KEY_NUMPAD_ENTER = 0x59,
KB_KEY_ENTER = 0x5A,
KB_KEY_RBRACKET = 0x5B,
KB_KEY_BACKSLASH = 0x5D,
KB_KEY_END = 0x5E,
KB_KEY_LEFT = 0x5F,
KB_KEY_HOME = 0x60,
KB_KEY_INSERT = 0x61,
KB_KEY_DELETE = 0x62,
KB_KEY_DOWN = 0x63,
KB_KEY_RIGHT = 0x64,
KB_KEY_UP = 0x65,
KB_KEY_BACKSPACE = 0x66,
KB_KEY_PGDOWN = 0x67,
KB_KEY_PGUP = 0x68,
KB_KEY_NUMPAD_1 = 0x69,
KB_KEY_NUMPAD_SLASH = 0x6A,
KB_KEY_NUMPAD_4 = 0x6B,
KB_KEY_NUMPAD_7 = 0x6C,
KB_KEY_NUMPAD_0 = 0x70,
KB_KEY_NUMPAD_COLON = 0x71,
KB_KEY_NUMPAD_2 = 0x72,
KB_KEY_NUMPAD_5 = 0x73,
KB_KEY_NUMPAD_6 = 0x74,
KB_KEY_NUMPAD_8 = 0x75,
KB_KEY_ESC = 0x76,
KB_KEY_F11 = 0x78,
KB_KEY_NUMPAD_PLUS = 0x79,
KB_KEY_NUMPAD_3 = 0x7A,
KB_KEY_NUMPAD_MINUS = 0x7B,
KB_KEY_NUMPAD_ASTERISK = 0x7C,
KB_KEY_NUMPAD_9 = 0x7D
};
typedef struct {
unsigned char status;
unsigned char lights;
unsigned char scancode;
unsigned char character;
} kb_key;
extern char getch();
extern kb_key get_key();
extern char scancode_to_ascii(unsigned char scancode);
extern unsigned char get_key_status(unsigned char scancode);
extern void kb_set_repeat(float rate, int delay);
extern void kb_set_LEDs(unsigned char status);