keyboard: fix keystroke, add more mapping
This commit is contained in:
parent
b159aa0b50
commit
29442c4b05
@ -58,7 +58,7 @@ const char *scancode[128] = {
|
||||
/* 52 */ ":",
|
||||
/* 53 */ "!",
|
||||
/* 54 */ 0, /* right shift*/
|
||||
/* 55 */ 0,
|
||||
/* 55 */ "*",
|
||||
/* 56 */ 0, /* left alt*/
|
||||
/* 57 */ " ",
|
||||
/* 58 */ 0, /* caps Lock */
|
||||
@ -72,21 +72,21 @@ const char *scancode[128] = {
|
||||
/* 66 */ "\e[19~", /* F8 */
|
||||
/* 67 */ "\e[20~", /* F9 */
|
||||
/* 68 */ "\e[21~", /* F10 */
|
||||
/* 69 */ 0,
|
||||
/* 69 */ 0, /* VerrNum*/
|
||||
/* 70 */ 0,
|
||||
/* 71 */ 0,
|
||||
/* 72 */ 0,
|
||||
/* 73 */ 0,
|
||||
/* 74 */ 0,
|
||||
/* 75 */ 0,
|
||||
/* 76 */ 0,
|
||||
/* 77 */ 0,
|
||||
/* 78 */ 0,
|
||||
/* 79 */ 0,
|
||||
/* 80 */ 0,
|
||||
/* 81 */ 0,
|
||||
/* 82 */ 0,
|
||||
/* 83 */ 0,
|
||||
/* 71 */ "7",
|
||||
/* 72 */ "8",
|
||||
/* 73 */ "9",
|
||||
/* 74 */ "-",
|
||||
/* 75 */ "4",
|
||||
/* 76 */ "5",
|
||||
/* 77 */ "6",
|
||||
/* 78 */ "+",
|
||||
/* 79 */ "1", /* pavnum*/
|
||||
/* 80 */ "2",
|
||||
/* 81 */ "3",
|
||||
/* 82 */ "0",
|
||||
/* 83 */ ".",
|
||||
/* 84 */ 0,
|
||||
/* 85 */ 0,
|
||||
/* 86 */ "<",
|
||||
@ -267,10 +267,16 @@ void keyboard_do_irq()
|
||||
static int lshift = 0;
|
||||
static int rshift = 0;
|
||||
static int capslock = 0;
|
||||
unsigned char c = 0;
|
||||
if (inb(0x60) != c) {
|
||||
c = inb(0x60);
|
||||
static int isExt = 0;
|
||||
unsigned char c = inb(KEYBOARD_DATA_PORT);
|
||||
const char *key = NULL;
|
||||
if (c > 0) {
|
||||
if (c == 0xE0) { // non printable such as page up/down ... See https://wiki.osdev.org/Keyboard
|
||||
isExt = 1;
|
||||
} else if (isExt) {
|
||||
isExt = 0;
|
||||
return;
|
||||
}
|
||||
if (c < BREAK_CODE) {
|
||||
switch (c) {
|
||||
case 42:
|
||||
@ -283,10 +289,11 @@ void keyboard_do_irq()
|
||||
capslock = 1 - capslock;
|
||||
break;
|
||||
default:
|
||||
if ((lshift || rshift) ^ capslock)
|
||||
printf(scancode_shift[(int)c]);
|
||||
else
|
||||
printf(scancode[(int)c]);
|
||||
if ((lshift || rshift) ^ capslock) {
|
||||
key = scancode_shift[(int)c];
|
||||
} else {
|
||||
key = scancode[(int)c];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
c = c - BREAK_CODE;
|
||||
@ -299,6 +306,8 @@ void keyboard_do_irq()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (key)
|
||||
printf(key);
|
||||
}
|
||||
|
||||
|
@ -3,4 +3,6 @@
|
||||
// Pushing generate MAKE_CODE (<0x80)
|
||||
// Releasing generate BREAK_CODE (break_code = make_code + 0x80)
|
||||
#define BREAK_CODE 0x80
|
||||
#define KEYBOARD_DATA_PORT 0x60
|
||||
|
||||
void keyboard_do_irq();
|
||||
|
Loading…
Reference in New Issue
Block a user