Skip to content

Commit 9e003f0

Browse files
committed
Make WebXRInputSystem members and methods static.
Fix issues in WebXRControllerModel and WebXRController device.
1 parent 376a6ae commit 9e003f0

File tree

5 files changed

+138
-137
lines changed

5 files changed

+138
-137
lines changed

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

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ namespace WebXR.InputSystem
2020

2121
public class WebXRControllerModel : MonoBehaviour
2222
{
23-
public void OnControllerProfiles()
24-
{
25-
#if WEBXR_INPUT_PROFILES
26-
HandleOnControllerProfiles();
27-
#endif
28-
}
2923
#if UNITY_INPUT_SYSTEM_1_4_4_OR_NEWER
3024
/// <summary>
3125
/// Options for which <see cref="Transform"/> properties to update.
@@ -137,7 +131,7 @@ public UpdateType updateType
137131
set => m_UpdateType = value;
138132
}
139133

140-
[SerializeField] private WebXRInputSystem webXRInputSystem;
134+
[SerializeField] private GameObject rigOrigin;
141135

142136
[SerializeField] private Handedness hand;
143137

@@ -361,10 +355,10 @@ void OnTrackingStateCanceled(InputAction.CallbackContext context)
361355
private void Awake()
362356
{
363357
actions = new WebXRInputActions();
364-
inputProfileLoader = webXRInputSystem.GetComponent<InputProfileLoader>();
358+
inputProfileLoader = rigOrigin.GetComponent<InputProfileLoader>();
365359
if (inputProfileLoader == null)
366360
{
367-
inputProfileLoader = webXRInputSystem.gameObject.AddComponent<InputProfileLoader>();
361+
inputProfileLoader = rigOrigin.AddComponent<InputProfileLoader>();
368362
}
369363

370364
var profilesPaths = inputProfileLoader.GetProfilesPaths();
@@ -390,6 +384,15 @@ protected void OnEnable()
390384
// Read current input values when becoming enabled,
391385
// but wait until after the input update so the input is read at a consistent time
392386
m_IsFirstUpdate = true;
387+
switch (hand)
388+
{
389+
case Handedness.Left:
390+
WebXRInputSystem.OnLeftControllerProfiles += HandleOnControllerProfiles;
391+
break;
392+
case Handedness.Right:
393+
WebXRInputSystem.OnRightControllerProfiles += HandleOnControllerProfiles;
394+
break;
395+
}
393396
}
394397

395398
/// <summary>
@@ -400,6 +403,15 @@ protected void OnDisable()
400403
actions.Disable();
401404
UnbindActions();
402405
InputSystem.onAfterUpdate -= UpdateCallback;
406+
switch (hand)
407+
{
408+
case Handedness.Left:
409+
WebXRInputSystem.OnLeftControllerProfiles -= HandleOnControllerProfiles;
410+
break;
411+
case Handedness.Right:
412+
WebXRInputSystem.OnRightControllerProfiles -= HandleOnControllerProfiles;
413+
break;
414+
}
403415
}
404416

405417
/// <summary>
@@ -556,10 +568,10 @@ public void HandleOnControllerProfiles()
556568
switch (hand)
557569
{
558570
case Handedness.Left:
559-
profiles = webXRInputSystem.GetLeftProfiles();
571+
profiles = WebXRInputSystem.GetLeftProfiles();
560572
break;
561573
case Handedness.Right:
562-
profiles = webXRInputSystem.GetRightProfiles();
574+
profiles = WebXRInputSystem.GetRightProfiles();
563575
break;
564576
}
565577

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

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public @WebXRInputActions()
197197
{
198198
""name"": """",
199199
""id"": ""63aa790d-a8f4-45ba-9444-437bc2ee7dc7"",
200-
""path"": ""<XRController>{LeftHand}/grip"",
200+
""path"": ""<XRController>{LeftHand}/{Grip}"",
201201
""interactions"": """",
202202
""processors"": """",
203203
""groups"": ""XR"",
@@ -208,7 +208,7 @@ public @WebXRInputActions()
208208
{
209209
""name"": """",
210210
""id"": ""43ba5fd1-7873-48a9-8031-69f1a5eaf8ae"",
211-
""path"": ""<XRController>{LeftHand}/primary2DAxis"",
211+
""path"": ""<XRController>{LeftHand}/{Primary2DAxis}"",
212212
""interactions"": """",
213213
""processors"": """",
214214
""groups"": ""XR"",
@@ -219,7 +219,7 @@ public @WebXRInputActions()
219219
{
220220
""name"": """",
221221
""id"": ""7dda14be-31ab-439e-a6e3-246788dd66ba"",
222-
""path"": ""<XRController>{LeftHand}/secondary2DAxis"",
222+
""path"": ""<XRController>{LeftHand}/{Secondary2DAxis}"",
223223
""interactions"": """",
224224
""processors"": """",
225225
""groups"": ""XR"",
@@ -230,7 +230,7 @@ public @WebXRInputActions()
230230
{
231231
""name"": """",
232232
""id"": ""d2afcd0c-9ded-43be-9d93-b5f63cae20b6"",
233-
""path"": ""<XRController>{LeftHand}/primaryButton"",
233+
""path"": ""<XRController>{LeftHand}/{PrimaryButton}"",
234234
""interactions"": """",
235235
""processors"": """",
236236
""groups"": ""XR"",
@@ -241,7 +241,7 @@ public @WebXRInputActions()
241241
{
242242
""name"": """",
243243
""id"": ""17f38512-dbc2-4572-ba83-b15851668b47"",
244-
""path"": ""<XRController>{LeftHand}/secondaryButton"",
244+
""path"": ""<XRController>{LeftHand}/{SecondaryButton}"",
245245
""interactions"": """",
246246
""processors"": """",
247247
""groups"": ""XR"",
@@ -252,7 +252,7 @@ public @WebXRInputActions()
252252
{
253253
""name"": """",
254254
""id"": ""3ceae2e0-3858-4197-a3bd-be17f192ccaa"",
255-
""path"": ""<XRController>{LeftHand}/secondary2DAxisClick"",
255+
""path"": ""<XRController>{LeftHand}/{Secondary2DAxisClick}"",
256256
""interactions"": """",
257257
""processors"": """",
258258
""groups"": ""XR"",
@@ -263,7 +263,7 @@ public @WebXRInputActions()
263263
{
264264
""name"": """",
265265
""id"": ""40f0145a-23fe-41f6-a684-e7d6dc62b23c"",
266-
""path"": ""<XRController>{LeftHand}/primary2DAxisClick"",
266+
""path"": ""<XRController>{LeftHand}/{Primary2DAxisClick}"",
267267
""interactions"": """",
268268
""processors"": """",
269269
""groups"": ""XR"",
@@ -325,7 +325,7 @@ public @WebXRInputActions()
325325
{
326326
""name"": ""Grip"",
327327
""type"": ""Value"",
328-
""id"": ""c4e66c4b-9887-4b92-9986-639cd146f6f8"",
328+
""id"": ""202b5135-089e-42d8-9a55-352c574df867"",
329329
""expectedControlType"": ""Axis"",
330330
""processors"": """",
331331
""interactions"": """",
@@ -334,7 +334,7 @@ public @WebXRInputActions()
334334
{
335335
""name"": ""Thumbstick"",
336336
""type"": ""Value"",
337-
""id"": ""541a6e85-c787-4c47-a098-ab52932f8eec"",
337+
""id"": ""fbd3f2c6-d870-40a1-9e77-a6550e2d0cdd"",
338338
""expectedControlType"": ""Vector2"",
339339
""processors"": """",
340340
""interactions"": """",
@@ -343,7 +343,7 @@ public @WebXRInputActions()
343343
{
344344
""name"": ""ThumbstickPressed"",
345345
""type"": ""Button"",
346-
""id"": ""034afb4f-da27-441e-b22f-76c53054eb93"",
346+
""id"": ""74c8ada5-db72-4e69-87ff-405afc4d9168"",
347347
""expectedControlType"": ""Button"",
348348
""processors"": """",
349349
""interactions"": """",
@@ -352,7 +352,7 @@ public @WebXRInputActions()
352352
{
353353
""name"": ""Touchpad"",
354354
""type"": ""Value"",
355-
""id"": ""9d2a1772-bcae-40c4-bc28-d36d7447db27"",
355+
""id"": ""7dd105e7-f8dd-43ab-af8b-5ab964c5fed2"",
356356
""expectedControlType"": ""Vector2"",
357357
""processors"": """",
358358
""interactions"": """",
@@ -361,7 +361,7 @@ public @WebXRInputActions()
361361
{
362362
""name"": ""TouchpadPressed"",
363363
""type"": ""Button"",
364-
""id"": ""6059657c-efaf-43f0-aa48-8296f9697b81"",
364+
""id"": ""a68c8312-3f17-42f5-81e7-77a46f022acd"",
365365
""expectedControlType"": ""Button"",
366366
""processors"": """",
367367
""interactions"": """",
@@ -370,7 +370,7 @@ public @WebXRInputActions()
370370
{
371371
""name"": ""ButtonA"",
372372
""type"": ""Button"",
373-
""id"": ""b8498c86-f27e-490d-b6fc-cb116d42c422"",
373+
""id"": ""06855edf-5fec-4a4c-868a-0af4d323e81c"",
374374
""expectedControlType"": ""Button"",
375375
""processors"": """",
376376
""interactions"": """",
@@ -379,7 +379,7 @@ public @WebXRInputActions()
379379
{
380380
""name"": ""ButtonB"",
381381
""type"": ""Button"",
382-
""id"": ""62b343c7-ac5d-4dc7-99d7-4b6e5f8a0b65"",
382+
""id"": ""a2a2bc86-b6c0-4c49-a205-947101fe0d78"",
383383
""expectedControlType"": ""Button"",
384384
""processors"": """",
385385
""interactions"": """",
@@ -422,100 +422,100 @@ public @WebXRInputActions()
422422
},
423423
{
424424
""name"": """",
425-
""id"": ""376297e2-c885-44e9-97a3-a465484866b8"",
426-
""path"": ""<XRController>{RightHand}/grip"",
425+
""id"": ""cab631e7-1c7b-4c82-9466-36fbf509a3d0"",
426+
""path"": ""<XRController>{RightHand}/deviceRotation"",
427427
""interactions"": """",
428428
""processors"": """",
429429
""groups"": ""XR"",
430-
""action"": ""Grip"",
430+
""action"": ""Rotation"",
431431
""isComposite"": false,
432432
""isPartOfComposite"": false
433433
},
434434
{
435435
""name"": """",
436-
""id"": ""1db38c6b-afbb-4a14-a7b2-f8b890fb5532"",
437-
""path"": ""<XRController>{RightHand}/primary2DAxis"",
436+
""id"": ""fb242f7f-5575-4104-a77c-0ed5f8aa1b4a"",
437+
""path"": ""<XRController>{RightHand}/devicePosition"",
438438
""interactions"": """",
439439
""processors"": """",
440440
""groups"": ""XR"",
441-
""action"": ""Thumbstick"",
441+
""action"": ""Position"",
442442
""isComposite"": false,
443443
""isPartOfComposite"": false
444444
},
445445
{
446446
""name"": """",
447-
""id"": ""243771b7-1d06-4366-9d07-766646db5d60"",
448-
""path"": ""<XRController>{RightHand}/primary2DAxisClick"",
447+
""id"": ""46fd4683-77c3-4db4-a329-02c985e617a3"",
448+
""path"": ""<XRController>{RightHand}/{Grip}"",
449449
""interactions"": """",
450450
""processors"": """",
451451
""groups"": ""XR"",
452-
""action"": ""ThumbstickPressed"",
452+
""action"": ""Grip"",
453453
""isComposite"": false,
454454
""isPartOfComposite"": false
455455
},
456456
{
457457
""name"": """",
458-
""id"": ""c7115824-4365-4b20-9ff0-67149d190bf0"",
459-
""path"": ""<XRController>{RightHand}/secondary2DAxis"",
458+
""id"": ""b0547fc8-1676-4606-82b5-05856d6f79ee"",
459+
""path"": ""<XRController>{RightHand}/{Primary2DAxis}"",
460460
""interactions"": """",
461461
""processors"": """",
462462
""groups"": ""XR"",
463-
""action"": ""Touchpad"",
463+
""action"": ""Thumbstick"",
464464
""isComposite"": false,
465465
""isPartOfComposite"": false
466466
},
467467
{
468468
""name"": """",
469-
""id"": ""6f1e295b-f9ec-4f54-83f6-991795922292"",
470-
""path"": ""<XRController>{RightHand}/secondary2DAxisClick"",
469+
""id"": ""72e50a78-6304-4080-b0dd-92875103a072"",
470+
""path"": ""<XRController>{RightHand}/{Primary2DAxisClick}"",
471471
""interactions"": """",
472472
""processors"": """",
473473
""groups"": ""XR"",
474-
""action"": ""TouchpadPressed"",
474+
""action"": ""ThumbstickPressed"",
475475
""isComposite"": false,
476476
""isPartOfComposite"": false
477477
},
478478
{
479479
""name"": """",
480-
""id"": ""1c578fc6-6b22-43b9-932c-84a6a69b28f6"",
481-
""path"": ""<XRController>{RightHand}/primaryButton"",
480+
""id"": ""02496df6-f863-4ab0-9a2b-19f379d1802e"",
481+
""path"": ""<XRController>{RightHand}/{Secondary2DAxis}"",
482482
""interactions"": """",
483483
""processors"": """",
484484
""groups"": ""XR"",
485-
""action"": ""ButtonA"",
485+
""action"": ""Touchpad"",
486486
""isComposite"": false,
487487
""isPartOfComposite"": false
488488
},
489489
{
490490
""name"": """",
491-
""id"": ""01f7d2c5-74f1-49fe-aa18-5f223e3b4dcd"",
492-
""path"": ""<XRController>{RightHand}/secondaryButton"",
491+
""id"": ""f4d512d5-b208-4144-9e13-e8b28fe90db6"",
492+
""path"": ""<XRController>{RightHand}/{Secondary2DAxisClick}"",
493493
""interactions"": """",
494494
""processors"": """",
495495
""groups"": ""XR"",
496-
""action"": ""ButtonB"",
496+
""action"": ""TouchpadPressed"",
497497
""isComposite"": false,
498498
""isPartOfComposite"": false
499499
},
500500
{
501501
""name"": """",
502-
""id"": ""cab631e7-1c7b-4c82-9466-36fbf509a3d0"",
503-
""path"": ""<XRController>{RightHand}/deviceRotation"",
502+
""id"": ""eed7075e-6a68-4284-93e5-aac10ac8fbf2"",
503+
""path"": ""<XRController>{RightHand}/{PrimaryButton}"",
504504
""interactions"": """",
505505
""processors"": """",
506506
""groups"": ""XR"",
507-
""action"": ""Rotation"",
507+
""action"": ""ButtonA"",
508508
""isComposite"": false,
509509
""isPartOfComposite"": false
510510
},
511511
{
512512
""name"": """",
513-
""id"": ""fb242f7f-5575-4104-a77c-0ed5f8aa1b4a"",
514-
""path"": ""<XRController>{RightHand}/devicePosition"",
513+
""id"": ""0dac47c1-275d-4fb3-9c67-1e1af9ace8e7"",
514+
""path"": ""<XRController>{RightHand}/{SecondaryButton}"",
515515
""interactions"": """",
516516
""processors"": """",
517517
""groups"": ""XR"",
518-
""action"": ""Position"",
518+
""action"": ""ButtonB"",
519519
""isComposite"": false,
520520
""isPartOfComposite"": false
521521
}

0 commit comments

Comments
 (0)