Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Implement grip pose input action for Oculus Touch controller's #97

Merged
merged 13 commits into from
Dec 16, 2020
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MonoBehaviour:
m_Name: LeftOculusHandGripInteractionMappingProfile
m_EditorClassIdentifier:
interactionMapping:
description: Grip
description: Grip Press
stateChangeType: 0
axisType: 2
inputType: 13
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MonoBehaviour:
m_Name: RightOculusHandGripInteractionMappingProfile
m_EditorClassIdentifier:
interactionMapping:
description: Grip
description: Grip Press
stateChangeType: 0
axisType: 2
inputType: 13
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e3fb79524faca40478c0844c24e542f7, type: 3}
m_Name: LeftOculusTouchGripPoseInteractionMappingProfile
m_EditorClassIdentifier:
interactionMapping:
description: Grip Pose
stateChangeType: 0
axisType: 7
inputType: 14
inputAction:
profileGuid: 399335ccc89c4d12b79f3539ca7771db
id: 3
description: Grip Pose
axisConstraint: 7
keyCode: 0
inputName:
axisCodeX:
axisCodeY:
inputProcessors: []
pointerProfiles: []

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ MonoBehaviour:
- {fileID: 11400000, guid: fb9b971cf238bb4449528a3b93906c0a, type: 2}
- {fileID: 11400000, guid: a28ef8a54b31cd7429a330d53d37bda4, type: 2}
- {fileID: 11400000, guid: 4c2c7b74b24b9d946af40c80ee0d0e9a, type: 2}
- {fileID: 11400000, guid: 44d1dac04942dba44ab0f01ee529dec8, type: 2}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e3fb79524faca40478c0844c24e542f7, type: 3}
m_Name: RightOculusTouchGripPoseInteractionMappingProfile
m_EditorClassIdentifier:
interactionMapping:
description: Grip Pose
stateChangeType: 0
axisType: 7
inputType: 14
inputAction:
profileGuid: 399335ccc89c4d12b79f3539ca7771db
id: 3
description: Grip Pose
axisConstraint: 7
keyCode: 0
inputName:
axisCodeX:
axisCodeY:
inputProcessors: []
pointerProfiles: []

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ MonoBehaviour:
- {fileID: 11400000, guid: dd3b05d4a1ecb1a4fb8223e48a0e2cd5, type: 2}
- {fileID: 11400000, guid: 8d874651626c3ec468f4807dc53538b0, type: 2}
- {fileID: 11400000, guid: a29c31e27b6a4dd478d0baffe9c452bf, type: 2}
- {fileID: 11400000, guid: 6bdb400e6c8fb154c973f1e2577f9b24, type: 2}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ MonoBehaviour:
runtimePlatforms:
- reference: c838c4f5-a87e-48c7-8742-09a4d85fc3bc
- reference: db1acc26-ec8d-4bc6-afca-c51351b2da2e
profile: {fileID: 11400000, guid: c02516a14adf1ff45b2e6feaefd1d090, type: 2}
profile: {fileID: 11400000, guid: 69601914bd8789b49bc45cc0a9220b4d, type: 2}
- instancedType:
reference: 0de5da40-feb8-4891-b9b2-942eafd041b9
name: Oculus Controller Data Provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public override ControllerDefinition[] GetDefaultControllerOptions()
{
new ControllerDefinition(typeof(OculusRemoteController)),
new ControllerDefinition(typeof(OculusTouchController), Handedness.Left),
new ControllerDefinition(typeof(OculusTouchController), Handedness.Right),
new ControllerDefinition(typeof(OculusTouchController), Handedness.Right)
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ protected BaseOculusController(IMixedRealityControllerDataProvider controllerDat
/// </summary>
private OculusApi.Node NodeType { get; }

/// <inheritdoc />
protected override MixedRealityPose GripPoseOffset => new MixedRealityPose(Vector3.zero, Quaternion.Euler(0f, 0f, -90f));

/// <summary>
/// The Oculus Controller Type.
/// </summary>
Expand Down Expand Up @@ -76,6 +79,7 @@ protected BaseOculusController(IMixedRealityControllerDataProvider controllerDat
new MixedRealityInteractionMapping("Button.DpadLeft Press", AxisType.Digital, "DpadLeft", DeviceInputType.ThumbStickPress),
new MixedRealityInteractionMapping("Button.DpadRight Press", AxisType.Digital, "DpadRight", DeviceInputType.ThumbStickPress),
new MixedRealityInteractionMapping("Button.RTouchpad", AxisType.Digital, "RTouchpad", DeviceInputType.ThumbTouch),
new MixedRealityInteractionMapping("Grip Pose", AxisType.SixDof, DeviceInputType.SpatialGrip)
};

/// <inheritdoc />
Expand Down Expand Up @@ -142,6 +146,9 @@ public override void UpdateController()
case DeviceInputType.Touchpad:
UpdateDualAxisData(interactionMapping);
break;
case DeviceInputType.SpatialGrip:
UpdateSpatialGripData(interactionMapping);
break;
default:
Debug.LogError($"Input [{interactionMapping.InputType}] is not handled for this controller [{GetType().Name}]");
break;
Expand Down Expand Up @@ -307,7 +314,7 @@ private void UpdateButtonDataTouch(MixedRealityInteractionMapping interactionMap
((OculusApi.RawTouch)previousState.Touches & interactionButton) != 0)
{
interactionMapping.BoolData = false;
}
}
}
}

