Bug fixes, functionality improvements:

Now the profile changes immediately upon selection.
The icon for restoring settings has been changed.
A bug has been fixed where restoring settings did not restore the previously selected gamepad.
This commit is contained in:
Vova 2025-03-02 19:07:49 +10:00
parent 33e3ba9ff2
commit 299f2144c8
3 changed files with 48 additions and 18 deletions

View file

@ -87,7 +87,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
public bool IsKeyboard => !IsController; public bool IsKeyboard => !IsController;
public bool IsRight { get; set; } public bool IsRight { get; set; }
public bool IsLeft { get; set; } public bool IsLeft { get; set; }
public int DeviceIndexBeforeChange { get; set; }
public bool HasLed => SelectedGamepad.Features.HasFlag(GamepadFeaturesFlag.Led); public bool HasLed => SelectedGamepad.Features.HasFlag(GamepadFeaturesFlag.Led);
public bool CanClearLed => SelectedGamepad.Name.ContainsIgnoreCase("DualSense"); public bool CanClearLed => SelectedGamepad.Name.ContainsIgnoreCase("DualSense");
@ -106,17 +106,17 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
public event Action NotifyChangesEvent; public event Action NotifyChangesEvent;
public int _profileChoose; public string _profileChoose;
public int ProfileChoose public string ProfileChoose
{ {
get => _profileChoose; get => _profileChoose;
set set
{ {
if (value >= 0) // When you select a profile, the settings from the profile will be applied.
{ // To save the settings, you still need to click the apply button
_profileChoose = value;
}
_profileChoose = value;
LoadProfile();
OnPropertyChanged(); OnPropertyChanged();
} }
} }
@ -152,6 +152,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
LoadDevice(); LoadDevice();
LoadProfiles(); LoadProfiles();
DeviceIndexBeforeChange = Device;
_isLoaded = true; _isLoaded = true;
_isChangeTrackingActive = true; _isChangeTrackingActive = true;
OnPropertyChanged(); OnPropertyChanged();
@ -242,6 +243,11 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
get => _device; get => _device;
set set
{ {
if (!IsModified)
{
DeviceIndexBeforeChange = _device;
}
_device = value < 0 ? 0 : value; _device = value < 0 ? 0 : value;
if (_device >= Devices.Count) if (_device >= Devices.Count)
@ -260,6 +266,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
LoadConfiguration(LoadDefaultConfiguration()); LoadConfiguration(LoadDefaultConfiguration());
} }
} }
FindPairedDevice(); FindPairedDevice();
SetChangeTrackingActive(); SetChangeTrackingActive();
OnPropertyChanged(); OnPropertyChanged();
@ -783,6 +790,12 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
return config; return config;
} }
public void LoadProfileButton()
{
IsModified = true;
LoadProfile();
}
public async void LoadProfile() public async void LoadProfile()
{ {
if (Device == 0) if (Device == 0)
@ -890,7 +903,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
LoadProfiles(); LoadProfiles();
ProfileChoose = ProfilesList.IndexOf(ProfileName); // Show new profile ProfileChoose = ProfileName; // Show new profile
} }
else else
{ {
@ -924,17 +937,24 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
LoadProfiles(); LoadProfiles();
ProfileChoose = 0; // Show default profile ProfileChoose = ProfilesList[0].ToString(); // Show default profile
} }
} }
public void LoadSavedConfiguration() public void LoadSavedConfiguration()
{ {
// Restores settings and sets the previously selected device to the last saved state
// NOTE: The current order allows the configuration and device to be loaded correctly until the configuration is changed.
if (IsModified) // Fixes random gamepad appearance in "disabled" option if (IsModified) // Fixes random gamepad appearance in "disabled" option
{ {
Device = DeviceIndexBeforeChange;
LoadDevice(); LoadDevice();
LoadConfiguration(); LoadConfiguration();
IsModified = false; IsModified = false;
OnPropertyChanged(); OnPropertyChanged();
} }
} }
@ -948,8 +968,8 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
} }
IsModified = false; IsModified = false;
DeviceIndexBeforeChange = Device;
List<InputConfig> newConfig = []; List <InputConfig> newConfig = [];
newConfig.AddRange(ConfigurationState.Instance.Hid.InputConfig.Value); newConfig.AddRange(ConfigurationState.Instance.Hid.InputConfig.Value);

View file

@ -87,7 +87,7 @@
ToolTip.Tip="{ext:Locale ControllerSettingsCancelCurrentChangesToolTip}" ToolTip.Tip="{ext:Locale ControllerSettingsCancelCurrentChangesToolTip}"
Command="{Binding LoadSavedConfiguration}"> Command="{Binding LoadSavedConfiguration}">
<ui:SymbolIcon <ui:SymbolIcon
Symbol="Cancel" Symbol="Undo"
FontSize="15" FontSize="15"
Height="20" /> Height="20" />
</Button> </Button>
@ -117,7 +117,8 @@
Name="ProfileBox" Name="ProfileBox"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalAlignment="Center" VerticalAlignment="Center"
SelectedIndex="{Binding ProfileChoose}" SelectedItem="{Binding ProfileChoose, Mode=TwoWay}"
SelectionChanged="ComboBox_SelectionChanged"
ItemsSource="{Binding ProfilesList}" ItemsSource="{Binding ProfilesList}"
Text="{Binding ProfileName, Mode=TwoWay}" /> Text="{Binding ProfileName, Mode=TwoWay}" />
<Button <Button
@ -126,7 +127,7 @@
Margin="5,0,0,0" Margin="5,0,0,0"
VerticalAlignment="Center" VerticalAlignment="Center"
ToolTip.Tip="{ext:Locale ControllerSettingsLoadProfileToolTip}" ToolTip.Tip="{ext:Locale ControllerSettingsLoadProfileToolTip}"
Command="{Binding LoadProfile}"> Command="{Binding LoadProfileButton}">
<ui:SymbolIcon <ui:SymbolIcon
Symbol="View" Symbol="View"
FontSize="15" FontSize="15"

View file

@ -1,4 +1,5 @@
using Avalonia.Controls; using Avalonia.Controls;
using FluentAvalonia.UI.Controls;
using Ryujinx.Ava.Common.Locale; using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.Helpers; using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.Models; using Ryujinx.Ava.UI.Models;
@ -70,6 +71,14 @@ namespace Ryujinx.Ava.UI.Views.Input
} }
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (sender is FAComboBox faComboBox)
{
faComboBox.IsDropDownOpen = false;
ViewModel.IsModified = true;
}
}
public void Dispose() public void Dispose()
{ {