mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2025-02-24 06:04:33 +01:00
misc: chore: Use collection expressions in Input projects
This commit is contained in:
parent
9f3eac7f26
commit
45125c16cf
@ -23,8 +23,8 @@ namespace Ryujinx.Input.SDL2
|
|||||||
|
|
||||||
private StandardControllerInputConfig _configuration;
|
private StandardControllerInputConfig _configuration;
|
||||||
|
|
||||||
private static readonly SDL_GameControllerButton[] _buttonsDriverMapping = new SDL_GameControllerButton[(int)GamepadButtonInputId.Count]
|
private static readonly SDL_GameControllerButton[] _buttonsDriverMapping =
|
||||||
{
|
[
|
||||||
// Unbound, ignored.
|
// Unbound, ignored.
|
||||||
SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_INVALID,
|
SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_INVALID,
|
||||||
|
|
||||||
@ -59,19 +59,19 @@ namespace Ryujinx.Input.SDL2
|
|||||||
SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_INVALID,
|
SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_INVALID,
|
||||||
SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_INVALID,
|
SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_INVALID,
|
||||||
SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_INVALID,
|
SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_INVALID,
|
||||||
SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_INVALID,
|
SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_INVALID
|
||||||
};
|
];
|
||||||
|
|
||||||
private readonly Lock _userMappingLock = new();
|
private readonly Lock _userMappingLock = new();
|
||||||
|
|
||||||
private readonly List<ButtonMappingEntry> _buttonsUserMapping;
|
private readonly List<ButtonMappingEntry> _buttonsUserMapping;
|
||||||
|
|
||||||
private readonly StickInputId[] _stickUserMapping = new StickInputId[(int)StickInputId.Count]
|
private readonly StickInputId[] _stickUserMapping =
|
||||||
{
|
[
|
||||||
StickInputId.Unbound,
|
StickInputId.Unbound,
|
||||||
StickInputId.Left,
|
StickInputId.Left,
|
||||||
StickInputId.Right,
|
StickInputId.Right
|
||||||
};
|
];
|
||||||
|
|
||||||
public GamepadFeaturesFlag Features { get; }
|
public GamepadFeaturesFlag Features { get; }
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ namespace Ryujinx.Input.SDL2
|
|||||||
public SDL2GamepadDriver()
|
public SDL2GamepadDriver()
|
||||||
{
|
{
|
||||||
_gamepadsInstanceIdsMapping = new Dictionary<int, string>();
|
_gamepadsInstanceIdsMapping = new Dictionary<int, string>();
|
||||||
_gamepadsIds = new List<string>();
|
_gamepadsIds = [];
|
||||||
|
|
||||||
SDL2Driver.Instance.Initialize();
|
SDL2Driver.Instance.Initialize();
|
||||||
SDL2Driver.Instance.OnJoyStickConnected += HandleJoyStickConnected;
|
SDL2Driver.Instance.OnJoyStickConnected += HandleJoyStickConnected;
|
||||||
|
@ -27,8 +27,8 @@ namespace Ryujinx.Input.SDL2
|
|||||||
private StandardKeyboardInputConfig _configuration;
|
private StandardKeyboardInputConfig _configuration;
|
||||||
private readonly List<ButtonMappingEntry> _buttonsUserMapping;
|
private readonly List<ButtonMappingEntry> _buttonsUserMapping;
|
||||||
|
|
||||||
private static readonly SDL_Keycode[] _keysDriverMapping = new SDL_Keycode[(int)Key.Count]
|
private static readonly SDL_Keycode[] _keysDriverMapping =
|
||||||
{
|
[
|
||||||
// INVALID
|
// INVALID
|
||||||
SDL_Keycode.SDLK_0,
|
SDL_Keycode.SDLK_0,
|
||||||
// Presented as modifiers, so invalid here.
|
// Presented as modifiers, so invalid here.
|
||||||
@ -166,15 +166,15 @@ namespace Ryujinx.Input.SDL2
|
|||||||
SDL_Keycode.SDLK_BACKSLASH,
|
SDL_Keycode.SDLK_BACKSLASH,
|
||||||
|
|
||||||
// Invalids
|
// Invalids
|
||||||
SDL_Keycode.SDLK_0,
|
SDL_Keycode.SDLK_0
|
||||||
};
|
];
|
||||||
|
|
||||||
public SDL2Keyboard(SDL2KeyboardDriver driver, string id, string name)
|
public SDL2Keyboard(SDL2KeyboardDriver driver, string id, string name)
|
||||||
{
|
{
|
||||||
_driver = driver;
|
_driver = driver;
|
||||||
Id = id;
|
Id = id;
|
||||||
Name = name;
|
Name = name;
|
||||||
_buttonsUserMapping = new List<ButtonMappingEntry>();
|
_buttonsUserMapping = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool HasConfiguration => _configuration != null;
|
private bool HasConfiguration => _configuration != null;
|
||||||
|
@ -13,7 +13,7 @@ namespace Ryujinx.Input.SDL2
|
|||||||
|
|
||||||
public string DriverName => "SDL2";
|
public string DriverName => "SDL2";
|
||||||
|
|
||||||
private static readonly string[] _keyboardIdentifers = new string[1] { "0" };
|
private static readonly string[] _keyboardIdentifers = ["0"];
|
||||||
|
|
||||||
public ReadOnlySpan<string> GamepadsIds => _keyboardIdentifers;
|
public ReadOnlySpan<string> GamepadsIds => _keyboardIdentifers;
|
||||||
|
|
||||||
|
@ -27,7 +27,8 @@ namespace Ryujinx.Input.HLE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly HLEButtonMappingEntry[] _hleButtonMapping = {
|
private static readonly HLEButtonMappingEntry[] _hleButtonMapping =
|
||||||
|
[
|
||||||
new(GamepadButtonInputId.A, ControllerKeys.A),
|
new(GamepadButtonInputId.A, ControllerKeys.A),
|
||||||
new(GamepadButtonInputId.B, ControllerKeys.B),
|
new(GamepadButtonInputId.B, ControllerKeys.B),
|
||||||
new(GamepadButtonInputId.X, ControllerKeys.X),
|
new(GamepadButtonInputId.X, ControllerKeys.X),
|
||||||
@ -48,8 +49,8 @@ namespace Ryujinx.Input.HLE
|
|||||||
new(GamepadButtonInputId.SingleLeftTrigger0, ControllerKeys.SlLeft),
|
new(GamepadButtonInputId.SingleLeftTrigger0, ControllerKeys.SlLeft),
|
||||||
new(GamepadButtonInputId.SingleRightTrigger0, ControllerKeys.SrLeft),
|
new(GamepadButtonInputId.SingleRightTrigger0, ControllerKeys.SrLeft),
|
||||||
new(GamepadButtonInputId.SingleLeftTrigger1, ControllerKeys.SlRight),
|
new(GamepadButtonInputId.SingleLeftTrigger1, ControllerKeys.SlRight),
|
||||||
new(GamepadButtonInputId.SingleRightTrigger1, ControllerKeys.SrRight),
|
new(GamepadButtonInputId.SingleRightTrigger1, ControllerKeys.SrRight)
|
||||||
};
|
];
|
||||||
|
|
||||||
private class HLEKeyboardMappingEntry
|
private class HLEKeyboardMappingEntry
|
||||||
{
|
{
|
||||||
@ -63,7 +64,8 @@ namespace Ryujinx.Input.HLE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly HLEKeyboardMappingEntry[] _keyMapping = {
|
private static readonly HLEKeyboardMappingEntry[] _keyMapping =
|
||||||
|
[
|
||||||
new(Key.A, 0x4),
|
new(Key.A, 0x4),
|
||||||
new(Key.B, 0x5),
|
new(Key.B, 0x5),
|
||||||
new(Key.C, 0x6),
|
new(Key.C, 0x6),
|
||||||
@ -186,10 +188,11 @@ namespace Ryujinx.Input.HLE
|
|||||||
new(Key.ControlRight, 0xE4),
|
new(Key.ControlRight, 0xE4),
|
||||||
new(Key.ShiftRight, 0xE5),
|
new(Key.ShiftRight, 0xE5),
|
||||||
new(Key.AltRight, 0xE6),
|
new(Key.AltRight, 0xE6),
|
||||||
new(Key.WinRight, 0xE7),
|
new(Key.WinRight, 0xE7)
|
||||||
};
|
];
|
||||||
|
|
||||||
private static readonly HLEKeyboardMappingEntry[] _keyModifierMapping = {
|
private static readonly HLEKeyboardMappingEntry[] _keyModifierMapping =
|
||||||
|
[
|
||||||
new(Key.ControlLeft, 0),
|
new(Key.ControlLeft, 0),
|
||||||
new(Key.ShiftLeft, 1),
|
new(Key.ShiftLeft, 1),
|
||||||
new(Key.AltLeft, 2),
|
new(Key.AltLeft, 2),
|
||||||
@ -200,8 +203,8 @@ namespace Ryujinx.Input.HLE
|
|||||||
new(Key.WinRight, 7),
|
new(Key.WinRight, 7),
|
||||||
new(Key.CapsLock, 8),
|
new(Key.CapsLock, 8),
|
||||||
new(Key.ScrollLock, 9),
|
new(Key.ScrollLock, 9),
|
||||||
new(Key.NumLock, 10),
|
new(Key.NumLock, 10)
|
||||||
};
|
];
|
||||||
|
|
||||||
private MotionInput _leftMotionInput;
|
private MotionInput _leftMotionInput;
|
||||||
private MotionInput _rightMotionInput;
|
private MotionInput _rightMotionInput;
|
||||||
|
@ -46,7 +46,7 @@ namespace Ryujinx.Input.HLE
|
|||||||
_keyboardDriver = keyboardDriver;
|
_keyboardDriver = keyboardDriver;
|
||||||
_gamepadDriver = gamepadDriver;
|
_gamepadDriver = gamepadDriver;
|
||||||
_mouseDriver = mouseDriver;
|
_mouseDriver = mouseDriver;
|
||||||
_inputConfig = new List<InputConfig>();
|
_inputConfig = [];
|
||||||
|
|
||||||
_gamepadDriver.OnGamepadConnected += HandleOnGamepadConnected;
|
_gamepadDriver.OnGamepadConnected += HandleOnGamepadConnected;
|
||||||
_gamepadDriver.OnGamepadDisconnected += HandleOnGamepadDisconnected;
|
_gamepadDriver.OnGamepadDisconnected += HandleOnGamepadDisconnected;
|
||||||
@ -56,7 +56,7 @@ namespace Ryujinx.Input.HLE
|
|||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
List<InputConfig> validInputs = new();
|
List<InputConfig> validInputs = [];
|
||||||
foreach (InputConfig inputConfigEntry in _inputConfig)
|
foreach (InputConfig inputConfigEntry in _inputConfig)
|
||||||
{
|
{
|
||||||
if (_controllers[(int)inputConfigEntry.PlayerIndex] != null)
|
if (_controllers[(int)inputConfigEntry.PlayerIndex] != null)
|
||||||
@ -124,7 +124,7 @@ namespace Ryujinx.Input.HLE
|
|||||||
{
|
{
|
||||||
NpadController[] oldControllers = _controllers.ToArray();
|
NpadController[] oldControllers = _controllers.ToArray();
|
||||||
|
|
||||||
List<InputConfig> validInputs = new();
|
List<InputConfig> validInputs = [];
|
||||||
|
|
||||||
foreach (InputConfig inputConfigEntry in inputConfig)
|
foreach (InputConfig inputConfigEntry in inputConfig)
|
||||||
{
|
{
|
||||||
@ -205,7 +205,7 @@ namespace Ryujinx.Input.HLE
|
|||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
List<GamepadInput> hleInputStates = new();
|
List<GamepadInput> hleInputStates = [];
|
||||||
List<SixAxisInput> hleMotionStates = new(NpadDevices.MaxControllers);
|
List<SixAxisInput> hleMotionStates = new(NpadDevices.MaxControllers);
|
||||||
|
|
||||||
KeyboardInput? hleKeyboardInput = null;
|
KeyboardInput? hleKeyboardInput = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user