diff --git a/src/userland/hid/usagePages/keyboard.c b/src/userland/hid/usagePages/keyboard.c index fa5e95b..b5aef93 100644 --- a/src/userland/hid/usagePages/keyboard.c +++ b/src/userland/hid/usagePages/keyboard.c @@ -10,7 +10,8 @@ '-', '=', '[', ']', '\\', '#', ';', '\'', /* grave accent */ 0, ',', '.', '/', /* caps lock */ 0 }; -REQUEST(doKeyCallback, "ioManager", "keyCallback"); +REQUEST(keyDown, "keyboard", "keyDown"); +REQUEST(keyUp, "keyboard", "keyDown"); void handleKeyboard(uint32_t usage, int32_t data) { if (!usage || !data) { @@ -20,6 +21,6 @@ if (usage >= sizeof(keycodes) / sizeof(char)) { printf("keyboard: unknown keycode %i\n", usage); } else if (keycodes[usage]) { - doKeyCallback(keycodes[usage], 0); + keyDown(keycodes[usage], 0); } } diff --git a/src/userland/hid/usagePages/keyboard.c b/src/userland/hid/usagePages/keyboard.c index fa5e95b..b5aef93 100644 --- a/src/userland/hid/usagePages/keyboard.c +++ b/src/userland/hid/usagePages/keyboard.c @@ -10,7 +10,8 @@ '-', '=', '[', ']', '\\', '#', ';', '\'', /* grave accent */ 0, ',', '.', '/', /* caps lock */ 0 }; -REQUEST(doKeyCallback, "ioManager", "keyCallback"); +REQUEST(keyDown, "keyboard", "keyDown"); +REQUEST(keyUp, "keyboard", "keyDown"); void handleKeyboard(uint32_t usage, int32_t data) { if (!usage || !data) { @@ -20,6 +21,6 @@ if (usage >= sizeof(keycodes) / sizeof(char)) { printf("keyboard: unknown keycode %i\n", usage); } else if (keycodes[usage]) { - doKeyCallback(keycodes[usage], 0); + keyDown(keycodes[usage], 0); } } diff --git a/src/userland/keyboard/main.c b/src/userland/keyboard/main.c index e20e132..1440ba1 100644 --- a/src/userland/keyboard/main.c +++ b/src/userland/keyboard/main.c @@ -2,10 +2,52 @@ #include +// maximum number of simultaniously pressed keys +#define MAX_PRESSED 10 + +REQUEST(doKeyCallback, "ioManager", "keyCallback"); + enum { - MODIFIER_LEFT_SHIFT = 0x01 << 0, - MODIFIER_RIGHT_SHIFT = 0x01 << 1, - MODIFIER_LEFT_CONTROL = 0x01 << 2, - MODIFIER_RIGHT_CONTROL = 0x01 << 3 + MODIFIER_LEFT_SHIFT = 0, + MODIFIER_RIGHT_SHIFT = 1, + MODIFIER_LEFT_CONTROL = 2, + MODIFIER_RIGHT_CONTROL = 3, }; +uint32_t modifiers = 0; + +// will be incremented every time a key is pressed. +volatile uint32_t repeatingThreadId = 0; + +char pressedKeys[] = { 0 }; + +void modifierUp(uint8_t modifier) { + +} + +void modifierDown(uint8_t modifier) { + +} + +void keyUp(char keycode) { +} + +void keyDown(char keycode) { + doKeyCallback(keycode, 0); +} + +void initialize() { + createFunction("keyDown", (void *)keyDown); + createFunction("keyUp", (void *)keyUp); + createFunction("modifierDown", (void *)modifierDown); + createFunction("modifierUp", (void *)modifierUp); +} + +int32_t main() { + static bool initialized = false; + if (!initialized) { + initialized = true; + initialize(); + printf("keyboard driver set up\n"); + } +} diff --git a/src/userland/hid/usagePages/keyboard.c b/src/userland/hid/usagePages/keyboard.c index fa5e95b..b5aef93 100644 --- a/src/userland/hid/usagePages/keyboard.c +++ b/src/userland/hid/usagePages/keyboard.c @@ -10,7 +10,8 @@ '-', '=', '[', ']', '\\', '#', ';', '\'', /* grave accent */ 0, ',', '.', '/', /* caps lock */ 0 }; -REQUEST(doKeyCallback, "ioManager", "keyCallback"); +REQUEST(keyDown, "keyboard", "keyDown"); +REQUEST(keyUp, "keyboard", "keyDown"); void handleKeyboard(uint32_t usage, int32_t data) { if (!usage || !data) { @@ -20,6 +21,6 @@ if (usage >= sizeof(keycodes) / sizeof(char)) { printf("keyboard: unknown keycode %i\n", usage); } else if (keycodes[usage]) { - doKeyCallback(keycodes[usage], 0); + keyDown(keycodes[usage], 0); } } diff --git a/src/userland/keyboard/main.c b/src/userland/keyboard/main.c index e20e132..1440ba1 100644 --- a/src/userland/keyboard/main.c +++ b/src/userland/keyboard/main.c @@ -2,10 +2,52 @@ #include +// maximum number of simultaniously pressed keys +#define MAX_PRESSED 10 + +REQUEST(doKeyCallback, "ioManager", "keyCallback"); + enum { - MODIFIER_LEFT_SHIFT = 0x01 << 0, - MODIFIER_RIGHT_SHIFT = 0x01 << 1, - MODIFIER_LEFT_CONTROL = 0x01 << 2, - MODIFIER_RIGHT_CONTROL = 0x01 << 3 + MODIFIER_LEFT_SHIFT = 0, + MODIFIER_RIGHT_SHIFT = 1, + MODIFIER_LEFT_CONTROL = 2, + MODIFIER_RIGHT_CONTROL = 3, }; +uint32_t modifiers = 0; + +// will be incremented every time a key is pressed. +volatile uint32_t repeatingThreadId = 0; + +char pressedKeys[] = { 0 }; + +void modifierUp(uint8_t modifier) { + +} + +void modifierDown(uint8_t modifier) { + +} + +void keyUp(char keycode) { +} + +void keyDown(char keycode) { + doKeyCallback(keycode, 0); +} + +void initialize() { + createFunction("keyDown", (void *)keyDown); + createFunction("keyUp", (void *)keyUp); + createFunction("modifierDown", (void *)modifierDown); + createFunction("modifierUp", (void *)modifierUp); +} + +int32_t main() { + static bool initialized = false; + if (!initialized) { + initialized = true; + initialize(); + printf("keyboard driver set up\n"); + } +} diff --git a/src/userland/ps2/main.c b/src/userland/ps2/main.c index 05e0007..aeece4e 100644 --- a/src/userland/ps2/main.c +++ b/src/userland/ps2/main.c @@ -23,15 +23,6 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const char capitalKeycodes[128] = { - 0, 27, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', - '+', '\b', '\t', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', - '{', '}', '\n', 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', - ':', '\"', '~', 0, '|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', - '>', '?', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0, 0, - '+', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t getScancode() { int_fast16_t scancode = -1; for (uint16_t i = 0; i < 1000; i++) { @@ -51,7 +42,7 @@ if (scancode & 0x80) { return; } - request(ioManager, keyCallback, 0, U32(altKeycodes[scancode])); + // request(ioManager, keyCallback, 0, U32(altKeycodes[scancode])); return; } if (scancode & 0x80) { @@ -59,24 +50,19 @@ scancode = scancode & 0x7F; for (uint8_t i = 0; i < sizeof(modifierScancodes); i++) { if (scancode == modifierScancodes[i]) { - modifiers = modifiers & (0xFF ^ 0x01 << i); + // modifiers = modifiers & (0xFF ^ 0x01 << i); } } return; } for (uint8_t i = 0; i < sizeof(modifierScancodes); i++) { if (scancode == modifierScancodes[i]) { - modifiers = modifiers | 0x01 << i; + // modifiers = modifiers | 0x01 << i; return; } } - char data = 0; - if (modifiers & MODIFIER_LEFT_SHIFT || modifiers & MODIFIER_RIGHT_SHIFT) { - data = capitalKeycodes[scancode]; - } else { - data = keycodes[scancode]; - } - request(ioManager, keyCallback, data, 0); + char data = keycodes[scancode]; + // request(ioManager, keyCallback, data, 0); } int32_t main() {