A game about forced loneliness, made by TACStudios
at master 109 lines 5.5 kB view raw
1#if UNITY_EDITOR || UNITY_STANDALONE_OSX || PACKAGE_DOCS_GENERATION 2using System.Runtime.InteropServices; 3using UnityEngine.InputSystem.Layouts; 4using UnityEngine.InputSystem.LowLevel; 5using UnityEngine.InputSystem.Utilities; 6using UnityEngine.InputSystem.OSX.LowLevel; 7using UnityEngine.InputSystem.Controls; 8 9namespace UnityEngine.InputSystem.OSX.LowLevel 10{ 11 /// <summary> 12 /// Structure of HID input reports for SteelSeries Nimbus+ controllers supported 13 /// via HID on OSX. 14 /// </summary> 15 [StructLayout(LayoutKind.Explicit, Size = 8)] 16 internal struct NimbusPlusHIDInputReport : IInputStateTypeInfo 17 { 18 /// <summary> 19 /// A dummy vendor ID made available by OSX when supporting Nimbus+ via HID. 20 /// This is exposed by OSX instead of the true SteelSeries vendor ID 0x1038. 21 /// </summary> 22 public const int OSXVendorId = 0xd; 23 24 /// <summary> 25 /// A dummy product ID made available by OSX when supporting Nimbus+ via HID. 26 /// This is exposed by OSX instead of the true Nimbus+ product ID 0x1422. 27 /// </summary> 28 public const int OSXProductId = 0x0; 29 30 public FourCC format => new FourCC('H', 'I', 'D'); 31 32 [InputControl(name = "leftStick", layout = "Stick", format = "VC2B")] 33 [InputControl(name = "leftStick/x", offset = 0, format = "SBYT", parameters = "")] 34 [InputControl(name = "leftStick/left", offset = 0, format = "SBYT", parameters = "clamp=1,clampMin=-1,clampMax=0,invert")] 35 [InputControl(name = "leftStick/right", offset = 0, format = "SBYT", parameters = "clamp=1,clampMin=0,clampMax=1")] 36 [InputControl(name = "leftStick/y", offset = 1, format = "SBYT", parameters = "")] 37 [InputControl(name = "leftStick/up", offset = 1, format = "SBYT", parameters = "clamp=1,clampMin=0,clampMax=1")] 38 [InputControl(name = "leftStick/down", offset = 1, format = "SBYT", parameters = "clamp=1,clampMin=-1,clampMax=0,invert")] 39 [FieldOffset(0)] public sbyte leftStickX; 40 [FieldOffset(1)] public sbyte leftStickY; 41 42 [InputControl(name = "rightStick", layout = "Stick", format = "VC2B")] 43 [InputControl(name = "rightStick/x", offset = 0, format = "SBYT")] 44 [InputControl(name = "rightStick/left", offset = 0, format = "SBYT", parameters = "clamp=1,clampMin=-1,clampMax=0,invert")] 45 [InputControl(name = "rightStick/right", offset = 0, format = "SBYT", parameters = "clamp=1,clampMin=0,clampMax=1")] 46 [InputControl(name = "rightStick/y", offset = 1, format = "SBYT")] 47 [InputControl(name = "rightStick/up", offset = 1, format = "SBYT", parameters = "clamp=1,clampMin=0,clampMax=1")] 48 [InputControl(name = "rightStick/down", offset = 1, format = "SBYT", parameters = "clamp=1,clampMin=-1,clampMax=0,invert")] 49 [FieldOffset(2)] public sbyte rightStickX; 50 [FieldOffset(3)] public sbyte rightStickY; 51 52 [InputControl(name = "leftTrigger", format = "BYTE")] 53 [FieldOffset(4)] public byte leftTrigger; 54 [InputControl(name = "rightTrigger", format = "BYTE")] 55 [FieldOffset(5)] public byte rightTrigger; 56 57 [InputControl(name = "dpad", format = "BIT", layout = "Dpad", sizeInBits = 4)] 58 [InputControl(name = "dpad/up", format = "BIT", bit = 0)] 59 [InputControl(name = "dpad/right", format = "BIT", bit = 1)] 60 [InputControl(name = "dpad/down", format = "BIT", bit = 2)] 61 [InputControl(name = "dpad/left", format = "BIT", bit = 3)] 62 [InputControl(name = "buttonSouth", displayName = "A", bit = 4)] 63 [InputControl(name = "buttonEast", displayName = "B", bit = 5)] 64 [InputControl(name = "buttonWest", displayName = "X", bit = 6)] 65 [InputControl(name = "buttonNorth", displayName = "Y", bit = 7)] 66 [FieldOffset(6)] public byte buttons1; 67 [InputControl(name = "leftShoulder", bit = 0)] 68 [InputControl(name = "rightShoulder", bit = 1)] 69 [InputControl(name = "leftStickPress", bit = 2)] 70 [InputControl(name = "rightStickPress", bit = 3)] 71 [InputControl(name = "homeButton", layout = "Button", bit = 4)] 72 [InputControl(name = "select", bit = 5)] 73 [InputControl(name = "start", bit = 6)] 74 [FieldOffset(7)] public byte buttons2; 75 } 76} 77 78namespace UnityEngine.InputSystem.OSX 79{ 80 /// <summary> 81 /// Steel Series Nimbus+ uses iOSGameController MFI when on iOS but 82 /// is just a standard HID on OSX. Note that the gamepad is made available 83 /// with incorrect VID/PID by OSX instead of the true VID/PID registred with 84 /// USB.org for this device. 85 /// </summary> 86 [InputControlLayout(stateType = typeof(NimbusPlusHIDInputReport), displayName = "Nimbus+ Gamepad")] 87 [Scripting.Preserve] 88 public class NimbusGamepadHid : Gamepad 89 { 90 /// <summary> 91 /// The center button in the middle section of the controller. 92 /// </summary> 93 /// <remarks> 94 /// Note that this button is also picked up by OS. 95 /// </remarks> 96 [InputControl(name = "homeButton", displayName = "Home", shortDisplayName = "Home")] 97 public ButtonControl homeButton { get; protected set; } 98 99 /// <inheritdoc /> 100 protected override void FinishSetup() 101 { 102 homeButton = GetChildControl<ButtonControl>("homeButton"); 103 Debug.Assert(homeButton != null); 104 105 base.FinishSetup(); 106 } 107 } 108} 109#endif // UNITY_EDITOR || UNITY_STANDALONE_OSX