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
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 @@ -28,6 +28,13 @@ protected BaseOculusController(IMixedRealityControllerDataProvider controllerDat
NodeType = nodeType;
}

/// <summary>
/// Local offset from the controller position defining where the grip pose is.
/// The grip pose may be used to attach things to the controller when grabbing objects.
/// </summary>
private readonly MixedRealityPose gripPoseOffset = new
MixedRealityPose(new Vector3(0f, 0f, .03f), Quaternion.Euler(0f, 90f, 0f));

/// <summary>
/// The Oculus Node Type.
/// </summary>
Expand Down Expand Up @@ -76,6 +83,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 +150,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 +318,7 @@ private void UpdateButtonDataTouch(MixedRealityInteractionMapping interactionMap
((OculusApi.RawTouch)previousState.Touches & interactionButton) != 0)
{
interactionMapping.BoolData = false;
}
}
}
}

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

Expand Down Expand Up @@ -368,6 +379,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 + gripPoseOffset.Position,
Quaternion.Euler(currentControllerPose.Rotation.eulerAngles + gripPoseOffset.Rotation.eulerAngles));
}

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)
};
}
}