make behavior consistent with windows version

This commit is contained in:
Moros Smith 2025-05-29 06:28:43 -04:00
parent 23cd32ff45
commit 04ac84f299

View file

@ -864,7 +864,10 @@ void EnableCursor(void)
// Set cursor position in the middle // Set cursor position in the middle
SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2); SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2);
// NOTE: isMouseLocked handled by EmscriptenPointerlockCallback() // Hide cursor
ShowCursor();
// NOTE: lockedMouseCursor handled by EmscriptenPointerlockCallback()
} }
// Disables cursor (lock cursor) // Disables cursor (lock cursor)
@ -873,10 +876,13 @@ void DisableCursor(void)
// TODO: figure out how not to hard code the canvas ID here. // TODO: figure out how not to hard code the canvas ID here.
emscripten_request_pointerlock(GetCanvasId(), 1); emscripten_request_pointerlock(GetCanvasId(), 1);
// Hide cursor
HideCursor();
// Set cursor position in the middle // Set cursor position in the middle
SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2); SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2);
// NOTE: isMouseLocked handled by EmscriptenPointerlockCallback() // NOTE: lockedMouseCursor handled by EmscriptenPointerlockCallback()
} }
// Swap back buffer with front buffer (screen drawing) // Swap back buffer with front buffer (screen drawing)
@ -1591,13 +1597,9 @@ static void MouseButtonCallback(GLFWwindow *window, int button, int action, int
// GLFW3 Cursor Position Callback, runs on mouse move // GLFW3 Cursor Position Callback, runs on mouse move
static void MouseCursorPosCallback(GLFWwindow *window, double x, double y) static void MouseCursorPosCallback(GLFWwindow *window, double x, double y)
{ {
// If the pointer is not locked, follow the position
if (!lockedMouseCursor)
{
CORE.Input.Mouse.currentPosition.x = (float)x; CORE.Input.Mouse.currentPosition.x = (float)x;
CORE.Input.Mouse.currentPosition.y = (float)y; CORE.Input.Mouse.currentPosition.y = (float)y;
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
}
#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES) #if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES)
// Process mouse events as touches to be able to use mouse-gestures // Process mouse events as touches to be able to use mouse-gestures