Compare commits

...

29 Commits

Author SHA1 Message Date
Evan Husted
8a22d9a942 tab 2025-01-23 22:58:08 -06:00
Evan Husted
344c1a5fef Clear LED on game close as well 2025-01-23 21:59:54 -06:00
Evan Husted
a6dfbe9ec2 Clear the LED on all controllers when settings window is closed and when input view is removed from the visual tree. 2025-01-23 21:39:19 -06:00
Evan Husted
5f02765130 Allow the ability to turn off the LED entirely
Only works for DualSense; in my testing, my DualShock 4 ignored the requests to set the LED to off.
2025-01-23 20:29:59 -06:00
Evan Husted
6619453aed Check if controller supports Rumble rather than trying to rumble for 100ms 2025-01-23 19:32:36 -06:00
Evan Husted
b442d32b7c directly compare result of rumble instead of storing an error int 2025-01-23 19:30:11 -06:00
Evan Husted
033f305872 log line to match other optional gamepad features 2025-01-23 19:28:26 -06:00
Evan Husted
bf869b0ee1 Properly save default 2025-01-23 19:18:29 -06:00
Evan Husted
72d5af8b46 Update LED as its changed in the UI 2025-01-23 19:02:35 -06:00
Evan Husted
cfe42563f2 Add the LED functionality to the base IGamepad interface 2025-01-23 18:33:52 -06:00
Evan Husted
5712e83a11 UI: enable LED changing 2025-01-23 17:22:25 -06:00
Evan Husted
8e642f0fe9 Merge branch 'master' into Change-Controller-LED-Color 2025-01-23 17:19:15 -06:00
Evan Husted
5276991517 Update SDL2Gamepad.cs 2025-01-22 22:37:03 -06:00
Evan Husted
898153ae13 Update SDL2Gamepad.cs 2025-01-22 22:35:09 -06:00
mika
96e9e3611d move logic around 2025-01-23 05:29:18 +01:00
mika
9aa834c268 maybe this works 2025-01-23 05:02:11 +01:00
mika
97dfeae99f test2 2025-01-23 04:24:01 +01:00
mika
740e35872d test 2025-01-23 03:40:45 +01:00
mika
2c4236f733 test 2025-01-23 03:39:33 +01:00
mika
e945565259 just testing if git works 2025-01-23 03:38:00 +01:00
mika
bdaaddb591 just testing if git is working 2025-01-23 03:38:00 +01:00
Otozinclus
488b09f974 Check if controller has a controllable LED 2025-01-23 03:38:00 +01:00
Evan Husted
f4c3a2e487 fix formatting & styling 2025-01-23 03:37:59 +01:00
Otozinclus
eff11f52a8 Change controller LED color
This changes the controller LED color. Now I need to add the option to change it in the settings
2025-01-23 03:37:59 +01:00
mika
c21aa86a7b just testing if git works 2025-01-23 00:09:07 +01:00
mika
861531f431 just testing if git is working 2025-01-23 00:06:24 +01:00
Otozinclus
6c0526c59f Check if controller has a controllable LED 2025-01-22 23:18:41 +01:00
Evan Husted
e861204078 fix formatting & styling 2025-01-22 16:04:57 -06:00
Otozinclus
8904397685 Change controller LED color
This changes the controller LED color. Now I need to add the option to change it in the settings
2025-01-22 21:55:53 +01:00
22 changed files with 231 additions and 17 deletions

View File

@@ -2,14 +2,19 @@
{ {
public class LedConfigController public class LedConfigController
{ {
/// <summary>
/// Packed RGB int of the color
/// </summary>
public uint LedColor { get; set; }
/// <summary> /// <summary>
/// Enable LED color changing by the emulator /// Enable LED color changing by the emulator
/// </summary> /// </summary>
public bool EnableLed { get; set; } public bool EnableLed { get; set; }
/// <summary>
/// Ignores the color and disables the LED entirely.
/// </summary>
public bool TurnOffLed { get; set; }
/// <summary>
/// Packed RGB int of the color
/// </summary>
public uint LedColor { get; set; }
} }
} }

View File

