From f03721083404c18942c3e40e2ac3b5e645b15d34 Mon Sep 17 00:00:00 2001 From: Feo Wu Date: Fri, 24 Nov 2023 00:58:37 +0800 Subject: [PATCH] fix: uncaptured mouse in FPS refers to: https://github.com/Ark2000/PankuConsole/issues/147 --- .../modules/interactive_shell/module.gd | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/addons/panku_console/modules/interactive_shell/module.gd b/addons/panku_console/modules/interactive_shell/module.gd index b57a257..591ef93 100644 --- a/addons/panku_console/modules/interactive_shell/module.gd +++ b/addons/panku_console/modules/interactive_shell/module.gd @@ -45,16 +45,25 @@ func init_module(): func(): if gui_mode == InputMode.Window: if window.visible: - Input.mouse_mode = _previous_mouse_mode window.hide_window() else: - _previous_mouse_mode = Input.mouse_mode - Input.mouse_mode = Input.MOUSE_MODE_VISIBLE window.show_window() elif gui_mode == InputMode.Launcher: simple_launcher.visible = not simple_launcher.visible ) + # Grab the mouse when the dev console is visible (e.g. FPS games) + window.visibility_changed.connect( + func(): + # the mouse is grabbed when the window is visible + if window.visible: + _previous_mouse_mode = Input.mouse_mode + Input.mouse_mode = Input.MOUSE_MODE_VISIBLE + # restore the mouse mode when the window is hidden + else: + Input.mouse_mode = _previous_mouse_mode + ) + gui_mode = load_module_data("gui_mode", InputMode.Window) pause_if_input = load_module_data("pause_if_popup", true) unified_window_visibility = load_module_data("unified_visibility", false)