Add key translation
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
#include <board/kbc.h>
|
||||
#include <board/kbscan.h>
|
||||
#include <board/keymap.h>
|
||||
|
||||
void kbc_init(void) {
|
||||
// Disable interrupts
|
||||
@ -9,6 +10,35 @@ void kbc_init(void) {
|
||||
*(KBC.control) = 0;
|
||||
}
|
||||
|
||||
// Translate from scancode set 2 to scancode set 1
|
||||
// for basically no good reason
|
||||
static bool kbc_translate = true;
|
||||
|
||||
void kbc_key(struct Kbc * kbc, uint16_t key, bool pressed) {
|
||||
if (kbc_translate) {
|
||||
key = keymap_translate(key);
|
||||
}
|
||||
switch (key & 0xFF00) {
|
||||
case K_E0:
|
||||
printf(" E0\n");
|
||||
kbc_keyboard(kbc, 0xE0);
|
||||
key &= 0xFF;
|
||||
// Fall through
|
||||
case 0x00:
|
||||
if (!pressed) {
|
||||
if (kbc_translate) {
|
||||
key |= 0x80;
|
||||
} else {
|
||||
printf(" F0\n");
|
||||
kbc_keyboard(kbc, 0xF0);
|
||||
}
|
||||
}
|
||||
printf(" %02X\n", key);
|
||||
kbc_keyboard(kbc, (uint8_t)key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
enum KbcState {
|
||||
KBC_STATE_NORMAL,
|
||||
KBC_STATE_WRITE_CONFIG,
|
||||
@ -109,6 +139,11 @@ void kbc_event(struct Kbc * kbc) {
|
||||
} else {
|
||||
control &= ~(1 << 1);
|
||||
}
|
||||
if (data & (1 << 6)) {
|
||||
kbc_translate = true;
|
||||
} else {
|
||||
kbc_translate = false;
|
||||
}
|
||||
*kbc->control = control;
|
||||
break;
|
||||
case KBC_STATE_SET_LEDS:
|
||||
|
Reference in New Issue
Block a user