From c259c3083231c61150c517537f0fc1331c571bc8 Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Thu, 4 Feb 2021 12:29:49 -0500 Subject: [PATCH] Release 0.2.3 (#121) * fixed HL1 input (#120) * fixed HL1 input * bumped package version * The HoloLens either prior to hand detection, or on hand lost creates an InteractionState of type "unknown". (#122) This update ignores any hands other than left or right on HL1. Tested with HL1 Co-authored-by: Simon (Darkside) Jackson --- ...et => LeftHoloLensControllerProfile.asset} | 6 +-- ... LeftHoloLensControllerProfile.asset.meta} | 0 .../RightHoloLensControllerProfile.asset | 23 ++++++++++ .../RightHoloLensControllerProfile.asset.meta | 8 ++++ ...RealityControllerDataProviderProfile.asset | 3 +- ...xedRealityControllerDataProviderProfile.cs | 3 +- ...ndowsMixedRealityControllerDataProvider.cs | 9 ++-- .../WindowsMixedRealityMotionController.cs | 46 +++++++++++++++++-- package.json | 4 +- 9 files changed, 87 insertions(+), 15 deletions(-) rename Profiles~/Contollers/{HoloLensControllerProfile.asset => LeftHoloLensControllerProfile.asset} (86%) rename Profiles~/Contollers/{HoloLensControllerProfile.asset.meta => LeftHoloLensControllerProfile.asset.meta} (100%) create mode 100644 Profiles~/Contollers/RightHoloLensControllerProfile.asset create mode 100644 Profiles~/Contollers/RightHoloLensControllerProfile.asset.meta diff --git a/Profiles~/Contollers/HoloLensControllerProfile.asset b/Profiles~/Contollers/LeftHoloLensControllerProfile.asset similarity index 86% rename from Profiles~/Contollers/HoloLensControllerProfile.asset rename to Profiles~/Contollers/LeftHoloLensControllerProfile.asset index 44537146..0751ae42 100644 --- a/Profiles~/Contollers/HoloLensControllerProfile.asset +++ b/Profiles~/Contollers/LeftHoloLensControllerProfile.asset @@ -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: diff --git a/Profiles~/Contollers/HoloLensControllerProfile.asset.meta b/Profiles~/Contollers/LeftHoloLensControllerProfile.asset.meta similarity index 100% rename from Profiles~/Contollers/HoloLensControllerProfile.asset.meta rename to Profiles~/Contollers/LeftHoloLensControllerProfile.asset.meta diff --git a/Profiles~/Contollers/RightHoloLensControllerProfile.asset b/Profiles~/Contollers/RightHoloLensControllerProfile.asset new file mode 100644 index 00000000..c67d7c76 --- /dev/null +++ b/Profiles~/Contollers/RightHoloLensControllerProfile.asset @@ -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} diff --git a/Profiles~/Contollers/RightHoloLensControllerProfile.asset.meta b/Profiles~/Contollers/RightHoloLensControllerProfile.asset.meta new file mode 100644 index 00000000..d9056a7f --- /dev/null +++ b/Profiles~/Contollers/RightHoloLensControllerProfile.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ff201f2397a3513458d415382ee6f1d0 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Profiles~/Contollers/WindowsMixedRealityControllerDataProviderProfile.asset b/Profiles~/Contollers/WindowsMixedRealityControllerDataProviderProfile.asset index 594ac75d..ff4327e4 100644 --- a/Profiles~/Contollers/WindowsMixedRealityControllerDataProviderProfile.asset +++ b/Profiles~/Contollers/WindowsMixedRealityControllerDataProviderProfile.asset @@ -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 diff --git a/Runtime/Profiles/WindowsMixedRealityControllerDataProviderProfile.cs b/Runtime/Profiles/WindowsMixedRealityControllerDataProviderProfile.cs index 738d4d6d..b199968b 100644 --- a/Runtime/Profiles/WindowsMixedRealityControllerDataProviderProfile.cs +++ b/Runtime/Profiles/WindowsMixedRealityControllerDataProviderProfile.cs @@ -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), }; diff --git a/Runtime/Providers/Controllers/WindowsMixedRealityControllerDataProvider.cs b/Runtime/Providers/Controllers/WindowsMixedRealityControllerDataProvider.cs index 38d8c967..1935e5fb 100644 --- a/Runtime/Providers/Controllers/WindowsMixedRealityControllerDataProvider.cs +++ b/Runtime/Providers/Controllers/WindowsMixedRealityControllerDataProvider.cs @@ -409,8 +409,7 @@ private WindowsMixedRealityMotionController GetController(InteractionSource inte switch (interactionSource.handedness) { default: - handedness = Handedness.None; - break; + return null; case InteractionSourceHandedness.Left: handedness = Handedness.Left; break; @@ -419,11 +418,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) { diff --git a/Runtime/Providers/Controllers/WindowsMixedRealityMotionController.cs b/Runtime/Providers/Controllers/WindowsMixedRealityMotionController.cs index 3ef1bbe1..22b4369c 100644 --- a/Runtime/Providers/Controllers/WindowsMixedRealityMotionController.cs +++ b/Runtime/Providers/Controllers/WindowsMixedRealityMotionController.cs @@ -17,6 +17,22 @@ namespace XRTK.WindowsMixedReality.Providers.Controllers { + /// + /// Hololens One Controller + /// + [Obsolete] + [System.Runtime.InteropServices.Guid("6CE43357-54E7-4471-B1B7-4BF4912984B1")] + public class HololensOneController : WindowsMixedRealityMotionController + { + /// + 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), + }; + } + /// /// A Windows Mixed Reality Controller Instance. /// @@ -33,10 +49,7 @@ public WindowsMixedRealityMotionController(IMixedRealityControllerDataProvider c { } - /// - /// The Windows Mixed Reality Controller default interactions. - /// - /// A single interaction mapping works for both left and right controllers. + /// public override MixedRealityInteractionMapping[] DefaultInteractions => new[] { new MixedRealityInteractionMapping("Spatial Pointer", AxisType.SixDof, DeviceInputType.SpatialPointer), @@ -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; diff --git a/package.json b/package.json index 92608be9..a2f47e27 100644 --- a/package.json +++ b/package.json @@ -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": [