-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyboard.c
34 lines (29 loc) · 958 Bytes
/
keyboard.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "io.h"
#define KEYBOARD_DATA_PORT 0x60
/** read_scan_code:
* Reads a scan code from the keyboard
*
* @return The scan code (NOT an ASCII character!)
*/
unsigned char keyboard_read_scan_code(void)
{
return inb(KEYBOARD_DATA_PORT);
}
unsigned char keyboard_scan_code_to_ascii(unsigned char scan_code)
{
unsigned char ascii[256] =
{
0x0, 0x0, '1', '2', '3', '4', '5', '6', // 0 - 7
'7', '8', '9', '0', '-', '=', 0x0, 0x0, // 8 - 15
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', // 16 - 23
'o', 'p', '[', ']', '\n', 0x0, 'a', 's', // 24 - 31
'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', // 32 - 39
'\'', '`', 0x0, '\\', 'z', 'x', 'c', 'v', // 40 - 47
'b', 'n', 'm', ',', '.', '/', 0x0, '*', // 48 - 55
0x0, ' ', 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // 56 - 63
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, '7', // 64 - 71
'8', '9', '-', '4', '5', '6', '+', '1', // 72 - 79
'2', '3', '0', '.' // 80 - 83
};
return ascii[scan_code];
}