DJUI: Default menus to keyboard/gamepad controls

This commit is contained in:
MysterD 2021-07-21 00:58:19 -07:00
parent 64648a8ce3
commit 1ddb27d1ad

View file

@ -14,7 +14,6 @@ static f32 sSavedMouseX = 0;
static f32 sSavedMouseY = 0; static f32 sSavedMouseY = 0;
f32 gCursorX = 0; f32 gCursorX = 0;
f32 gCursorY = 0; f32 gCursorY = 0;
void djui_cursor_set_visible(bool visible) { void djui_cursor_set_visible(bool visible) {
if (sMouseCursor) { if (sMouseCursor) {
djui_base_set_visible(&sMouseCursor->base, visible); djui_base_set_visible(&sMouseCursor->base, visible);
@ -111,7 +110,13 @@ void djui_cursor_update(void) {
controller_sdl_read_mouse_window(); controller_sdl_read_mouse_window();
// check if mouse is in control again // 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)); f32 dist = sqrtf(powf(mouse_window_x - sSavedMouseX, 2) + powf(mouse_window_y - sSavedMouseY, 2));
if (dist > 5) { if (dist > 5) {
sCursorMouseControlled = true; sCursorMouseControlled = true;