summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2011-11-01 04:09:51 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2011-11-01 04:09:51 (GMT)
commit67fe80b19b4610fb7138243d299a6d426f097e5f (patch)
treed866c2bc84a706e2ec19de41bf1dcc82a9c4f5ca
parentf3ae5e76b3c9521bb765b13d34931f384cf9189a (diff)
downloadabc8000-old-67fe80b19b4610fb7138243d299a6d426f097e5f.zip
abc8000-old-67fe80b19b4610fb7138243d299a6d426f097e5f.tar.gz
abc8000-old-67fe80b19b4610fb7138243d299a6d426f097e5f.tar.bz2
abc8000-old-67fe80b19b4610fb7138243d299a6d426f097e5f.tar.xz
keyboard: store key metadata; fix key lock
-rw-r--r--data/sysrom/keyboard.c17
-rw-r--r--data/sysrom/keyboard.h7
2 files changed, 17 insertions, 7 deletions
diff --git a/data/sysrom/keyboard.c b/data/sysrom/keyboard.c
index 34117c0..c41555a 100644
--- a/data/sysrom/keyboard.c
+++ b/data/sysrom/keyboard.c
@@ -27,7 +27,8 @@
static void keyboard_irq(void);
-static uint16_t kbd_ringbuf[256], kbd_head, kbd_tail;
+static struct key_stroke kbd_ringbuf[256];
+static uint8_t kbd_head, kbd_tail;
static const uint8_t kbd_reset[] =
{
@@ -154,6 +155,7 @@ static void __attribute__((interrupt)) keyboard_irq(void)
break;
case KEY_LOCK:
+ data = key_data[scan][0];
if (kbd_break_pfx) {
kbd_lock_keys &= ~data;
} else if (!(kbd_lock_keys & data)) {
@@ -168,16 +170,17 @@ static void __attribute__((interrupt)) keyboard_irq(void)
case KEY_SYMBOL:
bucky = kbd_shift_state & 7;
- if (bucky & KBD_ALT_L) {
- if (type & KEY_ALTALPHA)
- bucky ^= KBD_SHIFT_L;
- } else {
- if (type & KEY_ALPHA)
+ if (kbd_lock_state & KBD_CAPS_LOCK) {
+ uint8_t mask = (bucky & KBD_ALT_L) ? KEY_ALTALPHA : KEY_ALPHA;
+ if (type & mask)
bucky ^= KBD_SHIFT_L;
}
sym = key_data[scan][bucky];
if (kbd_head != kbd_tail) {
- kbd_ringbuf[kbd_head] = sym;
+ kbd_ringbuf[kbd_head].sym = sym;
+ kbd_ringbuf[kbd_head].scan = scan;
+ kbd_ringbuf[kbd_head].shift = kbd_shift_keys;
+ kbd_ringbuf[kbd_head].lock = kbd_lock_state;
kbd_head = (kbd_head + 1) % ELEMENTS(kbd_ringbuf);
}
break;
diff --git a/data/sysrom/keyboard.h b/data/sysrom/keyboard.h
index 4968c61..0ce8cd6 100644
--- a/data/sysrom/keyboard.h
+++ b/data/sysrom/keyboard.h
@@ -43,4 +43,11 @@
extern const uint8_t key_type[256];
extern const uint8_t key_data[][8];
+struct key_stroke {
+ uint8_t sym;
+ uint8_t scan;
+ uint8_t shift;
+ uint8_t lock;
+};
+
#endif /* SYSROM_KEYBOARD_H */