diff options
| author | TSRBerry <20988865+TSRBerry@users.noreply.github.com> | 2023-06-28 18:23:00 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-28 18:23:00 +0200 |
| commit | 46b7c905f5dbb8c7e527281e22d5d2fc36bc666f (patch) | |
| tree | 5b5dc632da1288a698bb8ad2c83a13cfe861ea57 /src/Ryujinx.Input/HLE/NpadManager.cs | |
| parent | 40f2bd37e3b025ae3b932d15971d8a8e2f8b9866 (diff) | |
[Ryujinx.Input] Address dotnet-format issues (#5384)
* dotnet format style --severity info
Some changes were manually reverted.
* dotnet format analyzers --serverity info
Some changes have been minimally adapted.
* Restore a few unused methods and variables
* Address dotnet format CA1816 warnings
* Address or silence dotnet format CA1806 and a few CA1854 warnings
* Address most dotnet format whitespace warnings
* Apply dotnet format whitespace formatting
A few of them have been manually reverted and the corresponding warning was silenced
* Add comments to disabled warnings
* Simplify properties and array initialization, Use const when possible, Remove trailing commas
* Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas"
This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e.
* dotnet format whitespace after rebase
* Remove redundant code, convert to auto-properties and fix naming rule violations
* Remove bogus change
* Address review feedback
Diffstat (limited to 'src/Ryujinx.Input/HLE/NpadManager.cs')
| -rw-r--r-- | src/Ryujinx.Input/HLE/NpadManager.cs | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/Ryujinx.Input/HLE/NpadManager.cs b/src/Ryujinx.Input/HLE/NpadManager.cs index 89a2f585..25887748 100644 --- a/src/Ryujinx.Input/HLE/NpadManager.cs +++ b/src/Ryujinx.Input/HLE/NpadManager.cs @@ -7,13 +7,15 @@ using System.Collections.Generic; using System.Diagnostics; using System.Runtime.CompilerServices; using CemuHookClient = Ryujinx.Input.Motion.CemuHook.Client; +using ControllerType = Ryujinx.Common.Configuration.Hid.ControllerType; +using PlayerIndex = Ryujinx.HLE.HOS.Services.Hid.PlayerIndex; using Switch = Ryujinx.HLE.Switch; namespace Ryujinx.Input.HLE { public class NpadManager : IDisposable { - private CemuHookClient _cemuHookClient; + private readonly CemuHookClient _cemuHookClient; private readonly object _lock = new(); @@ -21,7 +23,7 @@ namespace Ryujinx.Input.HLE private const int MaxControllers = 9; - private NpadController[] _controllers; + private readonly NpadController[] _controllers; private readonly IGamepadDriver _keyboardDriver; private readonly IGamepadDriver _gamepadDriver; @@ -51,7 +53,7 @@ namespace Ryujinx.Input.HLE { lock (_lock) { - List<InputConfig> validInputs = new List<InputConfig>(); + List<InputConfig> validInputs = new(); foreach (var inputConfigEntry in _inputConfig) { if (_controllers[(int)inputConfigEntry.PlayerIndex] != null) @@ -96,10 +98,8 @@ namespace Ryujinx.Input.HLE { return controller.UpdateDriverConfiguration(targetDriver, config); } - else - { - return controller.GamepadDriver != null; - } + + return controller.GamepadDriver != null; } public void ReloadConfiguration(List<InputConfig> inputConfig, bool enableKeyboard, bool enableMouse) @@ -112,11 +112,11 @@ namespace Ryujinx.Input.HLE _controllers[i] = null; } - List<InputConfig> validInputs = new List<InputConfig>(); + List<InputConfig> validInputs = new(); foreach (InputConfig inputConfigEntry in inputConfig) { - NpadController controller = new NpadController(_cemuHookClient); + NpadController controller = new(_cemuHookClient); bool isValid = DriverConfigurationUpdate(ref controller, inputConfigEntry); @@ -131,9 +131,9 @@ namespace Ryujinx.Input.HLE } } - _inputConfig = inputConfig; + _inputConfig = inputConfig; _enableKeyboard = enableKeyboard; - _enableMouse = enableMouse; + _enableMouse = enableMouse; _device.Hid.RefreshInputConfig(validInputs); } @@ -167,8 +167,8 @@ namespace Ryujinx.Input.HLE { lock (_lock) { - List<GamepadInput> hleInputStates = new List<GamepadInput>(); - List<SixAxisInput> hleMotionStates = new List<SixAxisInput>(NpadDevices.MaxControllers); + List<GamepadInput> hleInputStates = new(); + List<SixAxisInput> hleMotionStates = new(NpadDevices.MaxControllers); KeyboardInput? hleKeyboardInput = null; @@ -178,7 +178,7 @@ namespace Ryujinx.Input.HLE (SixAxisInput, SixAxisInput) motionState = default; NpadController controller = _controllers[(int)inputConfig.PlayerIndex]; - Ryujinx.HLE.HOS.Services.Hid.PlayerIndex playerIndex = (Ryujinx.HLE.HOS.Services.Hid.PlayerIndex)inputConfig.PlayerIndex; + PlayerIndex playerIndex = (PlayerIndex)inputConfig.PlayerIndex; bool isJoyconPair = false; @@ -195,7 +195,7 @@ namespace Ryujinx.Input.HLE inputState.Buttons |= _device.Hid.UpdateStickButtons(inputState.LStick, inputState.RStick); - isJoyconPair = inputConfig.ControllerType == Common.Configuration.Hid.ControllerType.JoyconPair; + isJoyconPair = inputConfig.ControllerType == ControllerType.JoyconPair; var altMotionState = isJoyconPair ? controller.GetHLEMotionState(true) : default; @@ -284,7 +284,7 @@ namespace Ryujinx.Input.HLE { lock (_lock) { - return _inputConfig.Find(x => x.PlayerIndex == (Ryujinx.Common.Configuration.Hid.PlayerIndex)index); + return _inputConfig.Find(x => x.PlayerIndex == (Common.Configuration.Hid.PlayerIndex)index); } } @@ -314,6 +314,7 @@ namespace Ryujinx.Input.HLE public void Dispose() { + GC.SuppressFinalize(this); Dispose(true); } } |
