feat: further kernel power and power optimizations
This commit is contained in:
@@ -156,6 +156,7 @@ namespace Montauk {
|
||||
static constexpr uint64_t SYS_CLIPBOARD_GET_INFO = 120;
|
||||
static constexpr uint64_t SYS_CLIPBOARD_GET_TEXT = 121;
|
||||
static constexpr uint64_t SYS_CLIPBOARD_CLEAR = 122;
|
||||
static constexpr uint64_t SYS_INPUT_WAIT = 123;
|
||||
|
||||
static constexpr uint32_t CLIPBOARD_MAX_TEXT_BYTES = 256 * 1024;
|
||||
|
||||
|
||||
@@ -177,6 +177,9 @@ namespace montauk {
|
||||
inline bool is_key_available() { return (bool)syscall0(Montauk::SYS_ISKEYAVAILABLE); }
|
||||
inline void getkey(Montauk::KeyEvent* out) { syscall1(Montauk::SYS_GETKEY, (uint64_t)out); }
|
||||
inline char getchar() { return (char)syscall0(Montauk::SYS_GETCHAR); }
|
||||
inline uint64_t input_wait(uint64_t observedSerial, uint64_t timeoutMs) {
|
||||
return (uint64_t)syscall2(Montauk::SYS_INPUT_WAIT, observedSerial, timeoutMs);
|
||||
}
|
||||
|
||||
// Networking
|
||||
inline int32_t ping(uint32_t ip, uint32_t timeoutMs = 3000) {
|
||||
|
||||
@@ -551,6 +551,7 @@ bool desktop_poll_external_windows(DesktopState* ds) {
|
||||
void gui::desktop_run(DesktopState* ds) {
|
||||
uint64_t lastClockToken = 0;
|
||||
uint64_t lastLauncherBlinkToken = ~0ull;
|
||||
uint64_t inputSerial = montauk::input_wait(0, 0);
|
||||
bool firstFrame = true;
|
||||
|
||||
for (;;) {
|
||||
@@ -628,11 +629,10 @@ void gui::desktop_run(DesktopState* ds) {
|
||||
firstFrame = false;
|
||||
}
|
||||
|
||||
if (desktop_has_active_interaction(ds)) {
|
||||
montauk::sleep_ms(1);
|
||||
} else {
|
||||
montauk::sleep_ms(sceneChanged ? 4 : 16);
|
||||
}
|
||||
uint64_t waitMs = (desktop_has_active_interaction(ds) || mouseChanged || keyboardChanged)
|
||||
? 1
|
||||
: (sceneChanged ? 4 : 16);
|
||||
inputSerial = montauk::input_wait(inputSerial, waitMs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user