commit bb6817e1bdda310581c2842acb305cd1a742cd7d
parent e05b17e6cd4b7bbc9bd845db96773478b794de0f
Author: anon <anon@example.com>
Date: Fri, 16 Oct 2026 07:33:29 +0000
Implement Linux cursor hiding and exercise pointer path in game smoke
Diffstat:
3 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/decompiled/runtime/linux_window.c b/decompiled/runtime/linux_window.c
@@ -38,6 +38,8 @@ static int quit_pending;
static uint32_t quit_code;
static uint8_t keyboard_state[256];
static uint32_t queued_mouse_buttons;
+/* The SDL default cursor has a guest handle; native pointers never enter guest state. */
+static uint32_t current_cursor = 0xf4500000u;
static void destroy_window(void);
struct SDL_Window *linux_window_native(uint32_t handle)
@@ -704,6 +706,17 @@ static void cursor_position(void)
g_eax = 1;
}
+static void set_cursor(void)
+{
+ uint32_t cursor = MEM32(g_esp + 4);
+ if (cursor && cursor != 0xf4500000u) unsupported("cursor handle", cursor);
+ if (cursor) SDL_SetCursor(SDL_GetDefaultCursor());
+ if (SDL_ShowCursor(cursor ? SDL_ENABLE : SDL_DISABLE) < 0) abort();
+ g_eax = current_cursor;
+ current_cursor = cursor;
+ g_esp += 8;
+}
+
static void key_state(void)
{
uint32_t key = MEM32(g_esp + 4);
@@ -1125,6 +1138,7 @@ recomp_func_t linux_window_lookup(const char *dll, const char *name)
if (!strcmp(name, "GetWindowRect")) return window_rect;
if (!strcmp(name, "ClientToScreen")) return client_to_screen;
if (!strcmp(name, "GetCursorPos")) return cursor_position;
+ if (!strcmp(name, "SetCursor")) return set_cursor;
if (!strcmp(name, "GetKeyState")) return key_state;
if (!strcmp(name, "GetDesktopWindow")) return desktop_window;
if (!strcmp(name, "GetDC")) return get_dc;
diff --git a/decompiled/tests/window.c b/decompiled/tests/window.c
@@ -529,6 +529,35 @@ static void cursor_query_writes_a_guest_point(void)
assert(!call("GetCursorPos", 1, &null) && error() == 998);
}
+static void null_cursor_hides_and_previous_cursor_can_be_restored(void)
+{
+ uint32_t null = 0;
+#ifdef _WIN32
+ SetLastError(77);
+#else
+ MEM32(g_fs_base + 0x34) = 77;
+ assert(SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE);
+#endif
+
+ uint32_t previous = call("SetCursor", 1, &null);
+ uint32_t repeated = call("SetCursor", 1, &null);
+
+ assert(!repeated && error() == 77);
+#ifdef _WIN32
+ assert(GetCursor() == NULL);
+#else
+ assert(previous && SDL_ShowCursor(SDL_QUERY) == SDL_DISABLE);
+#endif
+ assert(!call("SetCursor", 1, &previous));
+ assert(call("SetCursor", 1, &previous) == previous && error() == 77);
+#ifdef _WIN32
+ assert(GetCursor() == (HCURSOR)(uintptr_t)previous);
+#else
+ assert(SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE);
+ assert(SDL_GetCursor() == SDL_GetDefaultCursor());
+#endif
+}
+
static void modifier_queries_combine_left_and_right_keys(void)
{
#ifdef _WIN32
@@ -862,6 +891,7 @@ int main(void)
ascii_translation_uses_supplied_keyboard_state();
desktop_context_reports_native_pixel_storage();
cursor_query_writes_a_guest_point();
+ null_cursor_hides_and_previous_cursor_can_be_restored();
modifier_queries_combine_left_and_right_keys();
#ifndef _WIN32
screensaver_inhibition_is_process_scoped();
diff --git a/tools/reconstruction/linux_game_smoke.gdb.py b/tools/reconstruction/linux_game_smoke.gdb.py
@@ -40,6 +40,9 @@ def capture(label):
def on_present():
frame = int(gdb.parse_and_eval('$ao_frames'))
+ # Exercise the game's global-pointer query and native cursor hiding path.
+ if frame == 30:
+ gdb.execute('call (void)SDL_WarpMouseInWindow((void*)linux_graphics_window(), 512, 384)', to_string=True)
captures = {500: 'baseline', 530: 'inventory-open', 560: 'inventory-closed',
590: 'map-open', 620: 'map-closed', 680: 'moved'}
events = {510: ('i', True), 511: ('i', False), 540: ('i', True), 541: ('i', False),
@@ -57,12 +60,24 @@ gdb.execute('set print thread-events off')
for symbol in ['external_call', 'guest_memory_fault', 'unavailable_method']:
gdb.Breakpoint(symbol, internal=True)
gdb.execute('set $ao_frames = 0')
+gdb.execute('set $ao_cursor_calls = 0')
+gdb.execute('''break set_cursor
+commands
+silent
+set $ao_cursor_calls = $ao_cursor_calls + 1
+continue
+end''')
gdb.execute('''break gl_target_present
commands
silent
set $ao_frames = $ao_frames + 1
python on_present()
if $ao_frames == 700
+if $ao_cursor_calls == 0
+printf "Cursor path was not exercised.\\n"
+quit 1
+end
+printf "SetCursor calls: %u\\n", $ao_cursor_calls
printf "Smoke inputs complete at frame 700.\\n"
quit
end