raysan5/raylib

[rcore_web] Relative mouse mode issues

cemalgnlts opened this issue · 1 comments

Issue description

Hi,
When DisableCursor() is used, the mouse does not enter relative mode and the position is accumulated as the screen is rotated. This is why the mouse ray never gives the correct information.

Environment

Web - WASM - Emscripten

Issue Screenshot

When I rotate the screen one turn in the video, the position is doubled and the track from the mouse is not visible, I have to rotate the screen back one turn.
Screen recording 2024-04-11 21.36.17.webm

Code Example

https://www.raylib.com/examples.html
raylib [models] example - Mesh picking in 3d mode, ground plane, triangle, mesh

Suggestions & Ideas

If I look at the pull request here (#3874), this is the method used: glfwSetInputMode(platform.handle, GLFW_RAW_MOUSE_MOTION, GLFW_FALSE);
But emscripten does not support this: https://github.com/emscripten-core/emscripten/blob/46bd566937e1559a6b732cc78666e5be08cc414d/src/library_glfw.js#L974

However, when the pointer is locked, the browser always gives you the position where it is locked. Therefore, if the pointer is locked (DisableCursor is used), the middle position of the screen can be given instead of the mouse position on the screen.

@cemalgnlts Thanks for reporting!

However, when the pointer is locked, the browser always gives you the position where it is locked. Therefore, if the pointer is locked (DisableCursor is used), the middle position of the screen can be given instead of the mouse position on the screen.

I'm afraid I'm not understanding the proposed solution, could you send a PR for review?