diff --git a/Client/ClientApp.cs b/Client/ClientApp.cs index 186173c..bdfca5a 100644 --- a/Client/ClientApp.cs +++ b/Client/ClientApp.cs @@ -29,7 +29,6 @@ public ClientApp(CommandLineOptions args) ShowDebugInfo = Program.Options.Debug.Log; } - // Fonts are loaded at double the resolution to reduce blurriness when scaling on high DPI const int FontMultiplier = 2; const int FontTextSize = 30 * FontMultiplier; @@ -219,8 +218,10 @@ internal void Initialize() ImGui.CreateContext(); UnsafeImguiInitialization(); - ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.NavEnableKeyboard | ImGuiConfigFlags.NavEnableGamepad; + + ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.NavEnableKeyboard; ImGui.GetIO().NavVisible = true; + ApplyImguiSetings(); InitializeFonts(); @@ -296,6 +297,15 @@ internal void PushMainview() } } + internal void ApplyImguiSetings() + { + sdlCtx.AcceptControllerInput = Program.Options.ControllerInput; + if (Program.Options.ControllerInput) + ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.NavEnableGamepad; + else + ImGui.GetIO().ConfigFlags &= ~ImGuiConfigFlags.NavEnableGamepad; + } + internal void EntryPoint() { sdlCtx.CreateWindow(CommandLine.WindowTitle); diff --git a/Client/Core/Options.cs b/Client/Core/Options.cs index 665fe8c..c0f2fab 100644 --- a/Client/Core/Options.cs +++ b/Client/Core/Options.cs @@ -69,6 +69,8 @@ public class Options public int DefaultVolume = 60; + public bool ControllerInput = true; + public string ScaleHintForSDL => RendererScale switch { SDLScaleMode.Linear => "linear", diff --git a/Client/Core/StringTable.cs b/Client/Core/StringTable.cs index f20740a..4ef5c50 100644 --- a/Client/Core/StringTable.cs +++ b/Client/Core/StringTable.cs @@ -234,6 +234,8 @@ internal class SettingsTable public string InvalidPathError = "The selected path does not exist, try again."; public string PathSelectDialog = "Select path"; + + public string ControllerInput = "Enable joypad input for controlling the SysDVR GUI"; } internal class PlayerTable diff --git a/Client/GUI/Components/SDLContext.cs b/Client/GUI/Components/SDLContext.cs index 278e157..f50a672 100644 --- a/Client/GUI/Components/SDLContext.cs +++ b/Client/GUI/Components/SDLContext.cs @@ -35,6 +35,8 @@ public class SDLContext public bool IsFullscreen { get; private set; } = false; public Vector2 WindowSize { get; private set; } + internal bool AcceptControllerInput = true; + // Scaling info Vector2 PixelSize; Vector2 WantedDPIScale; @@ -132,6 +134,9 @@ public GuiMessage PumpEvents(out SDL_Event evt) if (SDL_PollEvent(out evt) == 0) return GuiMessage.None; + if (evt.type == SDL_EventType.SDL_JOYBUTTONDOWN && !AcceptControllerInput) + return GuiMessage.None; + //Console.WriteLine($"Received SDL_Event {evt.type}"); #if ANDROID_LIB diff --git a/Client/GUI/OptionsView.cs b/Client/GUI/OptionsView.cs index 0c8da8e..ec73782 100644 --- a/Client/GUI/OptionsView.cs +++ b/Client/GUI/OptionsView.cs @@ -290,7 +290,10 @@ public override void Draw() ImGui.SameLine(); ImGui.SliderInt("##SliderAudioVolume", ref Program.Options.DefaultVolume, 0, 100, "%d %%"); - ImGui.Unindent(); + if (ImGui.Checkbox(Strings.ControllerInput, ref Program.Options.ControllerInput)) + Program.Instance.ApplyImguiSetings(); + + ImGui.Unindent(); ImGui.NewLine(); }