Auto-Hide Cursor after 3 seconds if F1 menu not open

This commit is contained in:
MelonSpeedruns
2026-04-17 13:22:19 -04:00
parent edea6a1418
commit 4ddd243eca
2 changed files with 12 additions and 4 deletions
+10 -4
View File
@@ -368,10 +368,16 @@ namespace dusk {
m_menuTools.ShowStateShare();
DuskDebugPad(); // temporary, remove later
// Only show cursor when menu or any windows are open
if (showMenu || ImGui::GetIO().MetricsRenderWindows > 0) {
ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_NoMouseCursorChange;
// Imgui will re-show cursor.
// Hide mouse cursor if the F1 menu is not open and the cursor is idle for 3 seconds.
ImGuiIO& io = ImGui::GetIO();
if (showMenu) {
mouseHideTimer = 0.0f;
ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_NoMouseCursorChange; // Imgui will re-show cursor.
} else if (io.MouseDelta.x != 0.0f || io.MouseDelta.y != 0.0f) {
mouseHideTimer = 0.0f;
ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_NoMouseCursorChange; // Imgui will re-show cursor.
} else if (mouseHideTimer <= 3.0f) {
mouseHideTimer += ImGui::GetIO().DeltaTime;
} else {
ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange;
SDL_HideCursor();
+2
View File
@@ -38,6 +38,8 @@ private:
remain(duration) {}
};
float mouseHideTimer = 0.0f;
bool m_isHidden = true;
bool m_isLaunchInitialized = false;
bool m_touchTapActive = false;