Description
Issue description
I'm trying to show and hide the cursor for a pause menu and this works on desktop but when compiling for web if the cursor is hidden the mouse position does not update at all. (Side note: This example seems broken (pressing H does not hide cursor?) not sure if that's the same issue or not. I reproduced the issue here and it's the same as the example).
I expect the behavior of HideCursor and ShowCursor to be the same as Desktop (whether it locks the mouse or not).
Environment
Raylib 5.5, PLATFORM_WEB, compiled on Windows11, MinGW and Emscripten
Issue Screenshot
Code Example
if (IsKeyPressed(KEY_H)){
if (isCursorHidden == 0)
{
HideCursor();
isCursorHidden = 1;
}
else
{
ShowCursor();
isCursorHidden = 0;
}
}
ballPosition = GetMousePosition(); // gets stuck in same X,Y if HideCursor was called
Workaround and comments
I think this is caused because CORE.Input.Mouse.cursorHidden is being used for both hiding the cursor and locking the cursor. I would expect that the DisableCursor would lock the mouse, and for HideCursor to not lock the mouse. But in rcore_web there is a check for cursorHidden before updating the mouse position.
I think there could be two flags here, maybe? cursorHidden and cursorLocked. and cursorHidden only gets set and unset from Hide/ShowCursor. I could be missing something as well and maybe this is intended behavior for Web (since hiding cursor automatically locks it?).
The workaround I found is to use GetMouseDelta, but this only works if I use DisableCursor and EnableCursor instead of Hide and ShowCursor... which then makes me ask the question what exactly is the difference between Hiding and Disabling the Cursor? And also between Hiding and Locking (as used by Emscripten and GLFW).