feat: add keyboard layout support

This commit is contained in:
2026-08-13 17:57:44 +02:00
parent 86e3ebfe33
commit 821543238d
36 changed files with 1132 additions and 125 deletions
+8
View File
@@ -13,6 +13,7 @@
#include "gui/mtk/widgets.hpp"
#include "gui/terminal.hpp"
#include <Api/Syscall.hpp>
#include <montauk/keyboard.h>
namespace gui {
@@ -234,6 +235,12 @@ struct DesktopState {
uint64_t thermal_last_poll;
Rect temp_icon_rect;
// Keyboard layouts. The desktop translates hardware scan codes before
// dispatching events, so embedded and external apps see the same layout.
montauk::keyboard::State keyboard;
Rect keyboard_layout_rect;
uint64_t keyboard_last_poll;
int screen_w, screen_h;
uint32_t* background_cache;
int background_cache_pitch;
@@ -269,5 +276,6 @@ void desktop_draw_panel(DesktopState* ds);
void desktop_draw_window(DesktopState* ds, int idx);
void desktop_handle_mouse(DesktopState* ds);
void desktop_handle_keyboard(DesktopState* ds, const montauk::abi::KeyEvent& key);
bool desktop_refresh_keyboard_layouts(DesktopState* ds, bool force);
} // namespace gui
+1 -1
View File
@@ -395,7 +395,7 @@ inline void text_input_delete_range(char* text, int* len, int start, int end) {
inline bool text_input_char_allowed(char ch, TextInputCharFilter filter = nullptr,
void* userdata = nullptr) {
unsigned char u = (unsigned char)ch;
if (u < 0x20 || u >= 0x7F) return false;
if (u < 0x20 || u == 0x7F) return false;
return filter == nullptr || filter(ch, userdata);
}
+2 -1
View File
@@ -240,7 +240,8 @@ struct TextBox {
cursor--;
text[text_len] = '\0';
}
} else if (key.ascii >= 32 && key.ascii < 127) {
} else if ((unsigned char)key.ascii >= 32
&& (unsigned char)key.ascii != 127) {
// Printable character
if (text_len < 254) {
for (int i = text_len; i > cursor; i--) {