Skip to content
Snippets Groups Projects

feat: controller raw input

Merged Ahmad Nadil requested to merge feat/controller-input into staging
Compare and
4 files
+ 149
165
Preferences
Compare changes
Files
4
+ 82
111
@@ -36,6 +36,24 @@ public partial class @PlayerInput: IInputActionCollection2, IDisposable
""interactions"": """",
""initialStateCheck"": true
},
{
""name"": ""Reload"",
""type"": ""Button"",
""id"": ""bdf299d4-51bb-492c-b276-c7c97f7db46a"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""Shoot"",
""type"": ""Button"",
""id"": ""3c4532d3-a95e-4d7d-a35e-fa5a9c426fca"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""Jump"",
""type"": ""Button"",
@@ -291,6 +309,50 @@ public partial class @PlayerInput: IInputActionCollection2, IDisposable
""action"": ""Sprint"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""2789497d-68da-4de8-9389-ab64254945ba"",
""path"": ""<Mouse>/leftButton"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Shoot"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""01ca45ca-8cab-417b-9cfb-cb11b9f101a8"",
""path"": ""<Gamepad>/rightTrigger"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Shoot"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""5d2e31f1-01e8-4b46-9e50-696e7562d3a2"",
""path"": ""<Keyboard>/r"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Reload"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""8f639a28-7027-4b11-aef0-1f39352fd379"",
""path"": ""<Gamepad>/buttonWest"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Reload"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
},
@@ -809,54 +871,6 @@ public partial class @PlayerInput: IInputActionCollection2, IDisposable
""isPartOfComposite"": false
}
]
},
{
""name"": ""Weapon"",
""id"": ""776c71f5-0fc4-4d1a-b6f7-57338ff8edd4"",
""actions"": [
{
""name"": ""Shoot"",
""type"": ""Button"",
""id"": ""e0d19276-edea-4a7f-abe4-a0ae1a59cef1"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""Reload"",
""type"": ""Button"",
""id"": ""de7dfd3f-21b0-4c00-8129-d5edd8f63489"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
{
""name"": """",
""id"": ""faaef20b-720d-4c61-97d0-70c1af6d33a5"",
""path"": ""<Mouse>/leftButton"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Shoot"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""fe2ea0d8-d159-4bfb-b630-b238a8e9c891"",
""path"": ""<Keyboard>/r"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Reload"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
],
""controlSchemes"": []
@@ -864,6 +878,8 @@ public partial class @PlayerInput: IInputActionCollection2, IDisposable
// OnFoot
m_OnFoot = asset.FindActionMap("OnFoot", throwIfNotFound: true);
m_OnFoot_Movement = m_OnFoot.FindAction("Movement", throwIfNotFound: true);
m_OnFoot_Reload = m_OnFoot.FindAction("Reload", throwIfNotFound: true);
m_OnFoot_Shoot = m_OnFoot.FindAction("Shoot", throwIfNotFound: true);
m_OnFoot_Jump = m_OnFoot.FindAction("Jump", throwIfNotFound: true);
m_OnFoot_Look = m_OnFoot.FindAction("Look", throwIfNotFound: true);
m_OnFoot_Interact = m_OnFoot.FindAction("Interact", throwIfNotFound: true);
@@ -881,10 +897,6 @@ public partial class @PlayerInput: IInputActionCollection2, IDisposable
m_UI_RightClick = m_UI.FindAction("RightClick", throwIfNotFound: true);
m_UI_TrackedDevicePosition = m_UI.FindAction("TrackedDevicePosition", throwIfNotFound: true);
m_UI_TrackedDeviceOrientation = m_UI.FindAction("TrackedDeviceOrientation", throwIfNotFound: true);
// Weapon
m_Weapon = asset.FindActionMap("Weapon", throwIfNotFound: true);
m_Weapon_Shoot = m_Weapon.FindAction("Shoot", throwIfNotFound: true);
m_Weapon_Reload = m_Weapon.FindAction("Reload", throwIfNotFound: true);
}
public void Dispose()
@@ -947,6 +959,8 @@ public partial class @PlayerInput: IInputActionCollection2, IDisposable
private readonly InputActionMap m_OnFoot;
private List<IOnFootActions> m_OnFootActionsCallbackInterfaces = new List<IOnFootActions>();
private readonly InputAction m_OnFoot_Movement;
private readonly InputAction m_OnFoot_Reload;
private readonly InputAction m_OnFoot_Shoot;
private readonly InputAction m_OnFoot_Jump;
private readonly InputAction m_OnFoot_Look;
private readonly InputAction m_OnFoot_Interact;
@@ -957,6 +971,8 @@ public partial class @PlayerInput: IInputActionCollection2, IDisposable
private @PlayerInput m_Wrapper;
public OnFootActions(@PlayerInput wrapper) { m_Wrapper = wrapper; }
public InputAction @Movement => m_Wrapper.m_OnFoot_Movement;
public InputAction @Reload => m_Wrapper.m_OnFoot_Reload;
public InputAction @Shoot => m_Wrapper.m_OnFoot_Shoot;
public InputAction @Jump => m_Wrapper.m_OnFoot_Jump;
public InputAction @Look => m_Wrapper.m_OnFoot_Look;
public InputAction @Interact => m_Wrapper.m_OnFoot_Interact;
@@ -974,6 +990,12 @@ public partial class @PlayerInput: IInputActionCollection2, IDisposable
@Movement.started += instance.OnMovement;
@Movement.performed += instance.OnMovement;
@Movement.canceled += instance.OnMovement;
@Reload.started += instance.OnReload;
@Reload.performed += instance.OnReload;
@Reload.canceled += instance.OnReload;
@Shoot.started += instance.OnShoot;
@Shoot.performed += instance.OnShoot;
@Shoot.canceled += instance.OnShoot;
@Jump.started += instance.OnJump;
@Jump.performed += instance.OnJump;
@Jump.canceled += instance.OnJump;
@@ -996,6 +1018,12 @@ public partial class @PlayerInput: IInputActionCollection2, IDisposable
@Movement.started -= instance.OnMovement;
@Movement.performed -= instance.OnMovement;
@Movement.canceled -= instance.OnMovement;
@Reload.started -= instance.OnReload;
@Reload.performed -= instance.OnReload;
@Reload.canceled -= instance.OnReload;
@Shoot.started -= instance.OnShoot;
@Shoot.performed -= instance.OnShoot;
@Shoot.canceled -= instance.OnShoot;
@Jump.started -= instance.OnJump;
@Jump.performed -= instance.OnJump;
@Jump.canceled -= instance.OnJump;
@@ -1146,63 +1174,11 @@ public partial class @PlayerInput: IInputActionCollection2, IDisposable
}
}
public UIActions @UI => new UIActions(this);
// Weapon
private readonly InputActionMap m_Weapon;
private List<IWeaponActions> m_WeaponActionsCallbackInterfaces = new List<IWeaponActions>();
private readonly InputAction m_Weapon_Shoot;
private readonly InputAction m_Weapon_Reload;
public struct WeaponActions
{
private @PlayerInput m_Wrapper;
public WeaponActions(@PlayerInput wrapper) { m_Wrapper = wrapper; }
public InputAction @Shoot => m_Wrapper.m_Weapon_Shoot;
public InputAction @Reload => m_Wrapper.m_Weapon_Reload;
public InputActionMap Get() { return m_Wrapper.m_Weapon; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(WeaponActions set) { return set.Get(); }
public void AddCallbacks(IWeaponActions instance)
{
if (instance == null || m_Wrapper.m_WeaponActionsCallbackInterfaces.Contains(instance)) return;
m_Wrapper.m_WeaponActionsCallbackInterfaces.Add(instance);
@Shoot.started += instance.OnShoot;
@Shoot.performed += instance.OnShoot;
@Shoot.canceled += instance.OnShoot;
@Reload.started += instance.OnReload;
@Reload.performed += instance.OnReload;
@Reload.canceled += instance.OnReload;
}
private void UnregisterCallbacks(IWeaponActions instance)
{
@Shoot.started -= instance.OnShoot;
@Shoot.performed -= instance.OnShoot;
@Shoot.canceled -= instance.OnShoot;
@Reload.started -= instance.OnReload;
@Reload.performed -= instance.OnReload;
@Reload.canceled -= instance.OnReload;
}
public void RemoveCallbacks(IWeaponActions instance)
{
if (m_Wrapper.m_WeaponActionsCallbackInterfaces.Remove(instance))
UnregisterCallbacks(instance);
}
public void SetCallbacks(IWeaponActions instance)
{
foreach (var item in m_Wrapper.m_WeaponActionsCallbackInterfaces)
UnregisterCallbacks(item);
m_Wrapper.m_WeaponActionsCallbackInterfaces.Clear();
AddCallbacks(instance);
}
}
public WeaponActions @Weapon => new WeaponActions(this);
public interface IOnFootActions
{
void OnMovement(InputAction.CallbackContext context);
void OnReload(InputAction.CallbackContext context);
void OnShoot(InputAction.CallbackContext context);
void OnJump(InputAction.CallbackContext context);
void OnLook(InputAction.CallbackContext context);
void OnInteract(InputAction.CallbackContext context);
@@ -1222,9 +1198,4 @@ public partial class @PlayerInput: IInputActionCollection2, IDisposable
void OnTrackedDevicePosition(InputAction.CallbackContext context);
void OnTrackedDeviceOrientation(InputAction.CallbackContext context);
}
public interface IWeaponActions
{
void OnShoot(InputAction.CallbackContext context);
void OnReload(InputAction.CallbackContext context);
}
}