fix: fixes for shell/Terminal issues and CPU burn

This commit is contained in:
2026-05-06 22:04:57 +02:00
parent 6b500ec7cb
commit 2523340d08
4 changed files with 89 additions and 17 deletions
+20 -6
View File
@@ -352,6 +352,25 @@ static constexpr uint8_t SC_DOWN = 0x50;
static constexpr uint8_t SC_LEFT = 0x4B;
static constexpr uint8_t SC_RIGHT = 0x4D;
static bool empty_key_event(const Montauk::KeyEvent& ev) {
return ev.scancode == 0 && ev.ascii == 0 && !ev.pressed &&
!ev.shift && !ev.ctrl && !ev.alt;
}
static void wait_key_event(Montauk::KeyEvent* out) {
if (!out) return;
for (;;) {
montauk::getkey(out);
if (!empty_key_event(*out))
return;
uint64_t serial = montauk::input_wait(0, 0);
if (!montauk::is_key_available())
montauk::input_wait(serial, ~0ULL);
}
}
// ---- Entry point ----
extern "C" void _start() {
@@ -380,13 +399,8 @@ extern "C" void _start() {
prompt();
while (true) {
if (!montauk::is_key_available()) {
montauk::yield();
continue;
}
Montauk::KeyEvent ev;
montauk::getkey(&ev);
wait_key_event(&ev);
if (!ev.pressed) continue;