summaryrefslogtreecommitdiff
path: root/src/kernel/dev
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/dev')
-rw-r--r--src/kernel/dev/display.h1
-rw-r--r--src/kernel/dev/keyboard.cpp36
-rw-r--r--src/kernel/dev/keyboard.h7
3 files changed, 36 insertions, 8 deletions
diff --git a/src/kernel/dev/display.h b/src/kernel/dev/display.h
index 04a6d67..6960b7d 100644
--- a/src/kernel/dev/display.h
+++ b/src/kernel/dev/display.h
@@ -24,7 +24,6 @@ class display : public node {
connected_vt = 0;
}
virtual ~display() {}
-
virtual display* as_display() { return this; }
virtual int text_w() = 0;
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;
+}
diff --git a/src/kernel/dev/keyboard.h b/src/kernel/dev/keyboard.h
index 61fdbe7..4fd0b1d 100644
--- a/src/kernel/dev/keyboard.h
+++ b/src/kernel/dev/keyboard.h
@@ -58,6 +58,7 @@
#define KB_LSUPER 50
#define KB_RSUPER 51
#define KB_MENU 52
+#define KB_KPSLASH 53
#define KB_CMD_ALT 64 // any command with alt will have this flag
#define KB_CMD_CTRL 128 // any command with controll will have this flag
@@ -77,9 +78,11 @@ struct keymap {
int shiftaltgr[128];
};
+class vt;
class keyboard : public node {
private:
keymap* km;
+ vt *output;
protected:
bool num, caps, scroll;
@@ -91,8 +94,12 @@ class keyboard : public node {
public:
keyboard(node* parent);
virtual ~keyboard() {}
+
+ void outputTo(vt *vt);
void handle(int scancode, bool pressed);
+
+ int link(node* to, int mode);
};
#endif