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