Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Commit

Permalink
fixed HL1 input (#120)
Browse files Browse the repository at this point in the history
* fixed HL1 input

* bumped package version
  • Loading branch information
StephenHodgson authored Feb 4, 2021
1 parent 4975e57 commit 5f15fc5
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d420c170b42dfe0438e2aa2a829775ed, type: 3}
m_Name: HoloLensControllerProfile
m_Name: LeftHoloLensControllerProfile
m_EditorClassIdentifier:
controllerType:
reference: 37aa1554-3d46-4c72-aac4-31023775f62b
handedness: 0
reference: 6ce43357-54e7-4471-b1b7-4bf4912984b1
handedness: 1
visualizationProfile: {fileID: 0}
useCustomInteractions: 1
interactionMappingProfiles:
Expand Down
23 changes: 23 additions & 0 deletions Profiles~/Contollers/RightHoloLensControllerProfile.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
%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: d420c170b42dfe0438e2aa2a829775ed, type: 3}
m_Name: RightHoloLensControllerProfile
m_EditorClassIdentifier:
controllerType:
reference: 6ce43357-54e7-4471-b1b7-4bf4912984b1
handedness: 2
visualizationProfile: {fileID: 0}
useCustomInteractions: 1
interactionMappingProfiles:
- {fileID: 11400000, guid: 276d084c2bceed04b94fd467c7e5fc14, type: 2}
- {fileID: 11400000, guid: f3146fda244cb8d4693c2edc69bdb2c3, type: 2}
- {fileID: 11400000, guid: 5f74fb8ba2c5a29448299a01af87774b, type: 2}

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 @@ -11,10 +11,11 @@ MonoBehaviour:
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe9eeb08f95b1c1419ad17953d9a48ee, type: 3}
m_Name: WindowsMixedRealityControllerDataProviderProfile
m_EditorClassIdentifier:
m_EditorClassIdentifier:
hasSetupDefaults: 1
controllerMappingProfiles:
- {fileID: 11400000, guid: aaa9b82b55ce7834bb43c9d726ff893e, type: 2}
- {fileID: 11400000, guid: ff201f2397a3513458d415382ee6f1d0, type: 2}
- {fileID: 11400000, guid: 752ece58d1e10d4458ac9d6ad664cc58, type: 2}
- {fileID: 11400000, guid: 87a124892ea548a4ea4cbba488e06b5a, type: 2}
manipulationGestures: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public override ControllerDefinition[] GetDefaultControllerOptions()
{
return new[]
{
new ControllerDefinition("HoloLensController", typeof(WindowsMixedRealityMotionController)),
new ControllerDefinition(typeof(HololensOneController), Handedness.Left),
new ControllerDefinition(typeof(HololensOneController), Handedness.Right),
new ControllerDefinition(typeof(WindowsMixedRealityMotionController), Handedness.Left),
new ControllerDefinition(typeof(WindowsMixedRealityMotionController), Handedness.Right),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,15 @@ private WindowsMixedRealityMotionController GetController(InteractionSource inte
break;
}


WindowsMixedRealityMotionController detectedController;
var controllerType = interactionSource.kind == InteractionSourceKind.Hand
? typeof(HololensOneController)
: typeof(WindowsMixedRealityMotionController);

try
{
detectedController = new WindowsMixedRealityMotionController(this, TrackingState.NotApplicable, handedness, GetControllerMappingProfile(typeof(WindowsMixedRealityMotionController), handedness));
detectedController = new WindowsMixedRealityMotionController(this, TrackingState.NotApplicable, handedness, GetControllerMappingProfile(controllerType, handedness));
}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@

namespace XRTK.WindowsMixedReality.Providers.Controllers
{
/// <summary>
/// Hololens One Controller
/// </summary>
[Obsolete]
[System.Runtime.InteropServices.Guid("6CE43357-54E7-4471-B1B7-4BF4912984B1")]
public class HololensOneController : WindowsMixedRealityMotionController
{
/// <inheritdoc />
public override MixedRealityInteractionMapping[] DefaultInteractions => new[]
{
new MixedRealityInteractionMapping("Spatial Pointer", AxisType.SixDof, DeviceInputType.SpatialPointer),
new MixedRealityInteractionMapping("Spatial Grip", AxisType.SixDof, DeviceInputType.SpatialGrip),
new MixedRealityInteractionMapping("Air Tap (Select)", AxisType.Digital, DeviceInputType.Select),
};
}

/// <summary>
/// A Windows Mixed Reality Controller Instance.
/// </summary>
Expand All @@ -33,10 +49,7 @@ public WindowsMixedRealityMotionController(IMixedRealityControllerDataProvider c
{
}

/// <summary>
/// The Windows Mixed Reality Controller default interactions.
/// </summary>
/// <remarks>A single interaction mapping works for both left and right controllers.</remarks>
/// <inheritdoc />
public override MixedRealityInteractionMapping[] DefaultInteractions => new[]
{
new MixedRealityInteractionMapping("Spatial Pointer", AxisType.SixDof, DeviceInputType.SpatialPointer),
Expand Down Expand Up @@ -309,7 +322,30 @@ private void UpdateTriggerData(InteractionSourceState interactionSourceState, Mi
interactionMapping.BoolData = interactionSourceState.grasped;
break;
case DeviceInputType.Select:
interactionMapping.BoolData = interactionSourceState.selectPressed;
bool selectPressed = interactionSourceState.selectPressed;

// BEGIN WORKAROUND: Unity issue #1033526
// See https://issuetracker.unity3d.com/issues/hololens-interactionsourcestate-dot-selectpressed-is-false-when-air-tap-and-hold
// Bug was discovered May 2018 and still exists as of today Feb 2019 in version 2018.3.4f1, timeline for fix is unknown
// The bug only affects the development workflow via Holographic Remoting or Simulation
if (interactionSourceState.source.kind == InteractionSourceKind.Hand)
{
Debug.Assert(!(UnityEngine.XR.WSA.HolographicRemoting.ConnectionState == UnityEngine.XR.WSA.HolographicStreamerConnectionState.Connected
&& interactionSourceState.selectPressed),
"Unity issue #1033526 seems to have been resolved. Please remove this ugly workaround!");

// This workaround is safe as long as all these assumptions hold:
Debug.Assert(!interactionSourceState.source.supportsGrasp);
Debug.Assert(!interactionSourceState.source.supportsMenu);
Debug.Assert(!interactionSourceState.source.supportsPointing);
Debug.Assert(!interactionSourceState.source.supportsThumbstick);
Debug.Assert(!interactionSourceState.source.supportsTouchpad);

selectPressed = interactionSourceState.anyPressed;
}
// END WORKAROUND: Unity issue #1033526

interactionMapping.BoolData = selectPressed;
break;
case DeviceInputType.Trigger:
interactionMapping.FloatData = interactionSourceState.selectPressedAmount;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"mixed",
"reality"
],
"version": "0.2.2",
"version": "0.2.3",
"unity": "2019.4",
"license": "MIT",
"author": "XRTK Team (https://github.com/XRTK)",
"dependencies": {
"com.xrtk.core": "0.2.3",
"com.xrtk.core": "0.2.4",
"com.unity.xr.windowsmr.metro": "4.2.3"
},
"profiles": [
Expand Down

0 comments on commit 5f15fc5

Please sign in to comment.