enhance AutoAssignController to set player colors and enable LED functionality; update gamepad connection handling to load configuration while in Input settings.

This commit is contained in:
uncavo-hdmi 2025-02-04 17:02:25 +01:00
parent 7999a973f3
commit 6c8a60db08
3 changed files with 25 additions and 4 deletions

View File

@ -1,4 +1,5 @@
using Ryujinx.Ava.UI.ViewModels; using Avalonia.Media;
using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Ava.UI.Windows; using Ryujinx.Ava.UI.Windows;
using Ryujinx.Ava.Utilities.Configuration; using Ryujinx.Ava.Utilities.Configuration;
using Ryujinx.Common.Configuration.Hid; using Ryujinx.Common.Configuration.Hid;
@ -16,6 +17,17 @@ namespace Ryujinx.Ava
{ {
public class AutoAssignController public class AutoAssignController
{ {
private readonly uint[] _playerColors =
[
0xFFFF0000, // Player 1 - Red
0xFF0000FF, // Player 2 - Blue
0xFF00FF00, // Player 3 - Green
0xFFFFFF00, // Player 4 - Yellow
0xFFFF00FF, // Player 5 - Magenta
0xFFFFA500, // Player 6 - Orange
0xFF00FFFF, // Player 7 - Cyan
0xFF800080 // Player 8 - Purple
];
private const int MaxControllers = 9; private const int MaxControllers = 9;
private readonly InputManager _inputManager; private readonly InputManager _inputManager;
@ -48,6 +60,11 @@ namespace Ryujinx.Ava
foreach (var config in newConfig) foreach (var config in newConfig)
{ {
config.PlayerIndex = (PlayerIndex)index; config.PlayerIndex = (PlayerIndex)index;
if (config is StandardControllerInputConfig standardConfig)
{
Logger.Warning?.Print(LogClass.Application, $"Setting color for player {index+1}");
standardConfig.Led.LedColor = _playerColors[index];
}
index++; index++;
} }
@ -213,7 +230,7 @@ namespace Ryujinx.Ava
}, },
Led = new LedConfigController Led = new LedConfigController
{ {
EnableLed = false, EnableLed = true,
TurnOffLed = false, TurnOffLed = false,
UseRainbow = false, UseRainbow = false,
LedColor = 0, LedColor = 0,

View File

@ -38,7 +38,6 @@ namespace Ryujinx.Headless
private static LibHacHorizonManager _libHacHorizonManager; private static LibHacHorizonManager _libHacHorizonManager;
private static UserChannelPersistence _userChannelPersistence; private static UserChannelPersistence _userChannelPersistence;
private static InputManager _inputManager; private static InputManager _inputManager;
private static AutoAssignController _autoAssignController;
private static Switch _emulationContext; private static Switch _emulationContext;
private static WindowBase _window; private static WindowBase _window;
private static WindowsMultimediaTimerResolution _windowsMultimediaTimerResolution; private static WindowsMultimediaTimerResolution _windowsMultimediaTimerResolution;

View File

@ -363,7 +363,12 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
private void HandleOnGamepadConnected(string id) private void HandleOnGamepadConnected(string id)
{ {
Dispatcher.UIThread.Post(LoadDevices); Dispatcher.UIThread.Post(() =>
{
LoadDevices();
LoadConfiguration();
LoadDevice();
});
} }
private string GetCurrentGamepadId() private string GetCurrentGamepadId()