Can't interact with UI components using a gamepad controller
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
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]);
}
}
@luis-valverde-ms did you end up fixing this? It's unclear whether this is fixed or not by one of your PRs.
I didn't fix it, I couldn't spend more time on it.
Thanks for clarifying. We will leave it open.
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.
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.