keyboard: avr: implement ioc protocol

This commit is contained in:
Markus Koch 2019-11-01 19:52:10 +01:00
parent 13d25c6866
commit 2b070b173a

View File

@ -196,23 +196,35 @@ uint8_t matrix_state_last_vector[9] = {0xFF, 0xFF, 0xFF, 0xFF,
uint8_t fn_active = 0;
void uart_putc(char c)
{
while (!(UCSRA & (1 << UDRE)));
UDR = c;
}
void process_key_event(uint8_t col, uint8_t row, uint8_t state)
{
char c;
uint8_t keycode;
int event = 0;
keycode = keycode_translation_matrix[fn_active][col][row];
if (keycode == SKEY_FN) {
fn_active = state;
#ifdef KEYCODE_FN
while (!(UCSRA & (1 << UDRE)));
UDR = KEYCODE_FN | (state << 7);
c = KEYCODE_FN | (state << 7);
event = 1;
#endif
} else {
c = keycode | (state << 7);
while (!(UCSRA & (1 << UDRE)));
UDR = c;
event = 1;
}
if (event) {
uart_putc(0xFF);
uart_putc(0x55);
uart_putc(c);
}
}