Skip to content

Commit 05aebe3

Browse files
committed
Bug fixes and Input Actions layout fixes
1 parent bac7988 commit 05aebe3

File tree

10 files changed

+527
-1022
lines changed

10 files changed

+527
-1022
lines changed

Packages/webxr-interactions/Runtime/InputSystem/WebXRControllerModel.cs

Lines changed: 24 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,19 @@ public UpdateType updateType
134134

135135
[SerializeField] private Handedness hand;
136136

137-
[SerializeField]private XRBaseController xrController;
137+
[SerializeField] private XRBaseController xrController;
138+
139+
[SerializeField] private InputActionProperty positionActionProperty;
140+
[SerializeField] private InputActionProperty rotationActionProperty;
141+
[SerializeField] private InputActionProperty trackingStateActionProperty;
142+
[SerializeField] private InputActionProperty triggerActionProperty;
143+
[SerializeField] private InputActionProperty gripActionProperty;
144+
[SerializeField] private InputActionProperty touchpadActionProperty;
145+
[SerializeField] private InputActionProperty touchpadPressedActionProperty;
146+
[SerializeField] private InputActionProperty thumbstickActionProperty;
147+
[SerializeField] private InputActionProperty thumbstickPressedActionProperty;
148+
[SerializeField] private InputActionProperty buttonAActionProperty;
149+
[SerializeField] private InputActionProperty buttonBActionProperty;
138150

139151
#if WEBXR_INPUT_PROFILES
140152
private InputProfileLoader inputProfileLoader;
@@ -145,7 +157,6 @@ public UpdateType updateType
145157
private string loadedProfile = null;
146158
private bool loadedModel = false;
147159
private static Quaternion quat180 = Quaternion.Euler(0, 180, 0);
148-
private WebXRInputActions actions = null;
149160
private InputAction positionAction;
150161
private InputAction rotationAction;
151162
private InputAction trackingStateAction;
@@ -184,15 +195,7 @@ void BindPosition()
184195
if (m_PositionBound)
185196
return;
186197

187-
switch (hand)
188-
{
189-
case Handedness.Left:
190-
positionAction = actions.XRLeftHand.Position;
191-
break;
192-
case Handedness.Right:
193-
positionAction = actions.XRRightHand.Position;
194-
break;
195-
}
198+
positionAction = positionActionProperty.action;
196199
if (positionAction == null)
197200
return;
198201

@@ -206,15 +209,7 @@ void BindRotation()
206209
if (m_RotationBound)
207210
return;
208211

209-
switch (hand)
210-
{
211-
case Handedness.Left:
212-
rotationAction = actions.XRLeftHand.Rotation;
213-
break;
214-
case Handedness.Right:
215-
rotationAction = actions.XRRightHand.Rotation;
216-
break;
217-
}
212+
rotationAction = rotationActionProperty.action;
218213
if (rotationAction == null)
219214
return;
220215

@@ -228,15 +223,7 @@ void BindTrackingState()
228223
if (m_TrackingStateBound)
229224
return;
230225

231-
switch (hand)
232-
{
233-
case Handedness.Left:
234-
trackingStateAction = actions.XRLeftHand.TrackingState;
235-
break;
236-
case Handedness.Right:
237-
trackingStateAction = actions.XRRightHand.TrackingState;
238-
break;
239-
}
226+
trackingStateAction = trackingStateActionProperty.action;
240227
if (trackingStateAction == null)
241228
return;
242229

@@ -252,29 +239,14 @@ void InitVisualActions()
252239

253240
buttonActions = new InputAction[6];
254241
axisActions = new InputAction[2];
255-
switch (hand)
256-
{
257-
case Handedness.Left:
258-
buttonActions[0] = actions.XRLeftHand.Trigger;
259-
buttonActions[1] = actions.XRLeftHand.Grip;
260-
buttonActions[2] = actions.XRLeftHand.TouchpadPressed;
261-
buttonActions[3] = actions.XRLeftHand.ThumbstickPressed;
262-
buttonActions[4] = actions.XRLeftHand.ButtonA;
263-
buttonActions[5] = actions.XRLeftHand.ButtonB;
264-
axisActions[0] = actions.XRLeftHand.Touchpad;
265-
axisActions[1] = actions.XRLeftHand.Thumbstick;
266-
break;
267-
case Handedness.Right:
268-
buttonActions[0] = actions.XRRightHand.Trigger;
269-
buttonActions[1] = actions.XRRightHand.Grip;
270-
buttonActions[2] = actions.XRRightHand.TouchpadPressed;
271-
buttonActions[3] = actions.XRRightHand.ThumbstickPressed;
272-
buttonActions[4] = actions.XRRightHand.ButtonA;
273-
buttonActions[5] = actions.XRRightHand.ButtonB;
274-
axisActions[0] = actions.XRRightHand.Touchpad;
275-
axisActions[1] = actions.XRRightHand.Thumbstick;
276-
break;
277-
}
242+
buttonActions[0] = triggerActionProperty.action;
243+
buttonActions[1] = gripActionProperty.action;
244+
buttonActions[2] = touchpadPressedActionProperty.action;
245+
buttonActions[3] = thumbstickPressedActionProperty.action;
246+
buttonActions[4] = buttonAActionProperty.action;
247+
buttonActions[5] = buttonBActionProperty.action;
248+
axisActions[0] = touchpadActionProperty.action;
249+
axisActions[1] = thumbstickActionProperty.action;
278250

279251
visualActionsInit = true;
280252
}
@@ -358,7 +330,6 @@ void OnTrackingStateCanceled(InputAction.CallbackContext context)
358330

359331
private void Awake()
360332
{
361-
actions = new WebXRInputActions();
362333
inputProfileLoader = rigOrigin.GetComponent<InputProfileLoader>();
363334
if (inputProfileLoader == null)
364335
{
@@ -381,7 +352,6 @@ private void Awake()
381352
/// </summary>
382353
protected void OnEnable()
383354
{
384-
actions.Enable();
385355
BindActions();
386356
InputSystem.onAfterUpdate += UpdateCallback;
387357

@@ -405,7 +375,6 @@ protected void OnEnable()
405375
/// </summary>
406376
protected void OnDisable()
407377
{
408-
actions.Disable();
409378
UnbindActions();
410379
InputSystem.onAfterUpdate -= UpdateCallback;
411380
switch (hand)

0 commit comments

Comments
 (0)