Expand All @@ -327,7 +334,7 @@ private void UpdateButtonDataNearTouch(MixedRealityInteractionMapping interactio
((OculusApi.RawNearTouch)previousState.NearTouches & interactionButton) != 0)
{
interactionMapping.BoolData = false;
}
}
}
}

Expand Down Expand Up @@ -368,6 +375,14 @@ private void UpdateSingleAxisData(MixedRealityInteractionMapping interactionMapp
interactionMapping.FloatData = singleAxisValue;
}

private void UpdateSpatialGripData(MixedRealityInteractionMapping interactionMapping)
{
Debug.Assert(interactionMapping.AxisType == AxisType.SixDof);
interactionMapping.PoseData = new MixedRealityPose(
currentControllerPose.Position + currentControllerPose.Rotation * GripPoseOffset.Position,
currentControllerPose.Rotation * GripPoseOffset.Rotation);
}

private void UpdateDualAxisData(MixedRealityInteractionMapping interactionMapping)
{
Debug.Assert(interactionMapping.AxisType == AxisType.DualAxis);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public OculusTouchController(IMixedRealityControllerDataProvider controllerDataP
new MixedRealityInteractionMapping("Button.Four Touch", AxisType.Digital, "Y", DeviceInputType.ButtonTouch),
new MixedRealityInteractionMapping("Axis2D.PrimaryThumbRest", AxisType.DualAxis, "LTouchpad", DeviceInputType.ThumbStick),
new MixedRealityInteractionMapping("Touch.PrimaryThumbRest Touch", AxisType.Digital, "LThumbRest", DeviceInputType.ThumbTouch),
new MixedRealityInteractionMapping("Touch.PrimaryThumbRest Near Touch", AxisType.Digital, "LThumbRest", DeviceInputType.ThumbNearTouch)
new MixedRealityInteractionMapping("Touch.PrimaryThumbRest Near Touch", AxisType.Digital, "LThumbRest", DeviceInputType.ThumbNearTouch),
new MixedRealityInteractionMapping("Grip Pose", AxisType.SixDof, DeviceInputType.SpatialGrip)
};

/// <inheritdoc />
Expand All @@ -66,7 +67,8 @@ public OculusTouchController(IMixedRealityControllerDataProvider controllerDataP
new MixedRealityInteractionMapping("Button.Two Touch", AxisType.Digital, "B", DeviceInputType.ButtonTouch),
new MixedRealityInteractionMapping("Axis2D.SecondaryThumbRest", AxisType.DualAxis, "RTouchpad", DeviceInputType.ThumbStick),
new MixedRealityInteractionMapping("Touch.SecondaryThumbRest Touch", AxisType.Digital, "RThumbRest", DeviceInputType.ThumbTouch),
new MixedRealityInteractionMapping("Touch.SecondaryThumbRest Near Touch", AxisType.Digital, "RThumbRest", DeviceInputType.ThumbNearTouch)
new MixedRealityInteractionMapping("Touch.SecondaryThumbRest Near Touch", AxisType.Digital, "RThumbRest", DeviceInputType.ThumbNearTouch),
new MixedRealityInteractionMapping("Grip Pose", AxisType.SixDof, DeviceInputType.SpatialGrip)
};
}
}
2 changes: 1 addition & 1 deletion XRTK.Oculus/Packages/com.xrtk.oculus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"src": "Assets/XRTK.Oculus",
"author": "XRTK Team (https://github.com/XRTK)",
"dependencies": {
"com.xrtk.core": "0.2.0-preview.133"
"com.xrtk.core": "0.2.0-preview.161"
},
"profiles": [
{
Expand Down