From 1d3c7c05d442508a8b90136222f887ad9d433992 Mon Sep 17 00:00:00 2001 From: Revix-0 <30447649+revix-0@users.noreply.github.com> Date: Mon, 19 Dec 2022 16:11:37 +0100 Subject: [PATCH] ui: Add option to hide cursor after a period of time --- config_spec.yml | 3 +++ ui/xui/main-menu.cc | 2 ++ ui/xui/main.cc | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/config_spec.yml b/config_spec.yml index 5d894a6f86..b609bf859e 100644 --- a/config_spec.yml +++ b/config_spec.yml @@ -136,6 +136,9 @@ display: show_notifications: type: bool default: true + hide_cursor: + type: bool + default: true use_animations: type: bool default: true diff --git a/ui/xui/main-menu.cc b/ui/xui/main-menu.cc index 50db1aae43..f29b013983 100644 --- a/ui/xui/main-menu.cc +++ b/ui/xui/main-menu.cc @@ -316,6 +316,8 @@ void MainMenuDisplayView::Draw() "Show main menu bar when mouse is activated"); Toggle("Show notifications", &g_config.display.ui.show_notifications, "Display notifications in upper-right corner"); + Toggle("Hide mouse cursor", &g_config.display.ui.hide_cursor, + "Hide the mouse cursor when it is not moving"); int ui_scale_idx; if (g_config.display.ui.auto_scale) { diff --git a/ui/xui/main.cc b/ui/xui/main.cc index c7d00f33ba..fd38aa4e7b 100644 --- a/ui/xui/main.cc +++ b/ui/xui/main.cc @@ -256,6 +256,16 @@ void xemu_hud_render(void) } } + static uint32_t last_mouse_move = 0; + if (g_input_mgr.MouseMoved()) { + last_mouse_move = now; + } + + // FIXME: Handle time wrap around + if (g_config.display.ui.hide_cursor && (now - last_mouse_move) > 3000) { + ImGui::SetMouseCursor(ImGuiMouseCursor_None); + } + if (!ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow) && !g_scene_mgr.IsDisplayingScene()) {