Maze / Library /PackageCache /com.unity.inputsystem@1.6.1 /InputSystem /Plugins /iOS /IOSGameController.cs
| using System.Runtime.InteropServices; | |
| using UnityEngine.InputSystem.DualShock; | |
| using UnityEngine.InputSystem.Layouts; | |
| using UnityEngine.InputSystem.LowLevel; | |
| using UnityEngine.InputSystem.iOS.LowLevel; | |
| using UnityEngine.InputSystem.Utilities; | |
| namespace UnityEngine.InputSystem.iOS.LowLevel | |
| { | |
| internal enum iOSButton | |
| { | |
| DpadUp, | |
| DpadDown, | |
| DpadLeft, | |
| DpadRight, | |
| LeftStick, | |
| RightStick, | |
| LeftShoulder, | |
| RightShoulder, | |
| LeftTrigger, | |
| RightTrigger, | |
| X, | |
| Y, | |
| A, | |
| B, | |
| Start, | |
| Select | |
| // Note: If you'll add an element here, be sure to update kMaxButtons const below | |
| }; | |
| internal enum iOSAxis | |
| { | |
| LeftStickX, | |
| LeftStickY, | |
| RightStickX, | |
| RightStickY | |
| // Note: If you'll add an element here, be sure to update kMaxAxis const below | |
| }; | |
| [] | |
| internal unsafe struct iOSGameControllerState : IInputStateTypeInfo | |
| { | |
| public static FourCC kFormat = new FourCC('I', 'G', 'C', ' '); | |
| public const int MaxButtons = (int)iOSButton.Select + 1; | |
| public const int MaxAxis = (int)iOSAxis.RightStickY + 1; | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| [] | |
| public uint buttons; | |
| [] | |
| [] | |
| public fixed float buttonValues[MaxButtons]; | |
| private const uint kAxisOffset = sizeof(uint) + sizeof(float) * MaxButtons; | |
| [] | |
| [] | |
| public fixed float axisValues[MaxAxis]; | |
| public FourCC format => kFormat; | |
| public iOSGameControllerState WithButton(iOSButton button, bool value = true, float rawValue = 1.0f) | |
| { | |
| buttonValues[(int)button] = rawValue; | |
| Debug.Assert((int)button < 32, $"Expected button < 32, so we fit into the 32 bit wide bitmask"); | |
| var bit = 1U << (int)button; | |
| if (value) | |
| buttons |= bit; | |
| else | |
| buttons &= ~bit; | |
| return this; | |
| } | |
| public iOSGameControllerState WithAxis(iOSAxis axis, float value) | |
| { | |
| axisValues[(int)axis] = value; | |
| return this; | |
| } | |
| } | |
| } | |
| namespace UnityEngine.InputSystem.iOS | |
| { | |
| /// <summary> | |
| /// A generic Gamepad connected to an iOS device. | |
| /// </summary> | |
| /// <remarks> | |
| /// Any MFi-certified Gamepad which is not an <see cref="XboxOneGampadiOS"/> or <see cref="DualShock4GampadiOS"/> will | |
| /// be represented as an iOSGameController. | |
| /// </remarks> | |
| [] | |
| public class iOSGameController : Gamepad | |
| { | |
| } | |
| /// <summary> | |
| /// An Xbox One Bluetooth controller connected to an iOS device. | |
| /// </summary> | |
| [] | |
| public class XboxOneGampadiOS : XInput.XInputController | |
| { | |
| } | |
| /// <summary> | |
| /// A PlayStation DualShock 4 controller connected to an iOS device. | |
| /// </summary> | |
| [] | |
| public class DualShock4GampadiOS : DualShockGamepad | |
| { | |
| } | |
| /// <summary> | |
| /// A PlayStation DualSense controller connected to an iOS device. | |
| /// </summary> | |
| [] | |
| public class DualSenseGampadiOS : DualShockGamepad | |
| { | |
| } | |
| } | |