diff options
author | Alex AUVOLAT <alexis211@gmail.com> | 2012-05-18 13:09:28 +0200 |
---|---|---|
committer | Alex AUVOLAT <alexis211@gmail.com> | 2012-05-18 13:09:28 +0200 |
commit | f56aa2f7e4b8e6430e123f714507032a33955a09 (patch) | |
tree | 0381e4cbff6e5e856a3218d811da22fa12c97fcf /src/kernel/dev/keyboard.cpp | |
parent | f3e03796652b792bb3fd5d3d25b687b9a7f14633 (diff) | |
download | TCE-f56aa2f7e4b8e6430e123f714507032a33955a09.tar.gz TCE-f56aa2f7e4b8e6430e123f714507032a33955a09.zip |
The keyboard handling, it's getting better. + Funny screenshot.
Diffstat (limited to 'src/kernel/dev/keyboard.cpp')
-rw-r--r-- | src/kernel/dev/keyboard.cpp | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/kernel/dev/keyboard.cpp b/src/kernel/dev/keyboard.cpp index 479996d..ce8e77b 100644 --- a/src/kernel/dev/keyboard.cpp +++ b/src/kernel/dev/keyboard.cpp @@ -14,7 +14,7 @@ int ctrlkeys[] = { /* 0x80 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KB_ENTER, KB_RCTRL, 0, 0, /* 0xA0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* 0xB0 */ 0, 0, 0, 0, 0, 0, 0, KB_PRTSCN, KB_ALTGR, 0, 0, 0, 0, 0, 0, 0, +/* 0xB0 */ 0, 0, 0, 0, 0, KB_KPSLASH, 0, KB_PRTSCN, KB_ALTGR, 0, 0, 0, 0, 0, 0, 0, /* 0xC0 */ 0, 0, 0, 0, 0, 0, 0, KB_HOME, KB_UP, KB_PGUP, 0, KB_LEFT, 0, KB_RIGHT, 0, KB_END, /* 0xD0 */ KB_DOWN, KB_PGDOWN, KB_INS, KB_DEL, 0, 0, 0, 0, 0, 0, 0, KB_LSUPER, KB_RSUPER, KB_MENU, 0, 0, /* 0xE0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -90,11 +90,13 @@ void keyboard::handle(int scancode, bool pressed) { kp.scancode = scancode; kp.pressed = pressed; kp.command = ctrlkeys[scancode]; + kp.character = 0; if (kp.command == 0) kp.command = ctrlkeys[scancode & 0x7F]; if (kp.command == 0) { kp.command = (alt ? KB_CMD_ALT : 0) | (ctrl ? KB_CMD_CTRL : 0); - if (shift xor caps) { + scancode = scancode & 0x7F; + if ((shift || caps) && !(shift && caps)) { if (altgr) { kp.character = km->shiftaltgr[scancode]; } else { @@ -126,13 +128,13 @@ void keyboard::handle(int scancode, bool pressed) { ctrl = pressed; } else if (kp.command == KB_LSHIFT || kp.command == KB_RSHIFT) { shift = pressed; - } else if (kp.command == KB_CAPSLOCK) { + } else if (kp.command == KB_CAPSLOCK && kp.pressed) { caps = !caps; updateLeds(); - } else if (kp.command == KB_NUMLOCK) { + } else if (kp.command == KB_NUMLOCK && kp.pressed) { num = !num; updateLeds(); - } else if (kp.command == KB_SCRLLOCK) { + } else if (kp.command == KB_SCRLLOCK && kp.pressed) { scroll = !scroll; updateLeds(); } else if (kp.command == KB_TAB) { @@ -141,10 +143,30 @@ void keyboard::handle(int scancode, bool pressed) { kp.character = '\b'; } else if (kp.command == KB_ENTER) { kp.character = '\n'; + } else if (kp.command == KB_KPSLASH) { + kp.character = '/'; + kp.command = 0; } // process keypress - if (kp.character && kp.pressed) { - ke_vt->put(kp.character); + if (output != 0) { + output->keyboardInput(kp); + } else { + // TODO: enable reading directly keypresses from keyboard device } } + +void keyboard::outputTo(vt *vt) { + output = vt; +} + +int keyboard::link(node* to, int mode) { + if (mode == LM_OUTPUT_TO) { + vt *v = to->as_vt(); + if (v != 0) { + outputTo(v); + return 0; + } + } + return E_NOT_IMPLEMENTED; +} |