diff options
author | Benji Dial <benji6283@gmail.com> | 2020-09-13 03:19:57 -0400 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2020-09-13 03:19:57 -0400 |
commit | 1e4a254674f668839e5de273916024c16814b045 (patch) | |
tree | 6774f4d4398a29c4aafb4120070975d864ffcde4 /src/user/knob/user.c | |
parent | b8284137d4e0eec11c78bc14047243fce6a51373 (diff) | |
download | portland-os-1e4a254674f668839e5de273916024c16814b045.tar.gz |
(basic, not much tested) keyboard, better panic
Diffstat (limited to 'src/user/knob/user.c')
-rw-r--r-- | src/user/knob/user.c | 116 |
1 files changed, 82 insertions, 34 deletions
diff --git a/src/user/knob/user.c b/src/user/knob/user.c index fb39851..4ef3321 100644 --- a/src/user/knob/user.c +++ b/src/user/knob/user.c @@ -19,9 +19,25 @@ static const uint8_t caps_and_shift[] = { 0x7e, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x00 - - //TODO: higher + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const uint8_t caps_no_shift[] = { @@ -41,9 +57,25 @@ static const uint8_t caps_no_shift[] = { 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, - 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x00 - - //TODO: higher + 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const uint8_t shifted[] = { @@ -63,28 +95,39 @@ static const uint8_t shifted[] = { 0x7e, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, - 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x00 - - //TODO: higher + 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static char get_key_char() { _key_code_t key; while (!(key = _get_key())) _yield_task(); - return (char)( - (key & (_KEY_ALT | _KEY_CTRL | _KEY_META)) - ? 0 - : (key & _KEY_CAPS) - ? (key & _KEY_SHIFT) - ? caps_and_shift[key & 0xff] - : caps_no_shift[key & 0xff] - : (key & _KEY_SHIFT) - ? shifted[key & 0xff] - : (key & 0x80) - ? 0 - : (key & 0x7f) - ); + return + key & _KEY_CAPS + ? key & _KEY_SHIFT + ? caps_and_shift[key & 0xff] + : caps_no_shift[key & 0xff] + : key & _KEY_SHIFT + ? shifted[key & 0xff] + : key & 0xff; } void tell_user_sz(const char *sz) { @@ -115,18 +158,23 @@ uint32_t ask_user_line_sz(char *sz, uint32_t max_length) { uint32_t i; for (i = 0; i != max_length; ++i) { - char key = get_key_char(); - if (key) { - log_buf[0] = key; - _log_string(log_buf); - - if (key == '\b') - i -= i ? 2 : 1; - else if (key == '\n') - break; - else - sz[i] = key; - } + char key; + replace: + key = get_key_char(); + if (!key) + goto replace; + if (key & 0x80) + goto replace;//TODO + + log_buf[0] = key; + _log_string(log_buf); + + if (key == '\b') + i -= i ? 2 : 1; + else if (key == '\n') + break; + else + sz[i] = key; } sz[i] = '\0'; |