Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ConfigurableReader/Services/GamepadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class GamepadService : IDisposable
private DateTime _lastDPadUpTime = DateTime.MinValue;
private DateTime _lastDPadDownTime = DateTime.MinValue;

public Func<bool>? IsActive { get; set; }

public bool HasActiveGamepads => _activeGamepads.Count > 0;

public void Start()
Expand All @@ -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);
});
});
});
}
Expand Down
8 changes: 7 additions & 1 deletion ConfigurableReader/Views/InfoDialog.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
}
});
});
Expand Down
1 change: 1 addition & 0 deletions ConfigurableReader/Views/MainWindow.Gamepad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private void InitializeGamepad()
_ = HandlePositionAdjustmentAsync(delta);
};

_gamepadService.IsActive = () => IsActive;
_gamepadService.Start();
}

Expand Down
8 changes: 7 additions & 1 deletion ConfigurableReader/Views/MessageDialog.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
}
});
});
Expand Down
16 changes: 8 additions & 8 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Avalonia" Version="12.0.3" />
<PackageVersion Include="Avalonia.Controls.ColorPicker" Version="12.0.3" />
<PackageVersion Include="Avalonia.Desktop" Version="12.0.3" />
<PackageVersion Include="Avalonia.Fonts.Inter" Version="12.0.3" />
<PackageVersion Include="Avalonia.Themes.Fluent" Version="12.0.3" />
<PackageVersion Include="AvaloniaUI.DiagnosticsSupport" Version="2.2.1" />
<PackageVersion Include="Avalonia" Version="12.0.4" />
<PackageVersion Include="Avalonia.Controls.ColorPicker" Version="12.0.4" />
<PackageVersion Include="Avalonia.Desktop" Version="12.0.4" />
<PackageVersion Include="Avalonia.Fonts.Inter" Version="12.0.4" />
<PackageVersion Include="Avalonia.Themes.Fluent" Version="12.0.4" />
<PackageVersion Include="AvaloniaUI.DiagnosticsSupport" Version="2.2.2" />
<PackageVersion Include="DocumentFormat.OpenXml" Version="3.5.1" />
<PackageVersion Include="HIDDevices" Version="4.1.2" />
<PackageVersion Include="HIDDevices.Usages" Version="4.1.2" />
<PackageVersion Include="HtmlAgilityPack" Version="1.12.4" />
<PackageVersion Include="Markdig" Version="1.2.0" />
<PackageVersion Include="Markdig" Version="1.3.2" />
<PackageVersion Include="PdfPig" Version="0.1.14" />
<PackageVersion Include="VersOne.Epub" Version="3.3.6" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageVersion Include="xunit" Version="2.7.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageVersion Include="Moq" Version="4.20.72" />
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading