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

Commit

Permalink
Add support for input and gestures for hand controllers (#72)
Browse files Browse the repository at this point in the history
* updated wmr controller data provider

* removed commented out class

* added controller data provider reference to the controller

* updated references

* fixed references

* Added default controller definitions

* updated the controller data provider inspector

fixed naming for controller definition

* updated hand data provider profile inspector

* removed redundant inspector

* cleaned up the controller interaction mappings a bit

* updated references

* updated controller instance creation

* added default constructor

* updated TryRenderController method

* removed asset menu

* fixed compiler error

* Remove obsolete SetupDefaultIntreactions (#65)

* updated reference

* added WMR Camera Data Provider

* updated WMR Camera Data Provider

* updated camera rig reference

* updated icon

* moved WMR Camera data provider into correct file location

* updated data provider constructors

* added service parent reference

* Change requests for controller provider inspectors (#67)

* Update indent levels for WMR settings

* Cache GUIContent

* Adjust WMR to recent core changes

* Update due to rename

* Cleanup usings

* Added rig reset override

* reverted changes

* removed unused reference

* added camera profile

* Updated windows controller type name to get the controller textures to show up correctly based on the type name

* fixed reference to renamed controller class

* fixed more type references

* Resolve merge issues

* Reset some unrelated file changes

* Fix namespace

* Moved WMR hand data provider profile asset

* Fix WMR namespace compiler error

* Cleanup namespace

* Move default wmr data provider profile from SDK

* Update profile references

* Introduce hand rendering mode

* Implement runtime rendering mode switch

* Update converter to define platform capabilities

* Update wmr to use post processor

* Fix build errors due to removal of base converter

* Rename joints

* Point to new hand controller profiles

* Pass handedness to pose recognizer

* Fix build errors

* Update WMR converter to latest changes

* Update wmr hand data provider

* Temp update WindowsApiChecker

* Fix joint-root offset calculation

* Finally fix freaking joint conversion

* Cleanup code

* Commit new controller GUIDs

* Implement pointer pose override for WMR platform

* Remove DOTNETWINRT_PRESENT usage

Co-authored-by: Stephen Hodgson <hodgson.designs@gmail.com>
  • Loading branch information
FejZa and StephenHodgson committed Sep 22, 2020
1 parent 156423a commit b7ffbfd
Show file tree
Hide file tree
Showing 41 changed files with 437 additions and 249 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ MonoBehaviour:
cameraClearFlagsOpaqueDisplay: 1
backgroundColorOpaqueDisplay: {r: 0, g: 0, b: 0, a: 1}
opaqueQualityLevel: 0
nearClipPlaneTransparentDisplay: 0.2
nearClipPlaneTransparentDisplay: 0.05
cameraClearFlagsTransparentDisplay: 2
backgroundColorTransparentDisplay: {r: 0, g: 0, b: 0, a: 0}
transparentQualityLevel: 0
Expand Down

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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,7 +11,7 @@ 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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ MonoBehaviour:
m_EditorClassIdentifier:
hasSetupDefaults: 1
controllerMappingProfiles:
- {fileID: 11400000, guid: b43ff1b6f37e65946b1abc7e50af105f, type: 2}
- {fileID: 11400000, guid: 6c775257f26873e459a492f28125e129, type: 2}
handMeshingEnabled: 0
- {fileID: 11400000, guid: dd499836e4b82f14da2f414aad1fed8b, type: 2}
- {fileID: 11400000, guid: 78bf44d2b6970a74ea2721883b0b22bc, type: 2}
renderingMode: 1
handPhysicsEnabled: 0
useTriggers: 0
boundsMode: 0
trackedPoses: []
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#if WINDOWS_UWP

using System;
using Windows.Perception.People;
using XRTK.Definitions.Controllers.Hands;

Expand All @@ -18,36 +19,36 @@ public static TrackedHandJoint ToTrackedHandJoint(this HandJointKind handJointKi

case HandJointKind.Wrist: return TrackedHandJoint.Wrist;

case HandJointKind.ThumbMetacarpal: return TrackedHandJoint.ThumbMetacarpalJoint;
case HandJointKind.ThumbProximal: return TrackedHandJoint.ThumbProximalJoint;
case HandJointKind.ThumbDistal: return TrackedHandJoint.ThumbDistalJoint;
case HandJointKind.ThumbMetacarpal: return TrackedHandJoint.ThumbMetacarpal;
case HandJointKind.ThumbProximal: return TrackedHandJoint.ThumbProximal;
case HandJointKind.ThumbDistal: return TrackedHandJoint.ThumbDistal;
case HandJointKind.ThumbTip: return TrackedHandJoint.ThumbTip;

case HandJointKind.IndexMetacarpal: return TrackedHandJoint.IndexMetacarpal;
case HandJointKind.IndexProximal: return TrackedHandJoint.IndexKnuckle;
case HandJointKind.IndexIntermediate: return TrackedHandJoint.IndexMiddleJoint;
case HandJointKind.IndexDistal: return TrackedHandJoint.IndexDistalJoint;
case HandJointKind.IndexProximal: return TrackedHandJoint.IndexProximal;
case HandJointKind.IndexIntermediate: return TrackedHandJoint.IndexIntermediate;
case HandJointKind.IndexDistal: return TrackedHandJoint.IndexDistal;
case HandJointKind.IndexTip: return TrackedHandJoint.IndexTip;

case HandJointKind.MiddleMetacarpal: return TrackedHandJoint.MiddleMetacarpal;
case HandJointKind.MiddleProximal: return TrackedHandJoint.MiddleKnuckle;
case HandJointKind.MiddleIntermediate: return TrackedHandJoint.MiddleMiddleJoint;
case HandJointKind.MiddleDistal: return TrackedHandJoint.MiddleDistalJoint;
case HandJointKind.MiddleProximal: return TrackedHandJoint.MiddleProximal;
case HandJointKind.MiddleIntermediate: return TrackedHandJoint.MiddleIntermediate;
case HandJointKind.MiddleDistal: return TrackedHandJoint.MiddleDistal;
case HandJointKind.MiddleTip: return TrackedHandJoint.MiddleTip;

case HandJointKind.RingMetacarpal: return TrackedHandJoint.RingMetacarpal;
case HandJointKind.RingProximal: return TrackedHandJoint.RingKnuckle;
case HandJointKind.RingIntermediate: return TrackedHandJoint.RingMiddleJoint;
case HandJointKind.RingDistal: return TrackedHandJoint.RingDistalJoint;
case HandJointKind.RingProximal: return TrackedHandJoint.RingProximal;
case HandJointKind.RingIntermediate: return TrackedHandJoint.RingIntermediate;
case HandJointKind.RingDistal: return TrackedHandJoint.RingDistal;
case HandJointKind.RingTip: return TrackedHandJoint.RingTip;

case HandJointKind.LittleMetacarpal: return TrackedHandJoint.PinkyMetacarpal;
case HandJointKind.LittleProximal: return TrackedHandJoint.PinkyKnuckle;
case HandJointKind.LittleIntermediate: return TrackedHandJoint.PinkyMiddleJoint;
case HandJointKind.LittleDistal: return TrackedHandJoint.PinkyDistalJoint;
case HandJointKind.LittleTip: return TrackedHandJoint.PinkyTip;
case HandJointKind.LittleMetacarpal: return TrackedHandJoint.LittleMetacarpal;
case HandJointKind.LittleProximal: return TrackedHandJoint.LittleProximal;
case HandJointKind.LittleIntermediate: return TrackedHandJoint.LittleIntermediate;
case HandJointKind.LittleDistal: return TrackedHandJoint.LittleDistal;
case HandJointKind.LittleTip: return TrackedHandJoint.LittleTip;

default: return TrackedHandJoint.None;
default: throw new ArgumentOutOfRangeException($"{typeof(HandJointKind).Name}.{handJointKind} could not be mapped to {typeof(TrackedHandJoint).Name}");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ public static void StartHaptics(this InteractionSource interactionSource, float

public static void StartHaptics(this InteractionSource interactionSource, float intensity, float durationInSeconds)
{
if (!WindowsApiChecker.UniversalApiContractV4_IsAvailable && !Application.isEditor)
// GetForCurrentView and GetDetectedSourcesAtTimestamp were both introduced in the same Windows version.
// We need only check for one of them.
if ((!WindowsApiChecker.IsMethodAvailable(
"Windows.UI.Input.Spatial",
"SpatialInteractionManager",
"GetForCurrentView") ||
!WindowsApiChecker.IsTypeAvailable("Windows.Devices.Haptics", "SimpleHapticsController")) && !Application.isEditor)
{
return;
}
Expand Down Expand Up @@ -82,7 +88,13 @@ public static void StartHaptics(this InteractionSource interactionSource, float

public static void StopHaptics(this InteractionSource interactionSource)
{
if (!WindowsApiChecker.UniversalApiContractV4_IsAvailable && !Application.isEditor)
// GetForCurrentView and GetDetectedSourcesAtTimestamp were both introduced in the same Windows version.
// We need only check for one of them.
if ((!WindowsApiChecker.IsMethodAvailable(
"Windows.UI.Input.Spatial",
"SpatialInteractionManager",
"GetForCurrentView") ||
!WindowsApiChecker.IsTypeAvailable("Windows.Devices.Haptics", "SimpleHapticsController")) && !Application.isEditor)
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,24 @@ private WindowsMixedRealityMotionController GetController(InteractionSource inte
private static async void TryRenderControllerModel(InteractionSource interactionSource, WindowsMixedRealityMotionController controller)
{
#if WINDOWS_UWP
if (!UnityEngine.XR.WSA.HolographicSettings.IsDisplayOpaque) { return; }
if (!UnityEngine.XR.WSA.HolographicSettings.IsDisplayOpaque)
{
return;
}

IRandomAccessStreamWithContentType stream = null;

if (!WindowsApiChecker.UniversalApiContractV5_IsAvailable) { return; }
if (!WindowsApiChecker.IsMethodAvailable(
"Windows.UI.Input.Spatial",
"SpatialInteractionManager",
"GetForCurrentView") ||
!WindowsApiChecker.IsMethodAvailable(
"Windows.UI.Input.Spatial",
"SpatialInteractionController",
"TryGetRenderableModelAsync"))
{
return;
}

await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, DispatchedHandler);

Expand Down
Loading

0 comments on commit b7ffbfd

Please sign in to comment.