Skip to content

Commit dd2eb2e

Browse files
authored
Merge pull request #1415 from StephenHodgson/MRTK-ControllerRefactor
MRTK Xbox Controller & Motion Controller reconciliation
2 parents 6be5179 + e5a0d03 commit dd2eb2e

28 files changed

+895
-436
lines changed

Assets/HoloToolkit-Examples/Input/Scenes/XboxControllerExample.unity

+28-107
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ NavMeshSettings:
112112
debug:
113113
m_Flags: 0
114114
m_NavMeshData: {fileID: 0}
115+
--- !u!114 &332498722 stripped
116+
MonoBehaviour:
117+
m_PrefabParentObject: {fileID: 114000010164638790, guid: 022450106439a8946ae18a9e20cc92d8,
118+
type: 2}
119+
m_PrefabInternal: {fileID: 1246058044}
120+
m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
115121
--- !u!1001 &340683729
116122
Prefab:
117123
m_ObjectHideFlags: 0
@@ -151,6 +157,11 @@ Prefab:
151157
propertyPath: m_RootOrder
152158
value: 0
153159
objectReference: {fileID: 0}
160+
- target: {fileID: 114812681035175298, guid: d29bc40b7f3df26479d6a0aac211c355,
161+
type: 2}
162+
propertyPath: m_Enabled
163+
value: 0
164+
objectReference: {fileID: 0}
154165
m_RemovedComponents: []
155166
m_ParentPrefab: {fileID: 100100000, guid: d29bc40b7f3df26479d6a0aac211c355, type: 2}
156167
m_IsPrefabParent: 0
@@ -180,9 +191,8 @@ Transform:
180191
m_LocalScale: {x: 1, y: 1, z: 1}
181192
m_Children:
182193
- {fileID: 1635556075}
183-
- {fileID: 1895018971}
184194
m_Father: {fileID: 0}
185-
m_RootOrder: 1
195+
m_RootOrder: 2
186196
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
187197
--- !u!1 &473449477
188198
GameObject:
@@ -215,10 +225,14 @@ MonoBehaviour:
215225
m_Name:
216226
m_EditorClassIdentifier:
217227
IsGlobalListener: 1
228+
HoldStartedInterval: 2
229+
HoldCompletedInterval: 3
230+
SelectButton: 10
231+
HorizontalNavigationAxis: 1
218232
movementSpeedMultiplier: 0.01
219233
rotationSpeedMultiplier: 1
220234
resetButton: 13
221-
DebugText: {fileID: 1246058048}
235+
debugText: {fileID: 332498722}
222236
--- !u!23 &473449479
223237
MeshRenderer:
224238
m_ObjectHideFlags: 0
@@ -377,6 +391,10 @@ MonoBehaviour:
377391
m_Script: {fileID: 11500000, guid: 906323c940a3fad4f8f7e9e4fcd747f4, type: 3}
378392
m_Name:
379393
m_EditorClassIdentifier:
394+
containerObject: {fileID: 0}
395+
alignmentType: 0
396+
stationarySpaceTypePosition: {x: 0, y: 0, z: 0}
397+
roomScaleSpaceTypePosition: {x: 0, y: 0, z: 0}
380398
--- !u!4 &1131149986
381399
Transform:
382400
m_ObjectHideFlags: 0
@@ -551,12 +569,12 @@ MonoBehaviour:
551569
m_EditorClassIdentifier:
552570
PivotAxis: 0
553571
TargetTransform: {fileID: 0}
554-
--- !u!114 &1246058048 stripped
572+
--- !u!114 &1523391984 stripped
555573
MonoBehaviour:
556-
m_PrefabParentObject: {fileID: 114000010164638790, guid: 022450106439a8946ae18a9e20cc92d8,
574+
m_PrefabParentObject: {fileID: 114611684728110934, guid: a611e772ef8ddf64d8106a9cbb70f31c,
557575
type: 2}
558-
m_PrefabInternal: {fileID: 1246058044}
559-
m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
576+
m_PrefabInternal: {fileID: 1802791002}
577+
m_Script: {fileID: 11500000, guid: 0decd33ba8702954885a62b5bc1a778e, type: 3}
560578
--- !u!1001 &1635556074
561579
Prefab:
562580
m_ObjectHideFlags: 0
@@ -600,12 +618,7 @@ Prefab:
600618
type: 2}
601619
propertyPath: Cursor
602620
value:
603-
objectReference: {fileID: 1763047399}
604-
- target: {fileID: 114708646396671696, guid: 3eddd1c29199313478dd3f912bfab2ab,
605-
type: 2}
606-
propertyPath: debugDrawPointingRays
607-
value: 1
608-
objectReference: {fileID: 0}
621+
objectReference: {fileID: 1523391984}
609622
m_RemovedComponents: []
610623
m_ParentPrefab: {fileID: 100100000, guid: 3eddd1c29199313478dd3f912bfab2ab, type: 2}
611624
m_IsPrefabParent: 0
@@ -619,7 +632,7 @@ Camera:
619632
m_PrefabParentObject: {fileID: 20049547090947856, guid: 3eddd1c29199313478dd3f912bfab2ab,
620633
type: 2}
621634
m_PrefabInternal: {fileID: 1635556074}
622-
--- !u!1001 &1763047398
635+
--- !u!1001 &1802791002
623636
Prefab:
624637
m_ObjectHideFlags: 0
625638
serializedVersion: 2
@@ -656,100 +669,8 @@ Prefab:
656669
objectReference: {fileID: 0}
657670
- target: {fileID: 4000011792100794, guid: a611e772ef8ddf64d8106a9cbb70f31c, type: 2}
658671
propertyPath: m_RootOrder
659-
value: 2
672+
value: 1
660673
objectReference: {fileID: 0}
661674
m_RemovedComponents: []
662675
m_ParentPrefab: {fileID: 100100000, guid: a611e772ef8ddf64d8106a9cbb70f31c, type: 2}
663676
m_IsPrefabParent: 0
664-
--- !u!114 &1763047399 stripped
665-
MonoBehaviour:
666-
m_PrefabParentObject: {fileID: 114611684728110934, guid: a611e772ef8ddf64d8106a9cbb70f31c,
667-
type: 2}
668-
m_PrefabInternal: {fileID: 1763047398}
669-
m_Script: {fileID: 11500000, guid: 0decd33ba8702954885a62b5bc1a778e, type: 3}
670-
--- !u!1 &1895018970
671-
GameObject:
672-
m_ObjectHideFlags: 0
673-
m_PrefabParentObject: {fileID: 0}
674-
m_PrefabInternal: {fileID: 0}
675-
serializedVersion: 5
676-
m_Component:
677-
- component: {fileID: 1895018971}
678-
- component: {fileID: 1895018972}
679-
m_Layer: 0
680-
m_Name: XboxControllerInputSource
681-
m_TagString: Untagged
682-
m_Icon: {fileID: 0}
683-
m_NavMeshLayer: 0
684-
m_StaticEditorFlags: 0
685-
m_IsActive: 1
686-
--- !u!4 &1895018971
687-
Transform:
688-
m_ObjectHideFlags: 0
689-
m_PrefabParentObject: {fileID: 0}
690-
m_PrefabInternal: {fileID: 0}
691-
m_GameObject: {fileID: 1895018970}
692-
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
693-
m_LocalPosition: {x: 0, y: 0, z: 0}
694-
m_LocalScale: {x: 1, y: 1, z: 1}
695-
m_Children: []
696-
m_Father: {fileID: 402900810}
697-
m_RootOrder: 1
698-
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
699-
--- !u!114 &1895018972
700-
MonoBehaviour:
701-
m_ObjectHideFlags: 0
702-
m_PrefabParentObject: {fileID: 0}
703-
m_PrefabInternal: {fileID: 0}
704-
m_GameObject: {fileID: 1895018970}
705-
m_Enabled: 1
706-
m_EditorHideFlags: 0
707-
m_Script: {fileID: 11500000, guid: f53e0243d951df74baba23d966f61986, type: 3}
708-
m_Name:
709-
m_EditorClassIdentifier:
710-
DeviceRefreshInterval: 3
711-
horizontalAxis: 3
712-
verticalAxis: 4
713-
submitButton: 10
714-
cancelButton: 11
715-
mapping:
716-
- Type: 0
717-
Value:
718-
- Type: 1
719-
Value:
720-
- Type: 2
721-
Value:
722-
- Type: 3
723-
Value:
724-
- Type: 4
725-
Value:
726-
- Type: 5
727-
Value:
728-
- Type: 6
729-
Value:
730-
- Type: 7
731-
Value:
732-
- Type: 8
733-
Value:
734-
- Type: 9
735-
Value:
736-
- Type: 10
737-
Value:
738-
- Type: 11
739-
Value:
740-
- Type: 12
741-
Value:
742-
- Type: 13
743-
Value:
744-
- Type: 14
745-
Value:
746-
- Type: 15
747-
Value:
748-
- Type: 16
749-
Value:
750-
- Type: 17
751-
Value:
752-
- Type: 18
753-
Value:
754-
- Type: 19
755-
Value:

