Files
ryujinx/src/Ryujinx/UI/ViewModels/Input/LedInputViewModel.cs
_Neo_ cdbe4921e6 Improve Motion/Rumble/LED Windows
Due to resizing issues.
2025-11-20 19:43:09 +02:00

83 lines
2.2 KiB
C#

using Avalonia.Media;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Humanizer;
using Ryujinx.Ava.Systems.Configuration;
using Ryujinx.Ava.UI.Helpers;
using System.Globalization;
namespace Ryujinx.Ava.UI.ViewModels.Input
{
public partial class LedInputViewModel : BaseModel
{
public required InputViewModel ParentModel { get; init; }
public RelayCommand LedDisabledChanged => Commands.Create(() =>
{
if (!EnableLedChanging)
return;
if (TurnOffLed)
ParentModel.SelectedGamepad.ClearLed();
else
ParentModel.SelectedGamepad.SetLed(LedColor.ToUInt32());
});
[ObservableProperty]
public partial bool EnableLedChanging { get; set; }
[ObservableProperty]
public partial Color LedColor { get; set; }
public string RainbowSpeedText
{
get
{
if (RainbowSpeed == 10)
{
return RainbowSpeed.ToString("F1", CultureInfo.CurrentCulture);
}
else
{
return RainbowSpeed.ToString("F2", CultureInfo.CurrentCulture);
}
}
}
public float RainbowSpeed
{
get => ConfigurationState.Instance.Hid.RainbowSpeed;
set
{
ConfigurationState.Instance.Hid.RainbowSpeed.Value = value;
OnPropertyChanged();
OnPropertyChanged(nameof(RainbowSpeedText));
}
}
public bool ShowLedColorPicker => !TurnOffLed && !UseRainbowLed;
public bool TurnOffLed
{
get;
set
{
field = value;
OnPropertyChanged();
OnPropertyChanged(nameof(ShowLedColorPicker));
}
}
public bool UseRainbowLed
{
get;
set
{
field = value;
OnPropertyChanged();
OnPropertyChanged(nameof(ShowLedColorPicker));
}
}
}
}