MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

Can't interact with UI components using a gamepad controller

Open chbecker-ms opened this issue 7 years ago • 5 comments

Run HandInteractionExamplesScene in the editor with an Xbox gamepad connected. Click on any UI element You'll hit the following assert: KeyNotFoundException: The given key was not present in the dictionary. System.Collections.Generic.Dictionary2[TKey,TValue].get_Item (TKey key) (at :0)​ Microsoft.MixedReality.Toolkit.Input.DefaultPointerMediator.UpdatePointers () (at Assets/MixedRealityToolkit.SDK/Features/UX/Scripts/Pointers/DefaultPointerMediator.cs:111)​ Microsoft.MixedReality.Toolkit.Input.FocusProvider.UpdatePointers () (at Assets/MixedRealityToolkit.Services/InputSystem/FocusProvider.cs:681)​ Microsoft.MixedReality.Toolkit.Input.FocusProvider.Update () (at Assets/MixedRealityToolkit.Services/InputSystem/FocusProvider.cs:443)​ Microsoft.MixedReality.Toolkit.MixedRealityToolkit.UpdateAllServices () (at Assets/MixedRealityToolkit/Services/MixedRealityToolkit.cs:994)​ Microsoft.MixedReality.Toolkit.MixedRealityToolkit.Update () (at Assets/MixedRealityToolkit/Services/MixedRealityToolkit.cs:777) `

This is caused by the fact that the gamepad controller is using the pointer created by the GazeProvider. When the controller is created it triggers registration of the pointer, which at the time it has its InputSourceParent set to null, in the mediator via FocusProvider.ResgisterPointers(). It is only a bit later in the same function that the call to MixedRealityToolkit.InputSystem.GazeProvider.GazeInputSource lazily creates the gaze input source and sets it in the gaze pointer. This can be worked around by, for example, changing DefaultPointerMediator.UpdatePointers() to ignore pointers whose input source is not in the registry.

The next problem we hit is that both the gamepad controller and the gaze provider set the gaze pointer pose every frame, leading to unusable interactions.

I see two possible solutions: Create a pointer that is driven by both gaze and the gamepad in a coordinated way, in the style of GGVPointer. Create a virtual controller that produces the right combined inputs to drive any pointer via gaze and gamepad. I rather try first the second option because it is architecturally cleaner, i.e. it separates better pointer implementations from the specifics of the inputs driving it.

Original Repro (doesn't happen anymore)

We get a debug.assert at this line when a gamepad is connected and we press play in the Unity Editor. void IMixedRealitySourceStateHandler.OnSourceDetected(SourceStateEventData eventData) { for (int i = 0; i < eventData.InputSource.Pointers.Length; i++) { Debug.Assert(!pointersToUpdate.Contains(eventData.InputSource.Pointers[i])); pointersToUpdate.Add(eventData.InputSource.Pointers[i]); } }

chbecker-ms avatar May 07 '19 00:05 chbecker-ms

@luis-valverde-ms did you end up fixing this? It's unclear whether this is fixed or not by one of your PRs.

julenka avatar Jun 03 '19 21:06 julenka

I didn't fix it, I couldn't spend more time on it.

luis-valverde-ms avatar Jun 04 '19 09:06 luis-valverde-ms

Thanks for clarifying. We will leave it open.

julenka avatar Jun 04 '19 16:06 julenka

This issue has been marked as stale by an automated process because it has not had any recent activity. It will be automatically closed in 30 days if no further activity occurs. If this is still an issue please add a new comment with more recent details and repro steps.

stale[bot] avatar Feb 20 '20 01:02 stale[bot]

This issue has been closed by an automated process because it is stale. If this is still an issue please add a new comment with more recent details and repro steps.

stale[bot] avatar Mar 21 '20 04:03 stale[bot]