From 0e4b1758cc8e562ea47d4e789c81058a36bf9d59 Mon Sep 17 00:00:00 2001 From: lesleyrs <19632758+lesleyrs@users.noreply.github.com> Date: Sat, 16 Dec 2023 05:03:28 +0100 Subject: [PATCH] account for escape key on web --- src/platforms/rcore_web.c | 6 +++--- src/rcore.c | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index 8ffceafdc..4d7d3b9b4 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -674,8 +674,6 @@ void EnableCursor(void) // Set cursor position in the middle SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2); - - CORE.Input.Mouse.cursorHidden = false; } // Disables cursor (lock cursor) @@ -686,8 +684,10 @@ void DisableCursor(void) // Set cursor position in the middle SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2); +} - CORE.Input.Mouse.cursorHidden = true; +bool IsCursorHidden(void) { + return EM_ASM_INT({ return document.pointerLockElement !== null; }) ? true : false; } // Swap back buffer with front buffer (screen drawing) diff --git a/src/rcore.c b/src/rcore.c index a85b0971f..336b8a2a6 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -790,10 +790,12 @@ void DisableEventWaiting(void) } // Check if cursor is not visible +#if !defined(PLATFORM_WEB) bool IsCursorHidden(void) { return CORE.Input.Mouse.cursorHidden; } +#endif // Check if cursor is on the current screen. bool IsCursorOnScreen(void)