Fix ~3500 analyser issues

See merge request ryubing/ryujinx!44
This commit is contained in:
MrKev
2025-05-30 17:08:34 -05:00
committed by LotP
parent 417df486b1
commit 361d0c5632
622 changed files with 3080 additions and 2652 deletions

View File

@@ -33,7 +33,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
OnPropertyChanged();
}
}
private bool _isLeft;
public bool IsLeft
{
@@ -59,11 +59,11 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
}
public bool HasSides => IsLeft ^ IsRight;
[ObservableProperty] private SvgImage _image;
public InputViewModel ParentModel { get; }
public ControllerInputViewModel(InputViewModel model, GamepadInputConfig config, StickVisualizer visualizer)
{
ParentModel = model;
@@ -79,7 +79,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
else
{
Rainbow.Reset();
if (Config.TurnOffLed)
ParentModel.SelectedGamepad.ClearLed();
else
@@ -91,17 +91,17 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
}
public async void ShowMotionConfig()
{
{
await MotionInputView.Show(this);
ParentModel.IsModified = true;
}
public async void ShowRumbleConfig()
{
{
await RumbleInputView.Show(this);
ParentModel.IsModified = true;
}
public async void ShowLedConfig()
{
await LedInputView.Show(this);

View File

@@ -6,11 +6,11 @@ using CommunityToolkit.Mvvm.ComponentModel;
using Gommon;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.Input;
using Ryujinx.Ava.Systems.Configuration;
using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.Models;
using Ryujinx.Ava.UI.Models.Input;
using Ryujinx.Ava.UI.Windows;
using Ryujinx.Ava.Systems.Configuration;
using Ryujinx.Common;
using Ryujinx.Common.Configuration;
using Ryujinx.Common.Configuration.Hid;
@@ -67,12 +67,12 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
private set
{
Rainbow.Reset();
_selectedGamepad = value;
if (ConfigViewModel is ControllerInputViewModel { Config.UseRainbowLed: true })
Rainbow.Updated += (ref Color color) => _selectedGamepad.SetLed((uint)color.ToArgb());
OnPropertiesChanged(nameof(HasLed), nameof(CanClearLed));
}
}
@@ -101,7 +101,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
public bool IsModified
{
get => _isModified;
set
set
{
_isModified = value;
OnPropertyChanged();
@@ -149,11 +149,11 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
set
{
if (IsModified)
{
{
_playerIdChoose = value;
return;
}
IsModified = false;
_playerId = value;
_isChangeTrackingActive = false;
@@ -163,6 +163,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
_playerId = PlayerIndex.Player1;
}
_isLoaded = false;
LoadConfiguration();
LoadDevice();
@@ -216,11 +217,11 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
IsLeft = false;
break;
}
LoadInputDriver();
LoadProfiles();
}
OnPropertyChanged();
NotifyChanges();
}
@@ -287,7 +288,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
}
}
public InputConfig Config { get; set; }
public InputViewModel(UserControl owner) : this()
@@ -348,7 +348,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
{
ConfigViewModel = new ControllerInputViewModel(this, new GamepadInputConfig(controllerInputConfig), VisualStick);
}
}
private void FindPairedDeviceInConfigFile()
@@ -356,7 +355,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
// This function allows you to output a message about the device configuration found in the file
// NOTE: if the configuration is found, we display the message "Waiting for controller connection",
// but only if the id gamepad belongs to the selected player
NotificationIsVisible = Config != null && Devices.FirstOrDefault(d => d.Id == Config.Id).Id != Config.Id && Config.PlayerIndex == PlayerId;
if (NotificationIsVisible)
{
@@ -369,10 +368,8 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
NotificationText = $"{LocaleManager.Instance[LocaleKeys.ControllerSettingsWaitingConnectDevice].Format(Config.Name, Config.Id)}";
}
}
}
private void MarkAsChanged()
{
//If tracking is active, then allow changing the modifier
@@ -383,7 +380,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
}
}
public void UnlinkDevice()
{
// "Disabled" mode is available after unbinding the device
@@ -392,7 +388,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
IsModified = true;
}
public void LoadDevice()
{
if (Config == null || Config.Backend == InputBackendType.Invalid)
@@ -479,10 +474,10 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
LoadDevices();
IsModified = true;
RevertChanges();
RevertChanges();
_isChangeTrackingActive = true;// Enable configuration change tracking
}
private string GetCurrentGamepadId()
@@ -557,6 +552,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
{
return $"{GetShortGamepadName(gamepad.Name)} ({controllerNumber})";
}
string GetUniqueGamepadName(IGamepad gamepad, ref int controllerNumber)
{
string name = GetGamepadName(gamepad, controllerNumber);
@@ -565,6 +561,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
controllerNumber++;
name = GetGamepadName(gamepad, controllerNumber);
}
return name;
}
@@ -790,7 +787,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
}
public void LoadProfileButton()
{
{
LoadProfile();
IsModified = true;
}
@@ -824,6 +821,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
{
ProfilesList.RemoveAt(index);
}
return;
}
@@ -860,58 +858,57 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
public async void SaveProfile()
{
if (Device == 0)
{
return;
}
if (ConfigViewModel == null)
{
return;
}
if (ProfileName == LocaleManager.Instance[LocaleKeys.ControllerSettingsProfileDefault])
{
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogProfileDefaultProfileOverwriteErrorMessage]);
return;
}
else
{
bool validFileName = ProfileName.IndexOfAny(Path.GetInvalidFileNameChars()) == -1;
if (Device == 0)
{
return;
}
if (validFileName)
{
string path = Path.Combine(GetProfileBasePath(), ProfileName + ".json");
if (ConfigViewModel == null)
{
return;
}
InputConfig config = null;
if (ProfileName == LocaleManager.Instance[LocaleKeys.ControllerSettingsProfileDefault])
{
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogProfileDefaultProfileOverwriteErrorMessage]);
if (IsKeyboard)
{
config = (ConfigViewModel as KeyboardInputViewModel).Config.GetConfig();
}
else if (IsController)
{
config = (ConfigViewModel as ControllerInputViewModel).Config.GetConfig();
}
return;
}
else
{
bool validFileName = ProfileName.IndexOfAny(Path.GetInvalidFileNameChars()) == -1;
config.ControllerType = Controllers[_controller].Type;
if (validFileName)
{
string path = Path.Combine(GetProfileBasePath(), ProfileName + ".json");
string jsonString = JsonHelper.Serialize(config, _serializerContext.InputConfig);
InputConfig config = null;
await File.WriteAllTextAsync(path, jsonString);
if (IsKeyboard)
{
config = (ConfigViewModel as KeyboardInputViewModel).Config.GetConfig();
}
else if (IsController)
{
config = (ConfigViewModel as ControllerInputViewModel).Config.GetConfig();
}
LoadProfiles();
config.ControllerType = Controllers[_controller].Type;
ProfileChoose = ProfileName; // Show new profile
}
else
{
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogProfileInvalidProfileNameErrorMessage]);
}
}
string jsonString = JsonHelper.Serialize(config, _serializerContext.InputConfig);
await File.WriteAllTextAsync(path, jsonString);
LoadProfiles();
ProfileChoose = ProfileName; // Show new profile
}
else
{
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogProfileInvalidProfileNameErrorMessage]);
}
}
}
public async void RemoveProfile()
@@ -947,7 +944,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
{
LoadConfiguration(); // configuration preload is required if the paired gamepad was disconnected but was changed to another gamepad
Device = Devices.ToList().FindIndex(d => d.Id == RevertDeviceId);
LoadDevice();
LoadConfiguration();
@@ -957,7 +954,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
public void Save()
{
if (!IsModified)
{
return; //If the input settings were not touched, then do nothing
@@ -967,7 +964,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
RevertDeviceId = Devices[Device].Id; // Remember selected device after saving
List <InputConfig> newConfig = [];
List<InputConfig> newConfig = [];
newConfig.AddRange(ConfigurationState.Instance.Hid.InputConfig.Value);

View File

@@ -1,9 +1,9 @@
using Avalonia.Media;
using Avalonia.Media;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Humanizer;
using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.Systems.Configuration;
using Ryujinx.Ava.UI.Helpers;
using System.Globalization;
namespace Ryujinx.Ava.UI.ViewModels.Input
@@ -11,22 +11,23 @@ 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 (!EnableLedChanging)
return;
if (TurnOffLed)
ParentModel.SelectedGamepad.ClearLed();
else
ParentModel.SelectedGamepad.SetLed(LedColor.ToUInt32());
});
[ObservableProperty] private bool _enableLedChanging;
[ObservableProperty] private Color _ledColor;
public string RainbowSpeedText => RainbowSpeed.ToString(CultureInfo.CurrentCulture).Truncate(4, string.Empty);
public float RainbowSpeed
{
get => ConfigurationState.Instance.Hid.RainbowSpeed;
@@ -37,11 +38,11 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
OnPropertyChanged(nameof(RainbowSpeedText));
}
}
public bool ShowLedColorPicker => !TurnOffLed && !UseRainbowLed;
private bool _turnOffLed;
public bool TurnOffLed
{
get => _turnOffLed;
@@ -52,9 +53,9 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
OnPropertyChanged(nameof(ShowLedColorPicker));
}
}
private bool _useRainbowLed;
public bool UseRainbowLed
{
get => _useRainbowLed;