aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs')
-rw-r--r--src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs75
1 files changed, 39 insertions, 36 deletions
diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs
index edcc47d8..240933ad 100644
--- a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs
+++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs
@@ -19,22 +19,22 @@ namespace Ryujinx.HLE.HOS.Services.Hid
public const int MaxControllers = 9; // Players 1-8 and Handheld
private ControllerType[] _configuredTypes;
- private KEvent[] _styleSetUpdateEvents;
- private bool[] _supportedPlayers;
- private static VibrationValue _neutralVibrationValue = new VibrationValue
+ private readonly KEvent[] _styleSetUpdateEvents;
+ private readonly bool[] _supportedPlayers;
+ private VibrationValue _neutralVibrationValue = new()
{
AmplitudeLow = 0f,
FrequencyLow = 160f,
AmplitudeHigh = 0f,
- FrequencyHigh = 320f
+ FrequencyHigh = 320f,
};
internal NpadJoyHoldType JoyHold { get; set; }
internal bool SixAxisActive = false; // TODO: link to hidserver when implemented
internal ControllerType SupportedStyleSets { get; set; }
- public Dictionary<PlayerIndex, ConcurrentQueue<(VibrationValue, VibrationValue)>> RumbleQueues = new Dictionary<PlayerIndex, ConcurrentQueue<(VibrationValue, VibrationValue)>>();
- public Dictionary<PlayerIndex, (VibrationValue, VibrationValue)> LastVibrationValues = new Dictionary<PlayerIndex, (VibrationValue, VibrationValue)>();
+ public Dictionary<PlayerIndex, ConcurrentQueue<(VibrationValue, VibrationValue)>> RumbleQueues = new();
+ public Dictionary<PlayerIndex, (VibrationValue, VibrationValue)> LastVibrationValues = new();
public NpadDevices(Switch device, bool active = true) : base(device, active)
{
@@ -129,7 +129,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
if (player > PlayerIndex.Handheld)
{
- throw new ArgumentOutOfRangeException("Player must be Player1-8 or Handheld");
+ throw new InvalidOperationException("Player must be Player1-8 or Handheld");
}
if (controllerType == ControllerType.Handheld)
@@ -249,6 +249,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
switch (type)
{
+#pragma warning disable IDE0055 // Disable formatting
case ControllerType.ProController:
controller.StyleSet = NpadStyleTag.FullKey;
controller.DeviceType = DeviceType.FullKey;
@@ -296,6 +297,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
controller.DeviceType = DeviceType.Palma;
controller.AppletFooterUiType = AppletFooterUiType.None;
break;
+#pragma warning restore IDE0055
}
_styleSetUpdateEvents[(int)player].ReadableEvent.Signal();
@@ -329,7 +331,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
{
if (!Unsafe.AreSame(ref currentlyUsed, ref possiblyUnused))
{
- NpadCommonState newState = new NpadCommonState();
+ NpadCommonState newState = new();
WriteNewInputEntry(ref possiblyUnused, ref newState);
}
@@ -348,7 +350,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
{
if (!Unsafe.AreSame(ref currentlyUsed, ref possiblyUnused))
{
- SixAxisSensorState newState = new SixAxisSensorState();
+ SixAxisSensorState newState = new();
WriteNewSixInputEntry(ref possiblyUnused, ref newState);
}
@@ -379,23 +381,22 @@ namespace Ryujinx.HLE.HOS.Services.Hid
ref RingLifo<NpadCommonState> lifo = ref GetCommonStateLifo(ref currentNpad);
- NpadCommonState newState = new NpadCommonState
+ NpadCommonState newState = new()
{
- Buttons = (NpadButton)state.Buttons,
+ Buttons = (NpadButton)state.Buttons,
AnalogStickL = new AnalogStickState
{
- X = state.LStick.Dx,
- Y = state.LStick.Dy,
+ X = state.LStick.Dx,
+ Y = state.LStick.Dy,
},
AnalogStickR = new AnalogStickState
{
- X = state.RStick.Dx,
- Y = state.RStick.Dy,
- }
+ X = state.RStick.Dx,
+ Y = state.RStick.Dy,
+ },
+ Attributes = NpadAttribute.IsConnected,
};
- newState.Attributes = NpadAttribute.IsConnected;
-
switch (currentNpad.StyleSet)
{
case NpadStyleTag.Handheld:
@@ -434,7 +435,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
{
ref NpadInternalState currentNpad = ref _device.Hid.SharedMemory.Npads[(int)index].InternalState;
- NpadCommonState newState = new NpadCommonState();
+ NpadCommonState newState = new();
WriteNewInputEntry(ref currentNpad.FullKey, ref newState);
WriteNewInputEntry(ref currentNpad.Handheld, ref newState);
@@ -514,33 +515,33 @@ namespace Ryujinx.HLE.HOS.Services.Hid
return false;
}
- HidVector accel = new HidVector()
+ HidVector accel = new()
{
X = state.Accelerometer.X,
Y = state.Accelerometer.Y,
- Z = state.Accelerometer.Z
+ Z = state.Accelerometer.Z,
};
- HidVector gyro = new HidVector()
+ HidVector gyro = new()
{
X = state.Gyroscope.X,
Y = state.Gyroscope.Y,
- Z = state.Gyroscope.Z
+ Z = state.Gyroscope.Z,
};
- HidVector rotation = new HidVector()
+ HidVector rotation = new()
{
X = state.Rotation.X,
Y = state.Rotation.Y,
- Z = state.Rotation.Z
+ Z = state.Rotation.Z,
};
- SixAxisSensorState newState = new SixAxisSensorState
+ SixAxisSensorState newState = new()
{
- Acceleration = accel,
+ Acceleration = accel,
AngularVelocity = gyro,
- Angle = rotation,
- Attributes = SixAxisSensorAttribute.IsConnected
+ Angle = rotation,
+ Attributes = SixAxisSensorAttribute.IsConnected,
};
state.Orientation.AsSpan().CopyTo(newState.Direction.AsSpan());
@@ -562,9 +563,10 @@ namespace Ryujinx.HLE.HOS.Services.Hid
if (!needUpdateRight && !isRightPair)
{
- SixAxisSensorState emptyState = new SixAxisSensorState();
-
- emptyState.Attributes = SixAxisSensorAttribute.IsConnected;
+ SixAxisSensorState emptyState = new()
+ {
+ Attributes = SixAxisSensorAttribute.IsConnected,
+ };
WriteNewSixInputEntry(ref currentNpad.JoyDualRightSixAxisSensor, ref emptyState);
}
@@ -576,9 +578,10 @@ namespace Ryujinx.HLE.HOS.Services.Hid
{
ref NpadInternalState currentNpad = ref _device.Hid.SharedMemory.Npads[(int)index].InternalState;
- SixAxisSensorState newState = new SixAxisSensorState();
-
- newState.Attributes = SixAxisSensorAttribute.IsConnected;
+ SixAxisSensorState newState = new()
+ {
+ Attributes = SixAxisSensorAttribute.IsConnected,
+ };
WriteNewSixInputEntry(ref currentNpad.FullKeySixAxisSensor, ref newState);
WriteNewSixInputEntry(ref currentNpad.HandheldSixAxisSensor, ref newState);
@@ -632,4 +635,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid
return rumbleQueue;
}
}
-} \ No newline at end of file
+}