From fa3bd91a2e4eb7f3e2c326e2ddeedba3041a010e Mon Sep 17 00:00:00 2001 From: nilriera Date: Fri, 19 Jun 2026 15:33:41 +0200 Subject: [PATCH 1/2] Implement window focus gamepad control and update README --- ConfigurableReader/Services/GamepadService.cs | 8 +++++++- ConfigurableReader/Views/InfoDialog.axaml.cs | 8 +++++++- ConfigurableReader/Views/MainWindow.Gamepad.cs | 1 + ConfigurableReader/Views/MessageDialog.axaml.cs | 8 +++++++- README.md | 2 +- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ConfigurableReader/Services/GamepadService.cs b/ConfigurableReader/Services/GamepadService.cs index 4fba43d..009053c 100644 --- a/ConfigurableReader/Services/GamepadService.cs +++ b/ConfigurableReader/Services/GamepadService.cs @@ -51,6 +51,8 @@ public class GamepadService : IDisposable private DateTime _lastDPadUpTime = DateTime.MinValue; private DateTime _lastDPadDownTime = DateTime.MinValue; + public Func? IsActive { get; set; } + public bool HasActiveGamepads => _activeGamepads.Count > 0; public void Start() @@ -73,7 +75,11 @@ public void Start() gamepad.Changes.Subscribe(_ => { - Dispatcher.UIThread.Post(() => HandleGamepadInput(gamepad)); + Dispatcher.UIThread.Post(() => + { + if (IsActive != null && !IsActive()) return; + HandleGamepadInput(gamepad); + }); }); }); } diff --git a/ConfigurableReader/Views/InfoDialog.axaml.cs b/ConfigurableReader/Views/InfoDialog.axaml.cs index 02e14ae..047913d 100644 --- a/ConfigurableReader/Views/InfoDialog.axaml.cs +++ b/ConfigurableReader/Views/InfoDialog.axaml.cs @@ -28,7 +28,13 @@ public InfoDialog() if (gamepad.BButton || gamepad.AButton || gamepad.Start || gamepad.Select) { - Dispatcher.UIThread.Post(Close); + Dispatcher.UIThread.Post(() => + { + if (IsActive) + { + Close(); + } + }); } }); }); diff --git a/ConfigurableReader/Views/MainWindow.Gamepad.cs b/ConfigurableReader/Views/MainWindow.Gamepad.cs index 3dae4d8..88a27e1 100644 --- a/ConfigurableReader/Views/MainWindow.Gamepad.cs +++ b/ConfigurableReader/Views/MainWindow.Gamepad.cs @@ -55,6 +55,7 @@ private void InitializeGamepad() _ = HandlePositionAdjustmentAsync(delta); }; + _gamepadService.IsActive = () => IsActive; _gamepadService.Start(); } diff --git a/ConfigurableReader/Views/MessageDialog.axaml.cs b/ConfigurableReader/Views/MessageDialog.axaml.cs index 67a3352..8818e61 100644 --- a/ConfigurableReader/Views/MessageDialog.axaml.cs +++ b/ConfigurableReader/Views/MessageDialog.axaml.cs @@ -29,7 +29,13 @@ public MessageDialog() if (gamepad.BButton || gamepad.AButton || gamepad.Start || gamepad.Select) { - Dispatcher.UIThread.Post(Close); + Dispatcher.UIThread.Post(() => + { + if (IsActive) + { + Close(); + } + }); } }); }); diff --git a/README.md b/README.md index 1287ace..1937d38 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ A highly customizable, cross-platform text reader designed for a comfortable and - Full-text search capability. - Automatic Table of Contents extraction for EPUB and PDF files. - Custom Bookmarks feature allows saving specific locations with personalized names. -- **Gamepad Support:** Control your reading experience from the comfort of your couch using any standard HID Gamepad (Xbox, PlayStation, Switch, etc.). +- **Gamepad Support:** Control your reading experience from the comfort of your couch using any standard HID Gamepad (Xbox, PlayStation, Switch, etc.). Gamepad inputs are only processed when the window is focused/active to avoid accidental inputs when using other applications. - **Visual Indicators:** Connection indicator shows whether you are in Keyboard (⌨️) or Gamepad (🎮) mode. ## Controls From 0302e181e2ec1617150afd7355664640e6dfff1e Mon Sep 17 00:00:00 2001 From: nilriera Date: Fri, 19 Jun 2026 15:36:40 +0200 Subject: [PATCH 2/2] Update packages --- Directory.Packages.props | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 9db4d01..137a4a3 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,20 +4,20 @@ false - - - - - - + + + + + + - + - +