diff options
| author | mageven <62494521+mageven@users.noreply.github.com> | 2020-04-03 05:40:02 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-03 11:10:02 +1100 |
| commit | 2365ddfc363e76ac1ac9d2e32ef9b36b85463431 (patch) | |
| tree | 408bdb4a35e4f625a69ddbd65f22e9f056f7ebec /Ryujinx.HLE/HOS/Services/Hid/HidServer | |
| parent | 5b5239ab5b452f991d9fc4f8ad1f9a2880b8bad1 (diff) | |
HID SharedMem Rework (#1003)
* Delete old HLE.Input
* Add new HLE Input.
git shows Hid.cs as modified because of the same name. It is new.
* Change HID Service
* Change Ryujinx UI to reflect new Input
* Add basic ControllerApplet
* Add DebugPad
Should fix Kirby Star Allies
* Address Ac_K's comments
* Moved all of HLE.Input to Services.Hid
* Separated all structs and enums each to a file
* Removed vars
* Made some naming changes to align with switchbrew
* Added official joycon colors
As an aside, fixed a mistake in touchscreen headers and added checks to
important SharedMem structs at init time.
* Further address Ac_K's comments
* Addressed gdkchan's and some more Ac_K's comments
* Address AcK's review comments
* Address AcK's second review comments
* Replace missed Marshal.SizeOf and address gdkchan's comments
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Hid/HidServer')
11 files changed, 114 insertions, 36 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Hid/HidServer/HidUtils.cs b/Ryujinx.HLE/HOS/Services/Hid/HidServer/HidUtils.cs index c89ea306..c2cd8432 100644 --- a/Ryujinx.HLE/HOS/Services/Hid/HidServer/HidUtils.cs +++ b/Ryujinx.HLE/HOS/Services/Hid/HidServer/HidUtils.cs @@ -1,46 +1,39 @@ -using Ryujinx.HLE.Input; -using System; +using System; namespace Ryujinx.HLE.HOS.Services.Hid.HidServer { static class HidUtils { - public static ControllerId GetIndexFromNpadIdType(HidNpadIdType npadIdType) + public static PlayerIndex GetIndexFromNpadIdType(NpadIdType npadIdType) + => npadIdType switch { - switch (npadIdType) - { - case HidNpadIdType.Player1: return ControllerId.ControllerPlayer1; - case HidNpadIdType.Player2: return ControllerId.ControllerPlayer2; - case HidNpadIdType.Player3: return ControllerId.ControllerPlayer3; - case HidNpadIdType.Player4: return ControllerId.ControllerPlayer4; - case HidNpadIdType.Player5: return ControllerId.ControllerPlayer5; - case HidNpadIdType.Player6: return ControllerId.ControllerPlayer6; - case HidNpadIdType.Player7: return ControllerId.ControllerPlayer7; - case HidNpadIdType.Player8: return ControllerId.ControllerPlayer8; - case HidNpadIdType.Handheld: return ControllerId.ControllerHandheld; - case HidNpadIdType.Unknown: return ControllerId.ControllerUnknown; + NpadIdType.Player1 => PlayerIndex.Player1, + NpadIdType.Player2 => PlayerIndex.Player2, + NpadIdType.Player3 => PlayerIndex.Player3, + NpadIdType.Player4 => PlayerIndex.Player4, + NpadIdType.Player5 => PlayerIndex.Player5, + NpadIdType.Player6 => PlayerIndex.Player6, + NpadIdType.Player7 => PlayerIndex.Player7, + NpadIdType.Player8 => PlayerIndex.Player8, + NpadIdType.Handheld => PlayerIndex.Handheld, + NpadIdType.Unknown => PlayerIndex.Unknown, + _ => throw new ArgumentOutOfRangeException(nameof(npadIdType)) + }; - default: throw new ArgumentOutOfRangeException(nameof(npadIdType)); - } - } - - public static HidNpadIdType GetNpadIdTypeFromIndex(ControllerId index) + public static NpadIdType GetNpadIdTypeFromIndex(PlayerIndex index) + => index switch { - switch (index) - { - case ControllerId.ControllerPlayer1: return HidNpadIdType.Player1; - case ControllerId.ControllerPlayer2: return HidNpadIdType.Player2; - case ControllerId.ControllerPlayer3: return HidNpadIdType.Player3; - case ControllerId.ControllerPlayer4: return HidNpadIdType.Player4; - case ControllerId.ControllerPlayer5: return HidNpadIdType.Player5; - case ControllerId.ControllerPlayer6: return HidNpadIdType.Player6; - case ControllerId.ControllerPlayer7: return HidNpadIdType.Player7; - case ControllerId.ControllerPlayer8: return HidNpadIdType.Player8; - case ControllerId.ControllerHandheld: return HidNpadIdType.Handheld; - case ControllerId.ControllerUnknown: return HidNpadIdType.Unknown; - - default: throw new ArgumentOutOfRangeException(nameof(index)); - } - } + PlayerIndex.Player1 => NpadIdType.Player1, + PlayerIndex.Player2 => NpadIdType.Player2, + PlayerIndex.Player3 => NpadIdType.Player3, + PlayerIndex.Player4 => NpadIdType.Player4, + PlayerIndex.Player5 => NpadIdType.Player5, + PlayerIndex.Player6 => NpadIdType.Player6, + PlayerIndex.Player7 => NpadIdType.Player7, + PlayerIndex.Player8 => NpadIdType.Player8, + PlayerIndex.Handheld => NpadIdType.Handheld, + PlayerIndex.Unknown => NpadIdType.Unknown, + _ => throw new ArgumentOutOfRangeException(nameof(index)) + }; } }
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Npad/HidNpadHandheldActivationMode.cs b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Npad/HidNpadHandheldActivationMode.cs new file mode 100644 index 00000000..0aa8334d --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Npad/HidNpadHandheldActivationMode.cs @@ -0,0 +1,9 @@ +namespace Ryujinx.HLE.HOS.Services.Hid +{ + public enum HidNpadHandheldActivationMode + { + Dual, + Single, + None + } +}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Npad/HidNpadJoyAssignmentMode.cs b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Npad/HidNpadJoyAssignmentMode.cs new file mode 100644 index 00000000..a2e22661 --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Npad/HidNpadJoyAssignmentMode.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.HLE.HOS.Services.Hid +{ + public enum HidNpadJoyAssignmentMode + { + Dual, + Single + } +}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Npad/HidNpadJoyDeviceType.cs b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Npad/HidNpadJoyDeviceType.cs new file mode 100644 index 00000000..d0b34def --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Npad/HidNpadJoyDeviceType.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.HLE.HOS.Services.Hid +{ + public enum HidNpadJoyDeviceType + { + Left, + Right + } +}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/HidAccelerometerParameters.cs b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/HidAccelerometerParameters.cs new file mode 100644 index 00000000..fe7e4cc9 --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/HidAccelerometerParameters.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.HLE.HOS.Services.Hid +{ + public struct HidAccelerometerParameters + { + public float X; + public float Y; + } +}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/HidGyroscopeZeroDriftMode.cs b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/HidGyroscopeZeroDriftMode.cs new file mode 100644 index 00000000..cd3aa318 --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/HidGyroscopeZeroDriftMode.cs @@ -0,0 +1,9 @@ +namespace Ryujinx.HLE.HOS.Services.Hid +{ + public enum HidGyroscopeZeroDriftMode + { + Loose, + Standard, + Tight + } +}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/HidSensorFusionParameters.cs b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/HidSensorFusionParameters.cs new file mode 100644 index 00000000..cadf5ec0 --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/HidSensorFusionParameters.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.HLE.HOS.Services.Hid +{ + public struct HidSensorFusionParameters + { + public float RevisePower; + public float ReviseRange; + } +}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/HidVibrationDevicePosition.cs b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/HidVibrationDevicePosition.cs new file mode 100644 index 00000000..0ab84af3 --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/HidVibrationDevicePosition.cs @@ -0,0 +1,9 @@ +namespace Ryujinx.HLE.HOS.Services.Hid +{ + public enum HidVibrationDevicePosition + { + None, + Left, + Right + } +}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/HidVibrationDeviceType.cs b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/HidVibrationDeviceType.cs new file mode 100644 index 00000000..cf9e6498 --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/HidVibrationDeviceType.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.HLE.HOS.Services.Hid +{ + public enum HidVibrationDeviceType + { + None, + LinearResonantActuator + } +}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/HidVibrationDeviceValue.cs b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/HidVibrationDeviceValue.cs new file mode 100644 index 00000000..7905ecfd --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/HidVibrationDeviceValue.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.HLE.HOS.Services.Hid +{ + public struct HidVibrationDeviceValue + { + public HidVibrationDeviceType DeviceType; + public HidVibrationDevicePosition Position; + } +}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/HidVibrationValue.cs b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/HidVibrationValue.cs new file mode 100644 index 00000000..7211396e --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/HidVibrationValue.cs @@ -0,0 +1,10 @@ +namespace Ryujinx.HLE.HOS.Services.Hid +{ + public struct HidVibrationValue + { + public float AmplitudeLow; + public float FrequencyLow; + public float AmplitudeHigh; + public float FrequencyHigh; + } +}
\ No newline at end of file |
