Maze / Library /PackageCache /com.unity.inputsystem@1.6.1 /InputSystem /Plugins /Linux /LinuxSupport.cs
| using System; | |
| namespace UnityEngine.InputSystem.Linux | |
| { | |
| // These structures are not explicitly assigned, but they are filled in via JSON serialization coming from matching structs in native. | |
| internal enum JoystickFeatureType | |
| { | |
| Invalid = 0, | |
| Axis, | |
| Ball, | |
| Button, | |
| Hat, | |
| Max | |
| } | |
| internal enum SDLAxisUsage | |
| { | |
| Unknown = 0, | |
| X, | |
| Y, | |
| Z, | |
| RotateX, | |
| RotateY, | |
| RotateZ, | |
| Throttle, | |
| Rudder, | |
| Wheel, | |
| Gas, | |
| Brake, | |
| Hat0X, | |
| Hat0Y, | |
| Hat1X, | |
| Hat1Y, | |
| Hat2X, | |
| Hat2Y, | |
| Hat3X, | |
| Hat3Y, | |
| Count | |
| } | |
| internal enum SDLButtonUsage | |
| { | |
| Unknown = 0, | |
| Trigger, | |
| Thumb, | |
| Thumb2, | |
| Top, | |
| Top2, | |
| Pinkie, | |
| Base, | |
| Base2, | |
| Base3, | |
| Base4, | |
| Base5, | |
| Base6, | |
| Dead, | |
| A, | |
| B, | |
| X, | |
| Y, | |
| Z, | |
| TriggerLeft, | |
| TriggerRight, | |
| TriggerLeft2, | |
| TriggerRight2, | |
| Select, | |
| Start, | |
| Mode, | |
| ThumbLeft, | |
| ThumbRight, | |
| Count | |
| } | |
| // JSON must match JoystickFeatureDefinition in native. | |
| [] | |
| internal struct SDLFeatureDescriptor | |
| { | |
| public JoystickFeatureType featureType; | |
| public int usageHint; | |
| public int featureSize; | |
| public int offset; | |
| public int bit; | |
| public int min; | |
| public int max; | |
| } | |
| [] | |
| internal class SDLDeviceDescriptor | |
| { | |
| public SDLFeatureDescriptor[] controls; | |
| internal string ToJson() | |
| { | |
| return JsonUtility.ToJson(this); | |
| } | |
| internal static SDLDeviceDescriptor FromJson(string json) | |
| { | |
| return JsonUtility.FromJson<SDLDeviceDescriptor>(json); | |
| } | |
| } | |
| /// <summary> | |
| /// A small helper class to aid in initializing and registering SDL devices and layout builders. | |
| /// </summary> | |
| public | |
| internal | |
| static class LinuxSupport | |
| { | |
| /// <summary> | |
| /// The current interface code sent with devices to identify as Linux SDL devices. | |
| /// </summary> | |
| internal const string kInterfaceName = "Linux"; | |
| public static string GetAxisNameFromUsage(SDLAxisUsage usage) | |
| { | |
| return Enum.GetName(typeof(SDLAxisUsage), usage); | |
| } | |
| public static string GetButtonNameFromUsage(SDLButtonUsage usage) | |
| { | |
| return Enum.GetName(typeof(SDLButtonUsage), usage); | |
| } | |
| /// <summary> | |
| /// Registers all initial templates and the generalized layout builder with the InputSystem. | |
| /// </summary> | |
| public static void Initialize() | |
| { | |
| InputSystem.onFindLayoutForDevice += SDLLayoutBuilder.OnFindLayoutForDevice; | |
| } | |
| } | |
| } | |