|
|
@@ -4,11 +4,14 @@ using Avalonia.Controls.Primitives;
|
|
|
using Avalonia.Input;
|
|
|
using Avalonia.Interactivity;
|
|
|
using Avalonia.LogicalTree;
|
|
|
+using FluentAvalonia.UI.Controls;
|
|
|
using Ryujinx.Ava.UI.Helpers;
|
|
|
+using Ryujinx.Ava.UI.Models;
|
|
|
using Ryujinx.Ava.UI.ViewModels.Input;
|
|
|
using Ryujinx.Common.Configuration.Hid.Controller;
|
|
|
using Ryujinx.Input;
|
|
|
using Ryujinx.Input.Assigner;
|
|
|
+using System.Linq;
|
|
|
using StickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId;
|
|
|
|
|
|
namespace Ryujinx.Ava.UI.Views.Input
|
|
|
@@ -82,7 +85,7 @@ namespace Ryujinx.Ava.UI.Views.Input
|
|
|
|
|
|
private void Button_IsCheckedChanged(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- if (sender is ToggleButton button)
|
|
|
+ if (sender is ToggleButton button)
|
|
|
{
|
|
|
if (button.IsChecked is true)
|
|
|
{
|
|
|
@@ -103,7 +106,9 @@ namespace Ryujinx.Ava.UI.Views.Input
|
|
|
|
|
|
var viewModel = (DataContext as ControllerInputViewModel);
|
|
|
|
|
|
- IKeyboard keyboard = (IKeyboard)viewModel.ParentModel.AvaloniaKeyboardDriver.GetGamepad("0"); // Open Avalonia keyboard for cancel operations.
|
|
|
+ IKeyboard keyboard =
|
|
|
+ (IKeyboard)viewModel.ParentModel.AvaloniaKeyboardDriver
|
|
|
+ .GetGamepad("0"); // Open Avalonia keyboard for cancel operations.
|
|
|
IButtonAssigner assigner = CreateButtonAssigner(isStick);
|
|
|
|
|
|
_currentAssigner.ButtonAssigned += (sender, e) =>
|
|
|
@@ -231,8 +236,31 @@ namespace Ryujinx.Ava.UI.Views.Input
|
|
|
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
|
|
|
{
|
|
|
base.OnDetachedFromVisualTree(e);
|
|
|
+
|
|
|
+ foreach (IGamepad gamepad in RyujinxApp.MainWindow.InputManager.GamepadDriver.GetGamepads())
|
|
|
+ {
|
|
|
+ gamepad?.ClearLed();
|
|
|
+ }
|
|
|
+
|
|
|
_currentAssigner?.Cancel();
|
|
|
_currentAssigner = null;
|
|
|
}
|
|
|
+
|
|
|
+ private void ColorPickerButton_OnColorChanged(ColorPickerButton sender, ColorButtonColorChangedEventArgs args)
|
|
|
+ {
|
|
|
+ if (!args.NewColor.HasValue) return;
|
|
|
+ if (DataContext is not ControllerInputViewModel cVm) return;
|
|
|
+ if (!cVm.Config.EnableLedChanging) return;
|
|
|
+
|
|
|
+ cVm.ParentModel.SelectedGamepad.SetLed(args.NewColor.Value.ToUInt32());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ColorPickerButton_OnAttachedToVisualTree(object sender, VisualTreeAttachmentEventArgs e)
|
|
|
+ {
|
|
|
+ if (DataContext is not ControllerInputViewModel cVm) return;
|
|
|
+ if (!cVm.Config.EnableLedChanging) return;
|
|
|
+
|
|
|
+ cVm.ParentModel.SelectedGamepad.SetLed(cVm.Config.LedColor.ToUInt32());
|
|
|
+ }
|
|
|
}
|
|
|
}
|