#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
+#include "action.h"
#include "print.h"
#include "util.h"
#include "debug.h"
matrix_break(PAUSE);
}
- uint8_t code;
- while ((code = ps2_host_recv())) {
+ uint8_t code = ps2_host_recv();
+ if (!ps2_error) {
switch (state) {
case INIT:
switch (code) {
matrix_make(PRINT_SCREEN);
state = INIT;
break;
+ case 0x00: // Overrun [3]p.25
+ print("Overrun\n");
+ clear_keyboard();
+ state = INIT;
+ break;
default: // normal key make
if (code < 0x80) {
matrix_make(code);
} else {
- debug("unexpected scan code at INIT: "); debug_hex(code); debug("\n");
+ printf("unexpected scan code at INIT: %02X\n", code);
+ clear_keyboard();
}
state = INIT;
}
if (code < 0x80) {
matrix_make(code|0x80);
} else {
- debug("unexpected scan code at E0: "); debug_hex(code); debug("\n");
+ printf("unexpected scan code at E0: %02X\n", code);
+ clear_keyboard();
}
state = INIT;
}
if (code < 0x80) {
matrix_break(code);
} else {
- debug("unexpected scan code at F0: "); debug_hex(code); debug("\n");
+ printf("unexpected scan code at F0: %02X\n", code);
+ clear_keyboard();
}
state = INIT;
}
if (code < 0x80) {
matrix_break(code|0x80);
} else {
- debug("unexpected scan code at E0_F0: "); debug_hex(code); debug("\n");
+ printf("unexpected scan code at E0_F0: %02X\n", code);
+ clear_keyboard();
}
state = INIT;
}
default:
state = INIT;
}
- phex(code);
+ }
+
+ if (ps2_error > PS2_ERR_STARTBIT3) {
+ uint8_t ret = ps2_host_send(PS2_RESEND);
+ printf("Resend: %02X\n", ret);
}
return 1;
}