@@ -1,6 +1,7 @@
using Ryujinx.Common.Configuration.Hid; using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Hid.Controller; using Ryujinx.Common.Configuration.Hid.Controller;
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Services.Hid;
using SDL2; using SDL2;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -86,7 +87,7 @@ namespace Ryujinx.Input.SDL2
Id = driverId; Id = driverId;
Features = GetFeaturesFlag(); Features = GetFeaturesFlag();
_triggerThreshold = 0.0f; _triggerThreshold = 0.0f;
// Enable motion tracking // Enable motion tracking
if (Features.HasFlag(GamepadFeaturesFlag.Motion)) if (Features.HasFlag(GamepadFeaturesFlag.Motion))
{ {
@@ -102,6 +103,18 @@ namespace Ryujinx.Input.SDL2
} }
} }
public void SetLed(uint packedRgb)
{
if (!Features.HasFlag(GamepadFeaturesFlag.Led)) return;
byte red = packedRgb > 0 ? (byte)(packedRgb >> 16) : (byte)0;
byte green = packedRgb > 0 ? (byte)(packedRgb >> 8) : (byte)0;
byte blue = packedRgb > 0 ? (byte)(packedRgb % 256) : (byte)0;
if (SDL_GameControllerSetLED(_gamepadHandle, red, green, blue) != 0)
Logger.Error?.Print(LogClass.Hid, "LED is not supported on this game controller.");
}
private GamepadFeaturesFlag GetFeaturesFlag() private GamepadFeaturesFlag GetFeaturesFlag()
{ {
GamepadFeaturesFlag result = GamepadFeaturesFlag.None; GamepadFeaturesFlag result = GamepadFeaturesFlag.None;
@@ -112,9 +125,7 @@ namespace Ryujinx.Input.SDL2
result |= GamepadFeaturesFlag.Motion; result |= GamepadFeaturesFlag.Motion;
} }
int error = SDL_GameControllerRumble(_gamepadHandle, 0, 0, 100); if (SDL_GameControllerHasRumble(_gamepadHandle) == SDL_bool.SDL_TRUE)
if (error == 0)
{ {
result |= GamepadFeaturesFlag.Rumble; result |= GamepadFeaturesFlag.Rumble;
} }
@@ -220,6 +231,14 @@ namespace Ryujinx.Input.SDL2
{ {
_configuration = (StandardControllerInputConfig)configuration; _configuration = (StandardControllerInputConfig)configuration;
if (Features.HasFlag(GamepadFeaturesFlag.Led) && _configuration.Led.EnableLed)
{
if (_configuration.Led.TurnOffLed)
(this as IGamepad).ClearLed();
else
SetLed(_configuration.Led.LedColor);
}
_buttonsUserMapping.Clear(); _buttonsUserMapping.Clear();
// First update sticks // First update sticks

View File

@@ -173,5 +173,16 @@ namespace Ryujinx.Input.SDL2
return new SDL2Gamepad(gamepadHandle, id); return new SDL2Gamepad(gamepadHandle, id);
} }
public IEnumerable<IGamepad> GetGamepads()
{
lock (_gamepadsIds)
{
foreach (string gamepadId in _gamepadsIds)
{
yield return GetGamepad(gamepadId);
}
}
}
} }
} }

View File

@@ -1,5 +1,6 @@
using Ryujinx.Common.Configuration.Hid; using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Hid.Keyboard; using Ryujinx.Common.Configuration.Hid.Keyboard;
using Ryujinx.Common.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Numerics; using System.Numerics;
@@ -385,6 +386,11 @@ namespace Ryujinx.Input.SDL2
} }
} }
public void SetLed(uint packedRgb)
{
Logger.Info?.Print(LogClass.UI, "SetLed called on an SDL2Keyboard");
}
public void SetTriggerThreshold(float triggerThreshold) public void SetTriggerThreshold(float triggerThreshold)
{ {
// No operations // No operations

View File

@@ -1,4 +1,5 @@
using Ryujinx.Common.Configuration.Hid; using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Logging;
using System; using System;
using System.Drawing; using System.Drawing;
using System.Numerics; using System.Numerics;
@@ -76,6 +77,11 @@ namespace Ryujinx.Input.SDL2
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void SetLed(uint packedRgb)
{
Logger.Info?.Print(LogClass.UI, "SetLed called on an SDL2Mouse");
}
public void SetTriggerThreshold(float triggerThreshold) public void SetTriggerThreshold(float triggerThreshold)
{ {
throw new NotImplementedException(); throw new NotImplementedException();

View File

@@ -1,6 +1,7 @@
using Ryujinx.Common.Configuration; using Ryujinx.Common.Configuration;
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Numerics; using System.Numerics;
@@ -164,6 +165,8 @@ namespace Ryujinx.Input.SDL2
return new SDL2Mouse(this); return new SDL2Mouse(this);
} }
public IEnumerable<IGamepad> GetGamepads() => [GetGamepad("0")];
public void Dispose() public void Dispose()
{ {
if (_isDisposed) if (_isDisposed)

View File

@@ -1,5 +1,6 @@
using Ryujinx.SDL2.Common; using Ryujinx.SDL2.Common;
using System; using System;
using System.Collections.Generic;
namespace Ryujinx.Input.SDL2 namespace Ryujinx.Input.SDL2
{ {
@@ -51,5 +52,13 @@ namespace Ryujinx.Input.SDL2
return new SDL2Keyboard(this, _keyboardIdentifers[0], "All keyboards"); return new SDL2Keyboard(this, _keyboardIdentifers[0], "All keyboards");
} }
public IEnumerable<IGamepad> GetGamepads()
{
foreach (var keyboardId in _keyboardIdentifers)
{
yield return GetGamepad(keyboardId);
}
}
} }
} }

