forked from danruimu/Zeos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyboard.c
executable file
·39 lines (37 loc) · 1.09 KB
/
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
35
36
37
38
39
#include <keyboard.h>
#include <types.h>
#include <io.h>
#include <libc.h>
char char_map[] = {
'\0', '\0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', '0', '\'', '¡', '\0', '\t',
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
'o', 'p', '`', '+', '\n', '\0', 'a', 's',
'd', 'f', 'g', 'h', 'j', 'k', 'l', 'ñ',
'\0', 'º', '\0', 'ç', 'z', 'x', 'c', 'v',
'b', 'n', 'm', ',', '.', '-', '\0', '*',
'\0', ' ', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '7',
'8', '9', '-', '4', '5', '6', '+', '1',
'2', '3', '0', '\0', '\0', '\0', '<', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0'
};
char llegirImprimirTecla() {
Byte b = inb(PORT_IN_KEY);
unsigned int c = (unsigned int) b & 0x7F;
if (b == ESC) {
cls();
}
else if (b & 0x80) {
if (c < (sizeof(char_map)/sizeof(char)) && char_map[c] != '\0') {
printc(char_map[c]);
return char_map[c];
} else {
char *buff = " ";
itoa(c,buff);
printk_xy(0, 0, buff);
}
}
return -1;
}