diff options
author | Alex AUVOLAT <alexis211@gmail.com> | 2012-05-17 17:56:23 +0200 |
---|---|---|
committer | Alex AUVOLAT <alexis211@gmail.com> | 2012-05-17 17:56:23 +0200 |
commit | 593bf4df3d8db49286c1a7ae4ef75c887b629930 (patch) | |
tree | 988a104c9611d72e1252282789688586efd9a394 /src/kernel/dev/ps2keyboard.cpp | |
parent | 7c9a48b4e6d66cf4f62e7bad9e22ab06923e47ef (diff) | |
download | TCE-593bf4df3d8db49286c1a7ae4ef75c887b629930.tar.gz TCE-593bf4df3d8db49286c1a7ae4ef75c887b629930.zip |
Devices using the VFS structure. Basic keyboard handler.
Diffstat (limited to 'src/kernel/dev/ps2keyboard.cpp')
-rw-r--r-- | src/kernel/dev/ps2keyboard.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/kernel/dev/ps2keyboard.cpp b/src/kernel/dev/ps2keyboard.cpp new file mode 100644 index 0000000..31cd75f --- /dev/null +++ b/src/kernel/dev/ps2keyboard.cpp @@ -0,0 +1,55 @@ +#include "ps2keyboard.h" + +#include <core/sys.h> +#include <task/idt.h> + +ps2kbd *kbd = 0; + +static void kbd_irq(registers*) { + kbd->kbdIrq(); +} + +ps2kbd::ps2kbd(node* parent) : keyboard(parent) { + uint8_t temp = inb(0x60), temp2 = 0; + while (temp != temp2) { + temp2 = temp; + temp = inb(0x60); + } + + kbd = this; + idt_handleIrq(1, kbd_irq); + + escaped = false; + + updateLeds(); +} + +void ps2kbd::updateLeds() { + uint8_t tmp = 0; + if (scroll) tmp |= 1; + if (num) tmp |= 2; + if (caps) tmp |= 4; + outb(0x60, tmp); +} + +void ps2kbd::kbdIrq() { + uint8_t scancode = inb(0x60); + if (scancode == 0xE0) { + escaped = true; + } else { + if (scancode & 0x80) { + if (escaped) { + handle(scancode, false); + } else { + handle(scancode & 0x7F, false); + } + } else { + if (escaped) { + handle(scancode | 0x80, true); + } else { + handle(scancode, true); + } + } + escaped = false; + } +} |