View File

@@ -65,6 +65,15 @@ namespace Ryujinx.Input
/// <param name="configuration">The configuration of the gamepad</param> /// <param name="configuration">The configuration of the gamepad</param>
void SetConfiguration(InputConfig configuration); void SetConfiguration(InputConfig configuration);
/// <summary>
/// Set the LED on the gamepad to a given color.
/// </summary>
/// <remarks>Does nothing on a controller without LED functionality.</remarks>
/// <param name="packedRgb">The packed RGB integer.</param>
void SetLed(uint packedRgb);
public void ClearLed() => SetLed(0);
/// <summary> /// <summary>
/// Starts a rumble effect on the gamepad. /// Starts a rumble effect on the gamepad.
/// </summary> /// </summary>

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
namespace Ryujinx.Input namespace Ryujinx.Input
{ {
@@ -33,6 +34,11 @@ namespace Ryujinx.Input
/// <param name="id">The unique id of the gamepad</param> /// <param name="id">The unique id of the gamepad</param>
/// <returns>An instance of <see cref="IGamepad"/> associated to the gamepad id given or null if not found</returns> /// <returns>An instance of <see cref="IGamepad"/> associated to the gamepad id given or null if not found</returns>
IGamepad GetGamepad(string id); IGamepad GetGamepad(string id);
/// <summary>
/// Returns an <see cref="IEnumerable{T}"/> of the connected gamepads.
/// </summary>
IEnumerable<IGamepad> GetGamepads();
/// <summary> /// <summary>
/// Clear the internal state of the driver. /// Clear the internal state of the driver.

View File

@@ -587,6 +587,11 @@ namespace Ryujinx.Ava
return; return;
} }
foreach (IGamepad gamepad in RyujinxApp.MainWindow.InputManager.GamepadDriver.GetGamepads())
{
gamepad?.ClearLed();
}
_isStopped = true; _isStopped = true;
Stop(); Stop();
} }

View File

@@ -7647,6 +7647,31 @@
"zh_TW": "" "zh_TW": ""
} }
}, },
{
"ID": "ControllerSettingsLedColorDisable",
"Translations": {
"ar_SA": "",
"de_DE": "",
"el_GR": "",
"en_US": "Disable",
"es_ES": "",
"fr_FR": "",
"he_IL": "",
"it_IT": "",
"ja_JP": "",
"ko_KR": "",
"no_NO": "",
"pl_PL": "",
"pt_BR": "",
"ru_RU": "",
"sv_SE": "",
"th_TH": "",
"tr_TR": "",
"uk_UA": "",
"zh_CN": "",
"zh_TW": ""
}
},
{ {
"ID": "ControllerSettingsSave", "ID": "ControllerSettingsSave",
"Translations": { "Translations": {

View File

@@ -1,5 +1,6 @@
using Ryujinx.Common.Configuration.Hid; using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Hid.Keyboard; using Ryujinx.Common.Configuration.Hid.Keyboard;
using Ryujinx.Common.Logging;
using Ryujinx.Input; using Ryujinx.Input;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -143,6 +144,11 @@ namespace Ryujinx.Ava.Input
} }
} }
public void SetLed(uint packedRgb)
{
Logger.Info?.Print(LogClass.UI, "SetLed called on an AvaloniaKeyboard");
}
public void SetTriggerThreshold(float triggerThreshold) { } public void SetTriggerThreshold(float triggerThreshold) { }
public void Rumble(float lowFrequency, float highFrequency, uint durationMs) { } public void Rumble(float lowFrequency, float highFrequency, uint durationMs) { }

