feat: switch text to UTF-8; add Unicode key events, dead keys & Czech layout; fix numpad navigation; add NumLock support
This commit is contained in:
1 parent
32660ddd1a
commit
2aa6360b3d
101 files changed
+3733
-1639
No files matched your search
@@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
#include <Api/Syscall.hpp>
|
||||
#include <montauk/statuscodes.h>
|
||||
#include <montauk/utf8.h>
|
||||
|
||||
namespace montauk {
|
||||
|
||||
@@ -222,7 +223,23 @@ namespace montauk {
|
||||
|
||||
// Keyboard
|
||||
inline bool is_key_available() { return (bool)syscall0(montauk::abi::SYS_ISKEYAVAILABLE); }
|
||||
inline void getkey(montauk::abi::KeyEvent* out) { syscall1(montauk::abi::SYS_GETKEY, (uint64_t)out); }
|
||||
// Scancode to use when checking for navigation keys (arrows, Home/End,
|
||||
// PgUp/PgDn, Insert/Delete). The keypad shares those scancodes with its
|
||||
// digit and '.' keys, so a keypad key that types a character reports 0
|
||||
// here: numpad 4 is text, not Left. Compare against this, not .scancode.
|
||||
inline uint8_t nav_scancode(const montauk::abi::KeyEvent& key) {
|
||||
uint8_t sc = key.scancode;
|
||||
if (!key.extended && (sc & 0x7F) >= 0x47 && (sc & 0x7F) <= 0x53 &&
|
||||
montauk::utf8::key_codepoint(key) != 0)
|
||||
return 0;
|
||||
return sc;
|
||||
}
|
||||
|
||||
// Fills the full event, including the Unicode codepoint the key types.
|
||||
inline void getkey(montauk::abi::KeyEvent* out) {
|
||||
syscall2(montauk::abi::SYS_GETKEY_EX, (uint64_t)out, sizeof(*out));
|
||||
}
|
||||
// Text keys arrive as UTF-8, one byte per call.
|
||||
inline char getchar() { return (char)syscall0(montauk::abi::SYS_GETCHAR); }
|
||||
// Returns 0 rather than blocking when no character is pending.
|
||||
inline char getchar_nb() { return (char)syscall0(montauk::abi::SYS_GETCHAR_NB); }
|
||||
@@ -496,7 +513,8 @@ namespace montauk {
|
||||
return (int)syscall3(montauk::abi::SYS_CHILDIO_WRITE, (uint64_t)childPid, (uint64_t)data, (uint64_t)len);
|
||||
}
|
||||
inline int childio_writekey(int childPid, const montauk::abi::KeyEvent* key) {
|
||||
return (int)syscall2(montauk::abi::SYS_CHILDIO_WRITEKEY, (uint64_t)childPid, (uint64_t)key);
|
||||
return (int)syscall3(montauk::abi::SYS_CHILDIO_WRITEKEY_EX, (uint64_t)childPid,
|
||||
(uint64_t)key, sizeof(*key));
|
||||
}
|
||||
inline int childio_settermsz(int childPid, int cols, int rows) {
|
||||
return (int)syscall3(montauk::abi::SYS_CHILDIO_SETTERMSZ, (uint64_t)childPid, (uint64_t)cols, (uint64_t)rows);
|
||||
|
||||
Reference in new issue
Block a user