Files
kern/include/keyboard/keyboard.h
T
Tom-on ff07696dc6 Continuing terminal I/O
- Made stdio.h work
- Moved printFiletable back into kernel.c
- TODO: Add stdio.h to all files that should use it (probably next commmit)
- Added some more global addresses. There's a memory layout, but i'm not using it
- Got cursor to be drawn
- Calc program now gets user input
2024-05-28 17:08:49 +02:00

43 lines
1020 B
C

#ifndef KEYBOARD_H
#define KEYBOARD_H
#include <interrupt/idt.h>
#include <interrupt/pic.h>
#include <keyboard/keys.h>
#include <memory/addresses.h>
#include <stdio.h>
#include <stdbool.h>
typedef struct {
char character;
bool shift;
} keyboardState_t;
keyboardState_t* keyboard = (keyboardState_t*)KEYBOARD_STATE_LOC;
__attribute__ ((interrupt))
void keyboardHandler(intFrame_t* iframe) { // TODO: Make this better and be able to read multi-byte scancode
uint8_t scancode = inb(0x60);
char c = US_Keyboard[keyboard->shift][scancode];
if (scancode == LEFT_SHIFT_PRESS || scancode == RIGHT_SHIFT_PRESS) {
keyboard->shift = true;
} else if (scancode == LEFT_SHIFT_RELEASE || scancode == RIGHT_SHIFT_RELEASE) {
keyboard->shift = false;
}
if (scancode & 0x80) { // Keyup
} else if (c != '\0') {
keyboard->character = c;
}
sendPicEOI(1);
}
void setupKeyboard() {
idtSetGate(0x21, keyboardHandler, INT_GATE_FLAGS);
unsetIrqMask(1);
}
#endif