ps2: only read one byte per interrupt

This commit is contained in:
Benji Dial 2025-12-27 21:10:14 -05:00
parent 2eafff563e
commit bb10b27152

View file

@ -23,9 +23,14 @@
//returns -1 if no byte available
int read_ps2_byte();
static void process_keyboard_byte(uint8_t byte) {
(void)byte;
void on_keyboard_irq() {
int byte = read_ps2_byte();
if (byte == -1)
return;
//TODO
}
static uint8_t mouse_packet[3];
@ -34,7 +39,11 @@ static int mouse_packet_length = 0;
static int total_x = 0;
static int total_y = 0;
static void process_mouse_byte(uint8_t byte) {
void on_mouse_irq() {
int byte = read_ps2_byte();
if (byte == -1)
return;
mouse_packet[mouse_packet_length] = byte;
if (mouse_packet_length < 2) {
@ -69,21 +78,3 @@ static void process_mouse_byte(uint8_t byte) {
fb_base[total_y * fb_pitch + total_x * 4 + 2] = 0xff;
}
void on_keyboard_irq() {
while (1) {
int byte = read_ps2_byte();
if (byte == -1)
return;
process_keyboard_byte(byte);
}
}
void on_mouse_irq() {
while (1) {
int byte = read_ps2_byte();
if (byte == -1)
return;
process_mouse_byte(byte);
}
}