This repository has been archived on 2020-02-06. You can view files and clone it, but cannot push or open issues or pull requests.
Legacy-Sync/keyboard.c
Jenny Curle f6ba6aa117 Legacy OS files. Have an i686-elf-gcc & -ld in your PATH,
and the Makefile will take care of the rest.
2019-04-01 01:38:50 +01:00

49 lines
1.1 KiB
C

#include "headers/isr.h"
#include "headers/common.h"
#include "headers/screen.h"
#include <stdbool.h>
#include <stdint.h>
// make an array for the keystate
// aswell as a struct for the state of toggle keys
// and other ones such as shift ctrl etc
// add polling of status bits to recieve input properly
extern uint8_t current_color;
static void keyboard_callback(registers_t *regs)
{
regs->eax++; // lul
uint8_t scancode = inb(0x60); // read from the 8042 PS/2 data port
static int i = 0;
static int j = 0;
j = j%15;
current_color = j++;
kprintf("keyboard event 0x%x : %d\n",scancode,scancode);
i++;
// check for key presses like shift
// else use a lookup table to print it dependant on the state
}
void init_keyboard(void)
{
// register our keyboard callback
register_interrupt_handler(IRQ1,&keyboard_callback);
// poll until buffer is empty
bool full = true;
while(full)
{
full = inb(0x64) & 1; // poll bit 1 of status reg
}
// send a scancode change request
outb(0x60,0xF0); //scan code change
outb(0x60,0x2); // set 2
}