Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Web] Input.mouse_mode returns wrong value #100758

Open
matmas opened this issue Dec 23, 2024 · 3 comments · May be fixed by #101418
Open

[Web] Input.mouse_mode returns wrong value #100758

matmas opened this issue Dec 23, 2024 · 3 comments · May be fixed by #101418

Comments

@matmas
Copy link
Contributor

matmas commented Dec 23, 2024

Tested versions

  • Reproducible in v4.4.dev4.official [36e6207]
  • Reproducible in v4.4.dev7.official [46c8f8c]
  • Not reproducible in v4.4.dev3.official [f4af820]

System information

Godot v4.4.dev4 - CachyOS Linux #1 SMP PREEMPT_DYNAMIC Thu, 19 Dec 2024 21:23:18 +0000 on Wayland - X11 display driver, Multi-window, 1 monitor - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 2070 SUPER (nvidia; 565.77) - Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz (8 threads), Web export tested under Firefox 133.0.3 (64-bit)

Issue description

In web exports Input.mouse_mode sometimes returns MouseMode.MOUSE_MODE_VISIBLE despite setting it to MouseMode.MOUSE_MODE_CAPTURED and behaving like it is captured.

Steps to reproduce

  1. open "Window Management" from official demo projects
  2. add web export, run the project in browser (Remote Debug)
  3. click on the MOUSE_MODE_CAPTURED button or press F3
  4. Extra hints should appear below all the MouseModes buttons:

ESC: Deactivate MOUSE_MODE_CAPTURED
W, S: Move forward, backward
A, D: Strafe left, right

At least they do in v4.4.dev3 but not in v4.4.dev4 anymore since the condition Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED evaluates to false.

There is a case, when this evaluates to true:

  1. run the project in browser anew or refresh the page
  2. click somewhere inside the window, on the cube for example
  3. press F3, F1, F3 in that order.
  4. Notice extra hints being shown also in v4.4.dev4 or v4.4.dev7

Minimal reproduction project (MRP)

"Window Management" official demo project (https://github.com/godotengine/godot-demo-projects/tree/master/misc/window_management)

@matheusmdx
Copy link
Contributor

Bisected to #97257, @YeldhamDev

Image

@YeldhamDev
Copy link
Member

Hmm, I assume the issue originates around here: https://github.com/godotengine/godot/blob/master/core/input/input.cpp#L96-L97

set_mouse_mode_func(p_mode);
mouse_mode = get_mouse_mode_func();

Anyone on @godotengine/web could answer me if setting the mouse mode in the web is not immediate?

@Faless
Copy link
Collaborator

Faless commented Jan 10, 2025

Anyone on @godotengine/web could answer me if setting the mouse mode in the web is not immediate?

Hiding it is immediate, capturing/releasing it is async due to the underlying API being async -> https://developer.mozilla.org/en-US/docs/Web/API/Element/requestPointerLock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Unassessed
Status: For team assessment
Development

Successfully merging a pull request may close this issue.

5 participants