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

MOUSE_MODE_CONFINED_HIDDEN doesn't work on the web platform #96734

Open
ahopness opened this issue Sep 8, 2024 · 1 comment
Open

MOUSE_MODE_CONFINED_HIDDEN doesn't work on the web platform #96734

ahopness opened this issue Sep 8, 2024 · 1 comment

Comments

@ahopness
Copy link

ahopness commented Sep 8, 2024

Tested versions

  • Reproduced in: 4.3.stable & 4.2.2.stable.

System information

Windows 10 - Chrome 128 - Godot 4.3.stable - Compatibility

Issue description

My game is using Input.mouse_mode = MOUSE_MODE_CONFINED_HIDDEN because you're suposed to move your cursor a lot inside of it. The mode doesn't seem to work on web, it doesnt hide or confine the cursor.
I don't know if this is on pourpouse - it might be -but if it is, it's undocumented.

On windows (working correctly)
windows_example

On web (not working)
web_example

Is there a way to fix this?

Steps to reproduce

How to test the MRP

  1. Play the project both on windows and the web
  2. Open 'main.gd' file and uncomment line 7
  3. Play again both on windows and the web (it won't work on the web)

Minimal reproduction project (MRP)

mouse_filter_test.zip

@tehsquidge
Copy link

tehsquidge commented Oct 19, 2024

Hey,

I had a little look at the source and found this:

ERR_FAIL_COND_MSG(p_mode == MOUSE_MODE_CONFINED || p_mode == MOUSE_MODE_CONFINED_HIDDEN, "MOUSE_MODE_CONFINED is not supported for the Web platform.");

MOUSE_MODE_CONFINED_HIDDEN isn't supported on web. The error message here could probably be clearer as it only mentions MOUSE_MODE_HIDDEN and fails to mention MOUSE_MODE_CONFINED_HIDDEN.

An immediate solution for you might to do something like this:
Input.mouse_mode = Input.MOUSE_MODE_HIDDEN if OS.get_name() == "Web" else Input.MOUSE_MODE_CONFINED_HIDDEN

I'm happy to do any work on improving the error message or documentation if I can get some direction on it.

Would it make sense for MOUSE_MODE_CONFINED_HIDDEN to fallback to MOUSE_MODE_HIDDEN on Web?

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants