keyboard: avr: implement ioc protocol
This commit is contained in:
parent
13d25c6866
commit
2b070b173a
@ -196,23 +196,35 @@ uint8_t matrix_state_last_vector[9] = {0xFF, 0xFF, 0xFF, 0xFF,
|
|||||||
|
|
||||||
uint8_t fn_active = 0;
|
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)
|
void process_key_event(uint8_t col, uint8_t row, uint8_t state)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
uint8_t keycode;
|
uint8_t keycode;
|
||||||
|
int event = 0;
|
||||||
|
|
||||||
keycode = keycode_translation_matrix[fn_active][col][row];
|
keycode = keycode_translation_matrix[fn_active][col][row];
|
||||||
|
|
||||||
if (keycode == SKEY_FN) {
|
if (keycode == SKEY_FN) {
|
||||||
fn_active = state;
|
fn_active = state;
|
||||||
#ifdef KEYCODE_FN
|
#ifdef KEYCODE_FN
|
||||||
while (!(UCSRA & (1 << UDRE)));
|
c = KEYCODE_FN | (state << 7);
|
||||||
UDR = KEYCODE_FN | (state << 7);
|
event = 1;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
c = keycode | (state << 7);
|
c = keycode | (state << 7);
|
||||||
while (!(UCSRA & (1 << UDRE)));
|
event = 1;
|
||||||
UDR = c;
|
}
|
||||||
|
|
||||||
|
if (event) {
|
||||||
|
uart_putc(0xFF);
|
||||||
|
uart_putc(0x55);
|
||||||
|
uart_putc(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user