View File

@@ -59,6 +59,8 @@ namespace Ryujinx.Ava.Input
return new AvaloniaKeyboard(this, _keyboardIdentifers[0], LocaleManager.Instance[LocaleKeys.AllKeyboards]); return new AvaloniaKeyboard(this, _keyboardIdentifers[0], LocaleManager.Instance[LocaleKeys.AllKeyboards]);
} }
public IEnumerable<IGamepad> GetGamepads() => [GetGamepad("0")];
protected virtual void Dispose(bool disposing) protected virtual void Dispose(bool disposing)
{ {
if (disposing) if (disposing)

View File

@@ -1,4 +1,5 @@
using Ryujinx.Common.Configuration.Hid; using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Logging;
using Ryujinx.Input; using Ryujinx.Input;
using System; using System;
using System.Drawing; using System.Drawing;
@@ -74,6 +75,11 @@ namespace Ryujinx.Ava.Input
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void SetLed(uint packedRgb)
{
Logger.Info?.Print(LogClass.UI, "SetLed called on an AvaloniaMouse");
}
public void SetTriggerThreshold(float triggerThreshold) public void SetTriggerThreshold(float triggerThreshold)
{ {
throw new NotImplementedException(); throw new NotImplementedException();

View File

@@ -3,6 +3,7 @@ using Avalonia.Controls;
using Avalonia.Input; using Avalonia.Input;
using Ryujinx.Input; using Ryujinx.Input;
using System; using System;
using System.Collections.Generic;
using System.Numerics; using System.Numerics;
using MouseButton = Ryujinx.Input.MouseButton; using MouseButton = Ryujinx.Input.MouseButton;
using Size = System.Drawing.Size; using Size = System.Drawing.Size;
@@ -134,6 +135,8 @@ namespace Ryujinx.Ava.Input
return new AvaloniaMouse(this); return new AvaloniaMouse(this);
} }
public IEnumerable<IGamepad> GetGamepads() => [GetGamepad("0")];
public void Dispose() public void Dispose()
{ {
if (_isDisposed) if (_isDisposed)

View File

@@ -400,6 +400,18 @@ namespace Ryujinx.Ava.UI.Models.Input
} }
} }
private bool _turnOffLed;
public bool TurnOffLed
{
get => _turnOffLed;
set
{
_turnOffLed = value;
OnPropertyChanged();
}
}
private Color _ledColor; private Color _ledColor;
public Color LedColor public Color LedColor
@@ -512,6 +524,7 @@ namespace Ryujinx.Ava.UI.Models.Input
if (controllerInput.Led != null) if (controllerInput.Led != null)
{ {
EnableLedChanging = controllerInput.Led.EnableLed; EnableLedChanging = controllerInput.Led.EnableLed;
TurnOffLed = controllerInput.Led.TurnOffLed;
uint rawColor = controllerInput.Led.LedColor; uint rawColor = controllerInput.Led.LedColor;
byte alpha = (byte)(rawColor >> 24); byte alpha = (byte)(rawColor >> 24);
byte red = (byte)(rawColor >> 16); byte red = (byte)(rawColor >> 16);
@@ -579,6 +592,7 @@ namespace Ryujinx.Ava.UI.Models.Input
Led = new LedConfigController Led = new LedConfigController
{ {
EnableLed = EnableLedChanging, EnableLed = EnableLedChanging,
TurnOffLed = this.TurnOffLed,
LedColor = LedColor.ToUInt32() LedColor = LedColor.ToUInt32()
}, },
Version = InputConfig.CurrentVersion, Version = InputConfig.CurrentVersion,

View File

@@ -1,5 +1,8 @@
using Avalonia.Svg.Skia; using Avalonia.Svg.Skia;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using FluentAvalonia.UI.Controls;
using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.Models.Input; using Ryujinx.Ava.UI.Models.Input;
using Ryujinx.Ava.UI.Views.Input; using Ryujinx.Ava.UI.Views.Input;
@@ -57,6 +60,16 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
await RumbleInputView.Show(this); await RumbleInputView.Show(this);
} }
public RelayCommand LedDisabledChanged => Commands.Create(() =>
{
if (!Config.EnableLedChanging) return;
if (Config.TurnOffLed)
ParentModel.SelectedGamepad.ClearLed();
else
ParentModel.SelectedGamepad.SetLed(Config.LedColor.ToUInt32());
});
public void OnParentModelChanged() public void OnParentModelChanged()
{ {
IsLeft = ParentModel.IsLeft; IsLeft = ParentModel.IsLeft;

View File

@@ -3,6 +3,7 @@ using Avalonia.Controls;
using Avalonia.Svg.Skia; using Avalonia.Svg.Skia;
using Avalonia.Threading; using Avalonia.Threading;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using Gommon;
using Ryujinx.Ava.Common.Locale; using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.Input; using Ryujinx.Ava.Input;
using Ryujinx.Ava.UI.Helpers; using Ryujinx.Ava.UI.Helpers;
@@ -54,7 +55,18 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
private static readonly InputConfigJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions()); private static readonly InputConfigJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
public IGamepadDriver AvaloniaKeyboardDriver { get; } public IGamepadDriver AvaloniaKeyboardDriver { get; }
public IGamepad SelectedGamepad { get; private set; }
private IGamepad _selectedGamepad;
public IGamepad SelectedGamepad
{
get => _selectedGamepad;
private set
{
_selectedGamepad = value;
OnPropertiesChanged(nameof(HasLed), nameof(CanClearLed));
}
}
public ObservableCollection<PlayerModel> PlayerIndexes { get; set; } public ObservableCollection<PlayerModel> PlayerIndexes { get; set; }
public ObservableCollection<(DeviceType Type, string Id, string Name)> Devices { get; set; } public ObservableCollection<(DeviceType Type, string Id, string Name)> Devices { get; set; }
@@ -69,8 +81,8 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
public bool IsRight { get; set; } public bool IsRight { get; set; }
public bool IsLeft { get; set; } public bool IsLeft { get; set; }
public bool HasLed => false; //temporary public bool HasLed => SelectedGamepad.Features.HasFlag(GamepadFeaturesFlag.Led);
//SelectedGamepad.Features.HasFlag(GamepadFeaturesFlag.Led); public bool CanClearLed => SelectedGamepad.Name.ContainsIgnoreCase("DualSense");
public bool IsModified { get; set; } public bool IsModified { get; set; }
public event Action NotifyChangesEvent; public event Action NotifyChangesEvent;

View File

@@ -429,7 +429,7 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</Border> </Border>
<!-- Motion + Rumble --> <!-- Motion, Rumble, LED -->
<StackPanel <StackPanel
Margin="0,10,0,0" Margin="0,10,0,0"
Spacing="5" Spacing="5"
@@ -495,6 +495,7 @@
Margin="0,-1,0,0"> Margin="0,-1,0,0">
<Grid IsVisible="{Binding ParentModel.HasLed}"> <Grid IsVisible="{Binding ParentModel.HasLed}">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
@@ -505,8 +506,18 @@
IsChecked="{Binding Config.EnableLedChanging, Mode=TwoWay}"> IsChecked="{Binding Config.EnableLedChanging, Mode=TwoWay}">
<TextBlock Text="{ext:Locale ControllerSettingsLedColor}" /> <TextBlock Text="{ext:Locale ControllerSettingsLedColor}" />
</CheckBox> </CheckBox>
<ui:ColorPickerButton <CheckBox
Margin="10"
MinWidth="0"
Grid.Column="1" Grid.Column="1"
IsVisible="{Binding ParentModel.CanClearLed}"
IsChecked="{Binding Config.TurnOffLed, Mode=TwoWay}"
Command="{Binding LedDisabledChanged}">
<TextBlock Text="{ext:Locale ControllerSettingsLedColorDisable}" />
</CheckBox>
<ui:ColorPickerButton
Grid.Column="2"
IsEnabled="{Binding !Config.TurnOffLed}"
Margin="10" Margin="10"
IsMoreButtonVisible="False" IsMoreButtonVisible="False"
UseColorPalette="False" UseColorPalette="False"
@@ -514,6 +525,8 @@
UseColorWheel="False" UseColorWheel="False"
ShowAcceptDismissButtons="False" ShowAcceptDismissButtons="False"
IsAlphaEnabled="False" IsAlphaEnabled="False"
AttachedToVisualTree="ColorPickerButton_OnAttachedToVisualTree"
ColorChanged="ColorPickerButton_OnColorChanged"
Color="{Binding Config.LedColor, Mode=TwoWay}"> Color="{Binding Config.LedColor, Mode=TwoWay}">
</ui:ColorPickerButton> </ui:ColorPickerButton>
</Grid> </Grid>

View File

@@ -4,11 +4,14 @@ using Avalonia.Controls.Primitives;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.LogicalTree; using Avalonia.LogicalTree;
using FluentAvalonia.UI.Controls;
using Ryujinx.Ava.UI.Helpers; using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.Models;
using Ryujinx.Ava.UI.ViewModels.Input; using Ryujinx.Ava.UI.ViewModels.Input;
using Ryujinx.Common.Configuration.Hid.Controller; using Ryujinx.Common.Configuration.Hid.Controller;
using Ryujinx.Input; using Ryujinx.Input;
using Ryujinx.Input.Assigner; using Ryujinx.Input.Assigner;
using System.Linq;
using StickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId; using StickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId;
namespace Ryujinx.Ava.UI.Views.Input namespace Ryujinx.Ava.UI.Views.Input
@@ -82,7 +85,7 @@ namespace Ryujinx.Ava.UI.Views.Input
private void Button_IsCheckedChanged(object sender, RoutedEventArgs e) private void Button_IsCheckedChanged(object sender, RoutedEventArgs e)
{ {
if (sender is ToggleButton button) if (sender is ToggleButton button)
{ {
if (button.IsChecked is true) if (button.IsChecked is true)
{ {
@@ -103,7 +106,9 @@ namespace Ryujinx.Ava.UI.Views.Input
var viewModel = (DataContext as ControllerInputViewModel); 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); IButtonAssigner assigner = CreateButtonAssigner(isStick);
_currentAssigner.ButtonAssigned += (sender, e) => _currentAssigner.ButtonAssigned += (sender, e) =>
@@ -231,8 +236,31 @@ namespace Ryujinx.Ava.UI.Views.Input
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
{ {
base.OnDetachedFromVisualTree(e); base.OnDetachedFromVisualTree(e);
foreach (IGamepad gamepad in RyujinxApp.MainWindow.InputManager.GamepadDriver.GetGamepads())
{
gamepad?.ClearLed();
}
_currentAssigner?.Cancel(); _currentAssigner?.Cancel();
_currentAssigner = null; _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());
}
} }
} }

View File

@@ -4,9 +4,14 @@ using Avalonia.Input;
using FluentAvalonia.Core; using FluentAvalonia.Core;
using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Controls;
using Ryujinx.Ava.Common.Locale; using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.Models;
using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Ava.UI.ViewModels.Input;
using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.FileSystem;
using Ryujinx.Input;
using System; using System;
using System.Linq;
using Key = Avalonia.Input.Key;
namespace Ryujinx.Ava.UI.Windows namespace Ryujinx.Ava.UI.Windows
{ {
@@ -106,6 +111,12 @@ namespace Ryujinx.Ava.UI.Windows
protected override void OnClosing(WindowClosingEventArgs e) protected override void OnClosing(WindowClosingEventArgs e)
{ {
HotkeysPage.Dispose(); HotkeysPage.Dispose();
foreach (IGamepad gamepad in RyujinxApp.MainWindow.InputManager.GamepadDriver.GetGamepads())
{
gamepad?.ClearLed();
}
InputPage.Dispose(); InputPage.Dispose();
base.OnClosing(e); base.OnClosing(e);
} }

View File

@@ -1,3 +1,4 @@
using Avalonia.Media;
using Gommon; using Gommon;
using Ryujinx.Ava.Utilities.Configuration.System; using Ryujinx.Ava.Utilities.Configuration.System;
using Ryujinx.Ava.Utilities.Configuration.UI; using Ryujinx.Ava.Utilities.Configuration.UI;
@@ -421,7 +422,8 @@ namespace Ryujinx.Ava.Utilities.Configuration
config.Led = new LedConfigController config.Led = new LedConfigController
{ {
EnableLed = false, EnableLed = false,
LedColor = 328189 TurnOffLed = false,
LedColor = new Color(255, 5, 1, 253).ToUInt32()
}; };
} }
}) })