From 1ddb27d1ada6492013537ae62389f524d2174379 Mon Sep 17 00:00:00 2001 From: MysterD Date: Wed, 21 Jul 2021 00:58:19 -0700 Subject: [PATCH] DJUI: Default menus to keyboard/gamepad controls --- src/pc/djui/djui_cursor.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pc/djui/djui_cursor.c b/src/pc/djui/djui_cursor.c index a483bb11..4ab4b163 100644 --- a/src/pc/djui/djui_cursor.c +++ b/src/pc/djui/djui_cursor.c @@ -14,7 +14,6 @@ static f32 sSavedMouseX = 0; static f32 sSavedMouseY = 0; f32 gCursorX = 0; f32 gCursorY = 0; - void djui_cursor_set_visible(bool visible) { if (sMouseCursor) { djui_base_set_visible(&sMouseCursor->base, visible); @@ -111,7 +110,13 @@ void djui_cursor_update(void) { controller_sdl_read_mouse_window(); // check if mouse is in control again - if (!sCursorMouseControlled || (sMouseCursor && !sMouseCursor->base.visible)) { + static bool sFirstUpdate = true; + if (sFirstUpdate) { + sFirstUpdate = false; + sCursorMouseControlled = false; + sSavedMouseX = mouse_window_x; + sSavedMouseY = mouse_window_y; + } else if (!sCursorMouseControlled || (sMouseCursor && !sMouseCursor->base.visible)) { f32 dist = sqrtf(powf(mouse_window_x - sSavedMouseX, 2) + powf(mouse_window_y - sSavedMouseY, 2)); if (dist > 5) { sCursorMouseControlled = true;