mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-10 04:39:11 +00:00
Code style fixes
This commit is contained in:
parent
02b355eebf
commit
9a8a926851
2 changed files with 25 additions and 29 deletions
|
@ -1,3 +1,4 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
|
@ -44,15 +45,14 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
|
||||
private PlayerIndex _playerId;
|
||||
private int _controller;
|
||||
private int _controllerNumber = 0;
|
||||
private int _controllerNumber;
|
||||
private string _controllerImage;
|
||||
private int _device;
|
||||
private object _configViewModel;
|
||||
private string _profileName;
|
||||
private bool _isLoaded;
|
||||
private readonly UserControl _owner;
|
||||
|
||||
private static readonly InputConfigJsonSerializerContext SerializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
||||
private static readonly InputConfigJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
||||
|
||||
public IGamepadDriver AvaloniaKeyboardDriver { get; }
|
||||
public IGamepad SelectedGamepad { get; private set; }
|
||||
|
@ -177,11 +177,11 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
{
|
||||
get
|
||||
{
|
||||
SvgImage image = new SvgImage();
|
||||
SvgImage image = new();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_controllerImage))
|
||||
{
|
||||
SvgSource source = new SvgSource();
|
||||
SvgSource source = new();
|
||||
|
||||
source.Load(EmbeddedResources.GetStream(_controllerImage));
|
||||
|
||||
|
@ -235,22 +235,17 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
|
||||
public InputViewModel(UserControl owner) : this()
|
||||
{
|
||||
_owner = owner;
|
||||
|
||||
if (Program.PreviewerDetached)
|
||||
{
|
||||
_mainWindow =
|
||||
(MainWindow)((IClassicDesktopStyleApplicationLifetime)Avalonia.Application.Current
|
||||
(MainWindow)((IClassicDesktopStyleApplicationLifetime)Application.Current
|
||||
.ApplicationLifetime).MainWindow;
|
||||
|
||||
AvaloniaKeyboardDriver = new AvaloniaKeyboardDriver(owner);
|
||||
|
||||
_mainWindow.InputManager.GamepadDriver.OnGamepadConnected += HandleOnGamepadConnected;
|
||||
_mainWindow.InputManager.GamepadDriver.OnGamepadDisconnected += HandleOnGamepadDisconnected;
|
||||
if (_mainWindow.ViewModel.AppHost != null)
|
||||
{
|
||||
_mainWindow.ViewModel.AppHost.NpadManager.BlockInputUpdates();
|
||||
}
|
||||
_mainWindow.ViewModel.AppHost?.NpadManager.BlockInputUpdates();
|
||||
|
||||
_isLoaded = false;
|
||||
|
||||
|
@ -342,7 +337,8 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
{
|
||||
return;
|
||||
}
|
||||
else if (type == DeviceType.Keyboard)
|
||||
|
||||
if (type == DeviceType.Keyboard)
|
||||
{
|
||||
if (_mainWindow.InputManager.KeyboardDriver is AvaloniaKeyboardDriver)
|
||||
{
|
||||
|
@ -439,7 +435,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
const string Hyphen = "-";
|
||||
const int Offset = 1;
|
||||
|
||||
return str.Substring(str.IndexOf(Hyphen) + Offset);
|
||||
return str[(str.IndexOf(Hyphen) + Offset)..];
|
||||
}
|
||||
|
||||
public void LoadDevices()
|
||||
|
@ -553,7 +549,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
ButtonL = Key.E,
|
||||
ButtonZl = Key.Q,
|
||||
ButtonSl = Key.Unbound,
|
||||
ButtonSr = Key.Unbound
|
||||
ButtonSr = Key.Unbound,
|
||||
},
|
||||
LeftJoyconStick =
|
||||
new JoyconConfigKeyboardStick<Key>
|
||||
|
@ -562,7 +558,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
StickDown = Key.S,
|
||||
StickLeft = Key.A,
|
||||
StickRight = Key.D,
|
||||
StickButton = Key.F
|
||||
StickButton = Key.F,
|
||||
},
|
||||
RightJoycon = new RightJoyconCommonConfig<Key>
|
||||
{
|
||||
|
@ -574,7 +570,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
ButtonR = Key.U,
|
||||
ButtonZr = Key.O,
|
||||
ButtonSl = Key.Unbound,
|
||||
ButtonSr = Key.Unbound
|
||||
ButtonSr = Key.Unbound,
|
||||
},
|
||||
RightJoyconStick = new JoyconConfigKeyboardStick<Key>
|
||||
{
|
||||
|
@ -582,8 +578,8 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
StickDown = Key.K,
|
||||
StickLeft = Key.J,
|
||||
StickRight = Key.L,
|
||||
StickButton = Key.H
|
||||
}
|
||||
StickButton = Key.H,
|
||||
},
|
||||
};
|
||||
}
|
||||
else if (activeDevice.Type == DeviceType.Controller)
|
||||
|
@ -613,14 +609,14 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
ButtonL = ConfigGamepadInputId.LeftShoulder,
|
||||
ButtonZl = ConfigGamepadInputId.LeftTrigger,
|
||||
ButtonSl = ConfigGamepadInputId.Unbound,
|
||||
ButtonSr = ConfigGamepadInputId.Unbound
|
||||
ButtonSr = ConfigGamepadInputId.Unbound,
|
||||
},
|
||||
LeftJoyconStick = new JoyconConfigControllerStick<ConfigGamepadInputId, ConfigStickInputId>
|
||||
{
|
||||
Joystick = ConfigStickInputId.Left,
|
||||
StickButton = ConfigGamepadInputId.LeftStick,
|
||||
InvertStickX = false,
|
||||
InvertStickY = false
|
||||
InvertStickY = false,
|
||||
},
|
||||
RightJoycon = new RightJoyconCommonConfig<ConfigGamepadInputId>
|
||||
{
|
||||
|
@ -632,28 +628,28 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
ButtonR = ConfigGamepadInputId.RightShoulder,
|
||||
ButtonZr = ConfigGamepadInputId.RightTrigger,
|
||||
ButtonSl = ConfigGamepadInputId.Unbound,
|
||||
ButtonSr = ConfigGamepadInputId.Unbound
|
||||
ButtonSr = ConfigGamepadInputId.Unbound,
|
||||
},
|
||||
RightJoyconStick = new JoyconConfigControllerStick<ConfigGamepadInputId, ConfigStickInputId>
|
||||
{
|
||||
Joystick = ConfigStickInputId.Right,
|
||||
StickButton = ConfigGamepadInputId.RightStick,
|
||||
InvertStickX = false,
|
||||
InvertStickY = false
|
||||
InvertStickY = false,
|
||||
},
|
||||
Motion = new StandardMotionConfigController
|
||||
{
|
||||
MotionBackend = MotionInputBackendType.GamepadDriver,
|
||||
EnableMotion = true,
|
||||
Sensitivity = 100,
|
||||
GyroDeadzone = 1
|
||||
GyroDeadzone = 1,
|
||||
},
|
||||
Rumble = new RumbleConfigController
|
||||
{
|
||||
StrongRumble = 1f,
|
||||
WeakRumble = 1f,
|
||||
EnableRumble = false
|
||||
}
|
||||
EnableRumble = false,
|
||||
},
|
||||
};
|
||||
}
|
||||
else
|
||||
|
@ -700,7 +696,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
|
||||
try
|
||||
{
|
||||
config = JsonHelper.DeserializeFromFile(path, SerializerContext.InputConfig);
|
||||
config = JsonHelper.DeserializeFromFile(path, _serializerContext.InputConfig);
|
||||
}
|
||||
catch (JsonException) { }
|
||||
catch (InvalidOperationException)
|
||||
|
@ -766,7 +762,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
|
||||
config.ControllerType = Controllers[_controller].Type;
|
||||
|
||||
string jsonString = JsonHelper.Serialize(config, SerializerContext.InputConfig);
|
||||
string jsonString = JsonHelper.Serialize(config, _serializerContext.InputConfig);
|
||||
|
||||
await File.WriteAllTextAsync(path, jsonString);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace Ryujinx.Ava.UI.Views.Input
|
|||
|
||||
foreach (ILogical visual in SettingButtons.GetLogicalDescendants())
|
||||
{
|
||||
if (visual is ToggleButton button && !(visual is CheckBox))
|
||||
if (visual is ToggleButton button and not CheckBox)
|
||||
{
|
||||
button.IsCheckedChanged += Button_IsCheckedChanged;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue