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>2014-02-11 02:07:50 (GMT)
commit58475d8f4e971cac7bfced09a3d9cfff846502ea (patch)
tree89b682116d3947f3c80c96163f5529ad5d2b57e0
parent34be10743bbc0769e3cd3e6227d4a2967ab649b2 (diff)
downloadabc8000-58475d8f4e971cac7bfced09a3d9cfff846502ea.zip
abc8000-58475d8f4e971cac7bfced09a3d9cfff846502ea.tar.gz
abc8000-58475d8f4e971cac7bfced09a3d9cfff846502ea.tar.bz2
abc8000-58475d8f4e971cac7bfced09a3d9cfff846502ea.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 */