diff --git a/Assets/MixedRealityToolkit/_Core/Devices/MixedReality/WindowsMixedRealityDeviceManager.cs b/Assets/MixedRealityToolkit/_Core/Devices/MixedReality/WindowsMixedRealityDeviceManager.cs index a30ee12fe07..317fade391c 100644 --- a/Assets/MixedRealityToolkit/_Core/Devices/MixedReality/WindowsMixedRealityDeviceManager.cs +++ b/Assets/MixedRealityToolkit/_Core/Devices/MixedReality/WindowsMixedRealityDeviceManager.cs @@ -35,6 +35,16 @@ public WindowsMixedRealityDeviceManager(string name, uint priority) : base(name, /// private readonly Dictionary activeControllers = new Dictionary(); + /// + /// Cache of the states captured from the Unity InteractionManager for UWP + /// + InteractionSourceState[] interactionmanagerStates; + + /// + /// The current source state reading for the Unity InteractionManager for UWP + /// + public InteractionSourceState[] LastInteractionManagerStateReading { get; protected set; } + /// public override IMixedRealityController[] GetActiveControllers() { @@ -243,21 +253,18 @@ public override void Enable() } InteractionManager.InteractionSourceDetected += InteractionManager_InteractionSourceDetected; - InteractionManager.InteractionSourceUpdated += InteractionManager_InteractionSourceUpdated; - InteractionManager.InteractionSourcePressed += InteractionManager_InteractionSourcePressed; - InteractionManager.InteractionSourceReleased += InteractionManager_InteractionSourceReleased; InteractionManager.InteractionSourceLost += InteractionManager_InteractionSourceLost; - InteractionSourceState[] states = InteractionManager.GetCurrentReading(); + interactionmanagerStates = InteractionManager.GetCurrentReading(); // NOTE: We update the source state data, in case an app wants to query it on source detected. - for (var i = 0; i < states.Length; i++) + for (var i = 0; i < interactionmanagerStates?.Length; i++) { - var controller = GetController(states[i].source); + var controller = GetController(interactionmanagerStates[i].source); if (controller != null) { - controller.UpdateController(states[i]); + controller.UpdateController(interactionmanagerStates[i]); MixedRealityManager.InputSystem?.RaiseSourceDetected(controller.InputSource, controller); } } @@ -270,6 +277,26 @@ public override void Enable() } } + /// + public override void Update() + { + base.Update(); + + interactionmanagerStates = InteractionManager.GetCurrentReading(); + + for (var i = 0; i < interactionmanagerStates?.Length; i++) + { + var controller = GetController(interactionmanagerStates[i].source); + + if (controller != null) + { + controller.UpdateController(interactionmanagerStates[i]); + } + } + + LastInteractionManagerStateReading = interactionmanagerStates; + } + private void RegisterGestureEvents() { if (gestureRecognizer == null) @@ -333,9 +360,6 @@ public override void Disable() navigationGestureRecognizer?.Dispose(); InteractionManager.InteractionSourceDetected -= InteractionManager_InteractionSourceDetected; - InteractionManager.InteractionSourcePressed -= InteractionManager_InteractionSourcePressed; - InteractionManager.InteractionSourceUpdated -= InteractionManager_InteractionSourceUpdated; - InteractionManager.InteractionSourceReleased -= InteractionManager_InteractionSourceReleased; InteractionManager.InteractionSourceLost -= InteractionManager_InteractionSourceLost; InteractionSourceState[] states = InteractionManager.GetCurrentReading(); @@ -438,33 +462,6 @@ private void InteractionManager_InteractionSourceDetected(InteractionSourceDetec controller?.UpdateController(args.state); } - /// - /// SDK Interaction Source Updated Event handler - /// - /// SDK source updated event arguments - private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs args) - { - GetController(args.state.source)?.UpdateController(args.state); - } - - /// - /// SDK Interaction Source Pressed Event handler - /// - /// SDK source pressed event arguments - private void InteractionManager_InteractionSourcePressed(InteractionSourcePressedEventArgs args) - { - GetController(args.state.source)?.UpdateController(args.state); - } - - /// - /// SDK Interaction Source Released Event handler - /// - /// SDK source released event arguments - private void InteractionManager_InteractionSourceReleased(InteractionSourceReleasedEventArgs args) - { - GetController(args.state.source)?.UpdateController(args.state); - } - /// /// SDK Interaction Source Lost Event handler ///