Newer
Older
tree-os / src / kernel / drivers / interrupts / keyboard / keyboard.c
#include <keyboard.h>
#include <task.h>
#include <_stdio.h>
#include <irqs.h>
#include <ports.h>
#include <stdint.h>

uint64_t pressedKeys1 = 0;
uint64_t pressedKeys2 = 0;

unsigned char keycodes[128] = {
    0,  27, '1', '2', '3', '4', '5', '6', '7', '8',
  '9', '0', '-', '=', '\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
};

void keyboardHandler() {
    int i, scancode;
    for(i = 1000; i > 0; i++) {
        if ((inb(0x64) & 1) == 0) {
            continue;
        }
        scancode = inb(0x60);
        break;
    }
    if(i > 0) {
        if(scancode & 0x80) {
        }
        else {
            putChar(keycodes[scancode]);
		    yields();
        }
    }
}

void setupKeyboard() {
    setIRQHandler(1, &keyboardHandler);
}