How to free my cursor from game window under MouseMode = Captured

Godot Version

4.4

Question

The embedded game view in Godot 4.4 is absolutely amazing! One problem though: in a third-person-view, I set my mouse mode to this:

Input.mouse_mode = Input.MOUSE_MODE_CAPTURED

I can freely rotate my camera around, but cannot free my cursor from the game mode to click on any other buttoms. They only way to do this is stop running the game by pressing F8. Any idea how to do this during debugging? Thanks in advance!

godot

I would set up a global script that listens to a specific key press (example, F10) and when it’s pressed, it toggles between “visible” and “captured” modes. It’s probably the easiest solution.

F9 releases the mouse

If you wrote code to make that happen, yes. But this is not default behavior in Godot.

F9 pauses the game wich releases the mouse

Could you point me in the direction of the documentatino where this is outlined? As far as I know, by default, Godot games that you make will NOT intercept ANY keyboard buttons unless you program it to do so.

It’s not about the game receiving the input but the editor. F9 is the default shortcut for “Suspend/Resume Embedded Project” on Windows.

The page in the docs seems to be outdated (since 4.4). I would have expected it to be listed there but wasn’t able to find it.

This will not release the mouse though if you have the game running and you press F9. This will only help if you have the editor itself in focus, not the game.

If the game is running in embedded mode (what this whole topic is about), pressing F9 with the game in focus will pause it and release the mouse. Even if the game workspace is floating.

	if Input.is_action_just_pressed("whatever"):
		if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
			Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
		else:
			Input.mouse_mode = Input.MOUSE_MODE_CAPTURED

This is what I use in my project.

Right, I’m sorry I didn’t realize this was specific to the embedded mode.
I tested it on Linux and MacOS and it does work.

I’m on linux and it works fine, maybe it’s a wayland thing? (I’m on wayland)

Did you mean to reply to me?
If so I’m not sure what you mean, I said it works for me as well.

I read that it didn’t work for you mb