In the last few days an update has caused the error below to start showing up. I tested this on a brand new project pulling in the latest code with the default MixedRealityToolkit profile.
It breaks the Xbox controller in the Holographic Emulation modes (Simulate Error).
It seems that ControllerHandedness is not getting set, or at least if I force this in BaseController.cs (around line 177)
var controllerHandedness = ControllerHandedness;
controllerHandedness = Handedness.Right;
And then replace instances of ControllerHandeness after this with controllerHandedness the error disappears.
I don't understand all the interactions so maybe there is something upstream of ControllerHandedness that is the actual problem.
No error.
No controller model available. Failed to add controller game object to scene
UnityEngine.Debug:LogError(Object)
Microsoft.MixedReality.Toolkit.Input.BaseController:TryRenderControllerModel(Type) (at Assets/MixedRealityToolkit/Providers/BaseController.cs:202)
Microsoft.MixedReality.Toolkit.Input.BaseController:SetupConfiguration(Type) (at Assets/MixedRealityToolkit/Providers/BaseController.cs:92)
Microsoft.MixedReality.Toolkit.Input.UnityInput.UnityJoystickManager:GetOrAddController(String) (at Assets/MixedRealityToolkit/Providers/UnityInput/UnityJoystickManager.cs:160)
Microsoft.MixedReality.Toolkit.Input.UnityInput.UnityJoystickManager:RefreshDevices() (at Assets/MixedRealityToolkit/Providers/UnityInput/UnityJoystickManager.cs:111)
Microsoft.MixedReality.Toolkit.Input.UnityInput.UnityJoystickManager:Update() (at Assets/MixedRealityToolkit/Providers/UnityInput/UnityJoystickManager.cs:47)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit:UpdateAllServices() (at Assets/MixedRealityToolkit/Services/MixedRealityToolkit.cs:987)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit:Update() (at Assets/MixedRealityToolkit/Services/MixedRealityToolkit.cs:769)
_(Links to sample github project preferred)_
2018.10.f1
vNext latest code
This may have been impacted by some changes I made to start having gltf controllers rendered for windows mixed reality controllers. Do you know if the xbox controller has any ControllerHandedness assigned? It seems like there is probably some logic being seen where the active controller profile states to show a model and then no model is resolved.
That going said, is this error breaking your app experience? Or is it just generating a lot of noise in console output? It may make the difference on whether we remove this logged item or change the log error to just a normal log event.
Obviously there shouldn't be any error messages from the default setup for what I would assume would be a fairly common dev starting use case. But, the resulting lack of a visualization profile for the Xbox controller isn't important I don't think, and the controller still works.
For the warning message I'm just surprised by the difference in the expected name for the Xbox controller and what I actually see and then get confused about what the intent is, where the controller name is coming from etc.
Just to make sure my issues all still exist (as I was having some additional unexpected problems from a pending Windows update), I reverted all changes / tests and loaded the latest (as of a few minutes ago) code. I still get the error message and the log messages below, but the controller seems to be working properly and it doesn't seem like it is blocking anything else.
As best I can tell there seem to be a couple of related issues. I'm not totally clear on the underlying intent, so I'm not sure which of these are actual bugs (other than the obvious error message).
In UnityJoystickManager.GetCurrentControllerType The StartsWith("Xbox") name string doesn't match what is getting passed in. I'm not sure where this string value comes from.
ControllerHandedness never gets set. Even when the issue in 1. above is fixed.
In BaseController.TryRenderControllerModel the controllerModel (which I think should be renamed ControllerVisualizationModel) never gets set, never can get set properly, because of the issue in 2. above.
Even if you force the ControllerHandedness, so that you can get to this method:
controllerModel = GetControllerVisualizationProfile().GetControllerModelOverride(controllerType, ControllerHandedness);
If you have changed 1. above to recognize the Xbox and return:
return SupportedControllerType.Xbox;
then, unless I create an extra Xbox VisualizationProfile in the Toolkit, it doesn't find a profile for it, as it only holds the defaults, in the
controllerVisualizationSettings[i]
Error and Log Message:
No controller model available. Failed to add controller game object to scene
UnityEngine.Debug:LogError(Object)
Microsoft.MixedReality.Toolkit.Input.BaseController:TryRenderControllerModel(Type) (at Assets/MixedRealityToolkit/Providers/BaseController.cs:202)
Microsoft.MixedReality.Toolkit.Input.BaseController:SetupConfiguration(Type) (at Assets/MixedRealityToolkit/Providers/BaseController.cs:92)
Microsoft.MixedReality.Toolkit.Input.UnityInput.UnityJoystickManager:GetOrAddController(String) (at Assets/MixedRealityToolkit/Providers/UnityInput/UnityJoystickManager.cs:160)
Microsoft.MixedReality.Toolkit.Input.UnityInput.UnityJoystickManager:RefreshDevices() (at Assets/MixedRealityToolkit/Providers/UnityInput/UnityJoystickManager.cs:111)
Microsoft.MixedReality.Toolkit.Input.UnityInput.UnityJoystickManager:Update() (at Assets/MixedRealityToolkit/Providers/UnityInput/UnityJoystickManager.cs:47)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit:UpdateAllServices() (at Assets/MixedRealityToolkit/Services/MixedRealityToolkit.cs:987)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit:Update() (at Assets/MixedRealityToolkit/Services/MixedRealityToolkit.cs:769)
Controller (Xbox One For Windows) does not have a defined controller type, falling back to generic controller type
UnityEngine.Debug:Log(Object)
Microsoft.MixedReality.Toolkit.Input.UnityInput.UnityJoystickManager:GetCurrentControllerType(String) (at Assets/MixedRealityToolkit/Providers/UnityInput/UnityJoystickManager.cs:191)
Microsoft.MixedReality.Toolkit.Input.UnityInput.UnityJoystickManager:GetOrAddController(String) (at Assets/MixedRealityToolkit/Providers/UnityInput/UnityJoystickManager.cs:139)
Microsoft.MixedReality.Toolkit.Input.UnityInput.UnityJoystickManager:RefreshDevices() (at Assets/MixedRealityToolkit/Providers/UnityInput/UnityJoystickManager.cs:111)
Microsoft.MixedReality.Toolkit.Input.UnityInput.UnityJoystickManager:Update() (at Assets/MixedRealityToolkit/Providers/UnityInput/UnityJoystickManager.cs:47)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit:UpdateAllServices() (at Assets/MixedRealityToolkit/Services/MixedRealityToolkit.cs:987)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit:Update() (at Assets/MixedRealityToolkit/Services/MixedRealityToolkit.cs:769)
Actually, I'll amend the above. If I leave line 186 in UnityJoystickManager.cs as
if (joystickName.StartsWith("Xbox"))
Although the Xbox Thumbstick controls work in Holographic Emulation, and I can move around the scene, the PointerClick event never gets called (A button or trigger).
I can fix it by changing it to :
if (joystickName.Contains("Xbox"))
After which it recognizes the click event. Still have the "No controller model available" controller visualization error above though.
In regards to the issues you've called out, we should probably do the following:
1) We shouldn't log an error when no controller model/visualization model is found for a controller type. I likely caused this issue when adding WMR controller support recently and will work to get out a change.
2) It seems like the system defined xbox controller name may have changed. The change in joystickName that you have tested may be the appropriate fix. @davidkline-ms @keveleigh do you two have a perspective on whether or not this joystickName change is the appropriate fix?
3) Holographic simulation should work with xbox controllers. Its kind of surprising that controller handedness is needed for this to work. It seems like both controller handedness == none and controller handedness == any should work for your simulation scenarios.
do you two have a perspective on whether or not this joystickName change is the appropriate fix?
Yeah, we should definitely make that change.
Removed the error message for controllers without visualization https://github.com/Microsoft/MixedRealityToolkit-Unity/pull/3822
@luis-valverde-ms fixed the joystick name check yesterday here https://github.com/Microsoft/MixedRealityToolkit-Unity/pull/3790
Most helpful comment
Yeah, we should definitely make that change.