|
@@ -0,0 +1,277 @@
|
|
|
+
|
|
|
+
|
|
|
+using System;
|
|
|
+using System.Collections;
|
|
|
+using System.Collections.Generic;
|
|
|
+using UnityEngine.InputSystem;
|
|
|
+using UnityEngine.InputSystem.Utilities;
|
|
|
+
|
|
|
+public class @InputMaster : IInputActionCollection, IDisposable
|
|
|
+{
|
|
|
+ public InputActionAsset asset { get; }
|
|
|
+ public @InputMaster()
|
|
|
+ {
|
|
|
+ asset = InputActionAsset.FromJson(@"{
|
|
|
+ ""name"": ""InputMaster"",
|
|
|
+ ""maps"": [
|
|
|
+ {
|
|
|
+ ""name"": ""Player"",
|
|
|
+ ""id"": ""c0e731dc-cca5-4e31-9e39-322320614628"",
|
|
|
+ ""actions"": [
|
|
|
+ {
|
|
|
+ ""name"": ""Steer"",
|
|
|
+ ""type"": ""Value"",
|
|
|
+ ""id"": ""0c2e0063-2a71-41fa-8558-c860d648d00a"",
|
|
|
+ ""expectedControlType"": ""Analog"",
|
|
|
+ ""processors"": """",
|
|
|
+ ""interactions"": """"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ ""name"": ""Lean"",
|
|
|
+ ""type"": ""Value"",
|
|
|
+ ""id"": ""11b8defd-5887-45af-b2e8-f3442e007bcf"",
|
|
|
+ ""expectedControlType"": ""Analog"",
|
|
|
+ ""processors"": """",
|
|
|
+ ""interactions"": """"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ ""name"": ""Speed"",
|
|
|
+ ""type"": ""Value"",
|
|
|
+ ""id"": ""0368d4e7-2254-4f77-a048-c03d5a9e9466"",
|
|
|
+ ""expectedControlType"": ""Analog"",
|
|
|
+ ""processors"": """",
|
|
|
+ ""interactions"": """"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ ""bindings"": [
|
|
|
+ {
|
|
|
+ ""name"": ""1D Axis"",
|
|
|
+ ""id"": ""809e58c9-063d-4091-85dd-c6912da7887c"",
|
|
|
+ ""path"": ""1DAxis(minValue=-20,maxValue=20)"",
|
|
|
+ ""interactions"": """",
|
|
|
+ ""processors"": """",
|
|
|
+ ""groups"": """",
|
|
|
+ ""action"": ""Steer"",
|
|
|
+ ""isComposite"": true,
|
|
|
+ ""isPartOfComposite"": false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ ""name"": ""negative"",
|
|
|
+ ""id"": ""918a761d-d749-4fab-943b-b15b684ff46b"",
|
|
|
+ ""path"": ""<Gamepad>/leftStick/left"",
|
|
|
+ ""interactions"": """",
|
|
|
+ ""processors"": """",
|
|
|
+ ""groups"": ""Xbox Control Scheme"",
|
|
|
+ ""action"": ""Steer"",
|
|
|
+ ""isComposite"": false,
|
|
|
+ ""isPartOfComposite"": true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ ""name"": ""positive"",
|
|
|
+ ""id"": ""d09cba85-d987-46fc-89c7-98a9410da5ea"",
|
|
|
+ ""path"": ""<Gamepad>/leftStick/right"",
|
|
|
+ ""interactions"": """",
|
|
|
+ ""processors"": """",
|
|
|
+ ""groups"": ""Xbox Control Scheme"",
|
|
|
+ ""action"": ""Steer"",
|
|
|
+ ""isComposite"": false,
|
|
|
+ ""isPartOfComposite"": true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ ""name"": ""1D Axis"",
|
|
|
+ ""id"": ""ca704029-9a84-41e8-9def-5edf0439737a"",
|
|
|
+ ""path"": ""1DAxis(minValue=-20,maxValue=20)"",
|
|
|
+ ""interactions"": """",
|
|
|
+ ""processors"": """",
|
|
|
+ ""groups"": """",
|
|
|
+ ""action"": ""Lean"",
|
|
|
+ ""isComposite"": true,
|
|
|
+ ""isPartOfComposite"": false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ ""name"": ""negative"",
|
|
|
+ ""id"": ""02ebe08c-4529-44b9-9d52-47c3454c09ed"",
|
|
|
+ ""path"": ""<Gamepad>/rightStick/left"",
|
|
|
+ ""interactions"": """",
|
|
|
+ ""processors"": """",
|
|
|
+ ""groups"": ""Xbox Control Scheme"",
|
|
|
+ ""action"": ""Lean"",
|
|
|
+ ""isComposite"": false,
|
|
|
+ ""isPartOfComposite"": true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ ""name"": ""positive"",
|
|
|
+ ""id"": ""afcc1116-c915-451a-9058-b47acbc00d4d"",
|
|
|
+ ""path"": ""<Gamepad>/rightStick/right"",
|
|
|
+ ""interactions"": """",
|
|
|
+ ""processors"": """",
|
|
|
+ ""groups"": ""Xbox Control Scheme"",
|
|
|
+ ""action"": ""Lean"",
|
|
|
+ ""isComposite"": false,
|
|
|
+ ""isPartOfComposite"": true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ ""name"": ""1D Axis"",
|
|
|
+ ""id"": ""ef5544f0-948e-4ac2-9b5a-740ab381b571"",
|
|
|
+ ""path"": ""1DAxis(minValue=-300,maxValue=300)"",
|
|
|
+ ""interactions"": """",
|
|
|
+ ""processors"": """",
|
|
|
+ ""groups"": """",
|
|
|
+ ""action"": ""Speed"",
|
|
|
+ ""isComposite"": true,
|
|
|
+ ""isPartOfComposite"": false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ ""name"": ""negative"",
|
|
|
+ ""id"": ""190c1e38-5a07-4cf2-ac16-b1d89d70a921"",
|
|
|
+ ""path"": ""<Gamepad>/leftTrigger"",
|
|
|
+ ""interactions"": """",
|
|
|
+ ""processors"": """",
|
|
|
+ ""groups"": ""Xbox Control Scheme"",
|
|
|
+ ""action"": ""Speed"",
|
|
|
+ ""isComposite"": false,
|
|
|
+ ""isPartOfComposite"": true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ ""name"": ""positive"",
|
|
|
+ ""id"": ""aa7db5f0-9d6e-44b0-bdd2-fad109320909"",
|
|
|
+ ""path"": ""<Gamepad>/rightTrigger"",
|
|
|
+ ""interactions"": """",
|
|
|
+ ""processors"": """",
|
|
|
+ ""groups"": ""Xbox Control Scheme"",
|
|
|
+ ""action"": ""Speed"",
|
|
|
+ ""isComposite"": false,
|
|
|
+ ""isPartOfComposite"": true
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ ""controlSchemes"": [
|
|
|
+ {
|
|
|
+ ""name"": ""Xbox Control Scheme"",
|
|
|
+ ""bindingGroup"": ""Xbox Control Scheme"",
|
|
|
+ ""devices"": [
|
|
|
+ {
|
|
|
+ ""devicePath"": ""<XInputController>"",
|
|
|
+ ""isOptional"": false,
|
|
|
+ ""isOR"": false
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+}");
|
|
|
+
|
|
|
+ m_Player = asset.FindActionMap("Player", throwIfNotFound: true);
|
|
|
+ m_Player_Steer = m_Player.FindAction("Steer", throwIfNotFound: true);
|
|
|
+ m_Player_Lean = m_Player.FindAction("Lean", throwIfNotFound: true);
|
|
|
+ m_Player_Speed = m_Player.FindAction("Speed", throwIfNotFound: true);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Dispose()
|
|
|
+ {
|
|
|
+ UnityEngine.Object.Destroy(asset);
|
|
|
+ }
|
|
|
+
|
|
|
+ public InputBinding? bindingMask
|
|
|
+ {
|
|
|
+ get => asset.bindingMask;
|
|
|
+ set => asset.bindingMask = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ReadOnlyArray<InputDevice>? devices
|
|
|
+ {
|
|
|
+ get => asset.devices;
|
|
|
+ set => asset.devices = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
|
|
|
+
|
|
|
+ public bool Contains(InputAction action)
|
|
|
+ {
|
|
|
+ return asset.Contains(action);
|
|
|
+ }
|
|
|
+
|
|
|
+ public IEnumerator<InputAction> GetEnumerator()
|
|
|
+ {
|
|
|
+ return asset.GetEnumerator();
|
|
|
+ }
|
|
|
+
|
|
|
+ IEnumerator IEnumerable.GetEnumerator()
|
|
|
+ {
|
|
|
+ return GetEnumerator();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Enable()
|
|
|
+ {
|
|
|
+ asset.Enable();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Disable()
|
|
|
+ {
|
|
|
+ asset.Disable();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private readonly InputActionMap m_Player;
|
|
|
+ private IPlayerActions m_PlayerActionsCallbackInterface;
|
|
|
+ private readonly InputAction m_Player_Steer;
|
|
|
+ private readonly InputAction m_Player_Lean;
|
|
|
+ private readonly InputAction m_Player_Speed;
|
|
|
+ public struct PlayerActions
|
|
|
+ {
|
|
|
+ private @InputMaster m_Wrapper;
|
|
|
+ public PlayerActions(@InputMaster wrapper) { m_Wrapper = wrapper; }
|
|
|
+ public InputAction @Steer => m_Wrapper.m_Player_Steer;
|
|
|
+ public InputAction @Lean => m_Wrapper.m_Player_Lean;
|
|
|
+ public InputAction @Speed => m_Wrapper.m_Player_Speed;
|
|
|
+ public InputActionMap Get() { return m_Wrapper.m_Player; }
|
|
|
+ public void Enable() { Get().Enable(); }
|
|
|
+ public void Disable() { Get().Disable(); }
|
|
|
+ public bool enabled => Get().enabled;
|
|
|
+ public static implicit operator InputActionMap(PlayerActions set) { return set.Get(); }
|
|
|
+ public void SetCallbacks(IPlayerActions instance)
|
|
|
+ {
|
|
|
+ if (m_Wrapper.m_PlayerActionsCallbackInterface != null)
|
|
|
+ {
|
|
|
+ @Steer.started -= m_Wrapper.m_PlayerActionsCallbackInterface.OnSteer;
|
|
|
+ @Steer.performed -= m_Wrapper.m_PlayerActionsCallbackInterface.OnSteer;
|
|
|
+ @Steer.canceled -= m_Wrapper.m_PlayerActionsCallbackInterface.OnSteer;
|
|
|
+ @Lean.started -= m_Wrapper.m_PlayerActionsCallbackInterface.OnLean;
|
|
|
+ @Lean.performed -= m_Wrapper.m_PlayerActionsCallbackInterface.OnLean;
|
|
|
+ @Lean.canceled -= m_Wrapper.m_PlayerActionsCallbackInterface.OnLean;
|
|
|
+ @Speed.started -= m_Wrapper.m_PlayerActionsCallbackInterface.OnSpeed;
|
|
|
+ @Speed.performed -= m_Wrapper.m_PlayerActionsCallbackInterface.OnSpeed;
|
|
|
+ @Speed.canceled -= m_Wrapper.m_PlayerActionsCallbackInterface.OnSpeed;
|
|
|
+ }
|
|
|
+ m_Wrapper.m_PlayerActionsCallbackInterface = instance;
|
|
|
+ if (instance != null)
|
|
|
+ {
|
|
|
+ @Steer.started += instance.OnSteer;
|
|
|
+ @Steer.performed += instance.OnSteer;
|
|
|
+ @Steer.canceled += instance.OnSteer;
|
|
|
+ @Lean.started += instance.OnLean;
|
|
|
+ @Lean.performed += instance.OnLean;
|
|
|
+ @Lean.canceled += instance.OnLean;
|
|
|
+ @Speed.started += instance.OnSpeed;
|
|
|
+ @Speed.performed += instance.OnSpeed;
|
|
|
+ @Speed.canceled += instance.OnSpeed;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public PlayerActions @Player => new PlayerActions(this);
|
|
|
+ private int m_XboxControlSchemeSchemeIndex = -1;
|
|
|
+ public InputControlScheme XboxControlSchemeScheme
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ if (m_XboxControlSchemeSchemeIndex == -1) m_XboxControlSchemeSchemeIndex = asset.FindControlSchemeIndex("Xbox Control Scheme");
|
|
|
+ return asset.controlSchemes[m_XboxControlSchemeSchemeIndex];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public interface IPlayerActions
|
|
|
+ {
|
|
|
+ void OnSteer(InputAction.CallbackContext context);
|
|
|
+ void OnLean(InputAction.CallbackContext context);
|
|
|
+ void OnSpeed(InputAction.CallbackContext context);
|
|
|
+ }
|
|
|
+}
|