diff options
| author | Albert Cervin <albert@acervin.com> | 2023-01-23 21:56:39 +0100 |
|---|---|---|
| committer | Albert Cervin <albert@acervin.com> | 2023-01-23 21:56:39 +0100 |
| commit | 9eda570311ffd292d333f7687074403ff46cc838 (patch) | |
| tree | 40265e3d2c23831afaf352bb64b8d6634bae9730 /src/keyboard.c | |
| parent | 385c9d62a5507d901ff7e54d7a4c0342cf3aff43 (diff) | |
| download | dged-9eda570311ffd292d333f7687074403ff46cc838.tar.gz dged-9eda570311ffd292d333f7687074403ff46cc838.tar.xz dged-9eda570311ffd292d333f7687074403ff46cc838.zip | |
Implement some more commands
- More bug fixes for keys: You can now have mod-less keys in keymaps as
binds.
- Fix calculation bug with space fillouts.
Diffstat (limited to 'src/keyboard.c')
| -rw-r--r-- | src/keyboard.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 03d0bd4..e76630e 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -72,6 +72,18 @@ void parse_keys(uint8_t *bytes, uint32_t nbytes, struct key *out_keys, (kp->mod & Spec && !(has_more && bytes[bytei + 1] == '~'))) { ++nkps; } + } else if (utf8_byte_is_unicode_start(b)) { + kp->mod = None; + kp->key = 0; + kp->start = bytei; + kp->end = bytei + utf8_nbytes(bytes + bytei, nbytes - bytei, 1); + ++nkps; + } else { + kp->mod = None; + kp->key = b; + kp->start = bytei; + kp->end = bytei + 1; + ++nkps; } } } @@ -97,13 +109,13 @@ struct keyboard_update keyboard_update(struct keyboard *kbd, } } - int nbytes = read(STDIN_FILENO, upd.raw, 32); + int nbytes = read(STDIN_FILENO, upd.raw, 64); if (nbytes > 0) { upd.nbytes = nbytes; parse_keys(upd.raw, upd.nbytes, upd.keys, &upd.nkeys); - if (nbytes < 32) { + if (nbytes < 64) { kbd->has_data = false; } } else if (nbytes == EAGAIN) { @@ -118,7 +130,7 @@ bool key_equal_char(struct key *key, uint8_t mod, uint8_t c) { } bool key_equal(struct key *key1, struct key *key2) { - return key1->key == key2->key && key1->mod == key2->mod; + return key_equal_char(key1, key2->mod, key2->key); } void key_name(struct key *key, char *buf, size_t capacity) { |