Assets/HoloToolkit-Examples/Input/Scripts/XboxControllerHandlerTest.cs

+20-15
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace HoloToolkit.Unity.InputModule.Tests
88
{
99
public class XboxControllerHandlerTest : XboxControllerHandlerBase
1010
{
11-
11+
[Header("Xbox Controller Test Options")]
1212
[SerializeField]
1313
private float movementSpeedMultiplier = 1f;
1414

@@ -18,7 +18,9 @@ public class XboxControllerHandlerTest : XboxControllerHandlerBase
1818
[SerializeField]
1919
private XboxControllerMappingTypes resetButton = XboxControllerMappingTypes.XboxY;
2020

21-
public Text DebugText;
21+
[SerializeField]
22+
private Text debugText;
23+
2224
private Vector3 initialPosition;
2325
private Vector3 newPosition;
2426
private Vector3 newRotation;
@@ -29,41 +31,44 @@ protected override void Start()
2931
initialPosition = transform.position;
3032
}
3133

32-
public override void OnGamePadDetected(GamePadEventData eventData)
34+
public override void OnSourceLost(SourceStateEventData eventData)
3335
{
34-
base.OnGamePadDetected(eventData);
35-
Debug.LogFormat("Joystick \"{0}\" Connected with id: {1}", eventData.GamePadName, eventData.SourceId);
36+
Debug.LogFormat("Joystick {0} with id: \"{1}\" Disconnected", GamePadName, eventData.SourceId);
37+
base.OnSourceLost(eventData);
38+
debugText.text = "No Controller Connected";
3639
}
3740

38-
public override void OnGamePadLost(GamePadEventData eventData)
41+
public override void OnXboxInputUpdate(XboxControllerEventData eventData)
3942
{
40-
base.OnGamePadLost(eventData);
41-
Debug.LogFormat("Joystick \"{0}\" Disconnected with id: {1}", eventData.GamePadName, eventData.SourceId);
42-
DebugText.text = "No Controller Connected";
43-
}
43+
if (string.IsNullOrEmpty(GamePadName))
44+
{
45+
Debug.LogFormat("Joystick {0} with id: \"{1}\" Connected", eventData.GamePadName, eventData.SourceId);
46+
}
4447

45-
public override void OnXboxAxisUpdate(XboxControllerEventData eventData)
46-
{
47-
base.OnXboxAxisUpdate(eventData);
48+
base.OnXboxInputUpdate(eventData);
49+
50+
// Reset our new vectors
4851
newPosition = Vector3.zero;
4952
newRotation = Vector3.zero;
5053

54+
// Assign new Position Data
5155
newPosition.x += eventData.XboxLeftStickHorizontalAxis * movementSpeedMultiplier;
5256
newPosition.z += eventData.XboxLeftStickVerticalAxis * movementSpeedMultiplier;
5357
newPosition.y += eventData.XboxSharedTriggerAxis * movementSpeedMultiplier;
5458

5559
transform.position += newPosition;
5660

61+
// Assign new rotation data
5762
newRotation.y += eventData.XboxRightStickHorizontalAxis * rotationSpeedMultiplier;
5863

5964
transform.rotation *= Quaternion.Euler(newRotation);
6065

61-
if (OnButton_Up(resetButton, eventData))
66+
if (XboxControllerMapping.GetButton_Up(resetButton, eventData))
6267
{
6368
transform.position = initialPosition;
6469
}
6570

66-
DebugText.text =
71+
debugText.text =
6772
string.Format(
6873
"{19}\n" +
6974
"LS Horizontal: {0:0.000} Vertical: {1:0.000}\n" +

0 commit comments

Comments
 (0)