diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/include/keyboard.h | 1 | ||||
-rw-r--r-- | src/lib/include/proto/keymap_file.h | 1 | ||||
-rw-r--r-- | src/lib/libkogata/keyboard.c | 15 |
3 files changed, 12 insertions, 5 deletions
diff --git a/src/lib/include/keyboard.h b/src/lib/include/keyboard.h index 0d5a97a..63c6c2c 100644 --- a/src/lib/include/keyboard.h +++ b/src/lib/include/keyboard.h @@ -22,6 +22,7 @@ typedef struct { typedef struct { keymap_t km; + int key_char[256]; uint32_t status; // mask of alt/ctrl/super } keyboard_t; diff --git a/src/lib/include/proto/keymap_file.h b/src/lib/include/proto/keymap_file.h index 53ffeb7..281b147 100644 --- a/src/lib/include/proto/keymap_file.h +++ b/src/lib/include/proto/keymap_file.h @@ -8,6 +8,7 @@ typedef struct { int normal[128]; int shift[128]; int caps[128]; + int shiftcaps[128]; int mod[128]; int shiftmod[128]; bool ralt_is_mod; // true: right alt = alt-gr diff --git a/src/lib/libkogata/keyboard.c b/src/lib/libkogata/keyboard.c index 7e3c376..505c048 100644 --- a/src/lib/libkogata/keyboard.c +++ b/src/lib/libkogata/keyboard.c @@ -85,7 +85,7 @@ int key_chr(keyboard_t *kb, int k) { return kb->km.mod[k]; } } else if ((kb->status & KBD_CAPS) && (kb->status & KBD_SHIFT)) { - return kb->km.normal[k]; + return kb->km.shiftcaps[k]; } else if (kb->status & KBD_SHIFT) { return kb->km.shift[k]; } else if (kb->status & KBD_CAPS) { @@ -95,7 +95,7 @@ int key_chr(keyboard_t *kb, int k) { } } -key_t make_key(keyboard_t *kb, int k) { +key_t make_key(keyboard_t *kb, int k, bool down) { key_t x; x.flags = kb->status; @@ -106,7 +106,12 @@ key_t make_key(keyboard_t *kb, int k) { if (x.key != 0) return x; x.flags |= KBD_CHAR; - x.chr = key_chr(kb, k); + if (down) { + x.chr = key_chr(kb, k); + kb->key_char[k] = x.chr; + } else { + x.chr = kb->key_char[k]; + } return x; } @@ -126,7 +131,7 @@ key_t keyboard_press(keyboard_t *kb, int k) { kb->status ^= KBD_CAPS; } - return make_key(kb, k); + return make_key(kb, k, true); } key_t keyboard_release(keyboard_t *kb, int k) { @@ -142,7 +147,7 @@ key_t keyboard_release(keyboard_t *kb, int k) { kb->status &= ~KBD_MOD; } - return make_key(kb, k); + return make_key(kb, k, false); } /* vim: set ts=4 sw=4 tw=0 noet :*/ |