Detect motion controller device type

Hello there.

We are currently working on a VR game and we need a way for unreal to tell us which type of motion controller the player is using.
I know we can use ‘GetHMDDeviceName’ to determine if we are using SteamVR or Oculus, however this won’t help me tell the difference between a player using the vive motion controllers and the valve knuckles controllers for example.

Because of how abysmal the vive controller is I have to put the button for switching magic on the menu button and put directional dash on face button 1-4 which are on the touch pad.
However on valve knuckles I want to put the magic switch on face button 1 while having the dash activate on pressing in the left analogue stick and deciding the direction based on the axis.

Does anybody know a way to achieve this?

Thank you in advance

Edit:
I found a function called **GetMotionControllerDeviceTypeName **on **IMotionController (**IMotionController::GetMotionControllerDeviceTypeName | Unreal Engine Documentation), however I don’t quite understand where and how I would implement this interface.

Hi Gitschi91,

If you take a look at the MotionControllerComponent.cpp at line 480 you’ll see an example of how to make use of the IMotionController.

TArray<IMotionController*> MotionControllers = IModularFeatures::Get().GetModularFeatureImplementations<IMotionController>(IMotionController::GetModularFeatureName());
for (auto MotionController : MotionControllers)
{

It seems to be implemented by the various motion controllers classes internally. The MotionController component iterates through a list of the classes implementing IMotionController.

Hey DownToCode.

Thank you for the support and great explanation :slight_smile:

I ended up finding the ‘SteamVR Input’ plugin on the store though and it seems to come with the ability of differentiating between different controller types out of the box.

In case that doesn’t work out I’ll try the implementation you suggested.

Just an update in case someone else is trying to figure this out.

The SteamVR Input plugin is a buggy mess at this point and does more bad than good.
It would help with the issue of detecting which controller type an input is coming from, but also doesn’t seem to have a function where I can simply ask which controller type the player is using which would solve some issues, but wouldn’t work for things like showing the proper button image in a tooltip.

I tried to implement it using the suggestion from DownToCode, however the **GetMotionControllerDeviceTypeName **function on **IMotionController **is also completely useless.
It simply returns SteamVRController and also doesn’t differentiate between vive, index etc…

So I’m still not sure how to get the proper motion controller type.
For now I found a way to avoid the issue by using a different implementation, but I feel like this will still lead to other issues down the line.

Believe when I say I feeeeeel your pain with the SteamVR Input plugin as I’m forced to use it while I work with the knuckles on an experience.

I see thanks for getting back with an update on that, it’s useful to know that it doesn’t work. This is really something that should be implemented as I think it’s important to be able to differentiate between controllers at runtime.

Its not completely true, if you use native Oculus without Steam, it returns with “OculusInputDevice”.
However, if you installed SteamVR and use it for UE4 probably its the case you described.
Please let me know if you found a better alternative as I have also decide the controller type for showing proper button help icons for UI.

Yo devs? What the ■■■■? Even in your example the hand model is all wonky when using an index controller. How is there not even a well known solution for your lack of quality? I’m so sick of every time that I try to do something in your engine and I run into a wall because of the lack of something so common sense.

EDIT: I found that putting this in the Game Instance worked in the Editor but not on packaged builds. I ending up moving it to the Widget I use to display what buttons do what.

I found a way to get the actual name of the controller using blueprints. I put this into my Game Instance on Event Init but should work anywhere you need it.

Hey there,
have you found a solution to your problem ? I’m looking for this too. I found the “Enumerate Tracked Devices” node combined to “break XRDeviceID”, but it gives and ID (int) and/or the glabl device name (SteamVR in this case), even if you reduce choice to Controllers.
Also your setup doesn’t work in my case since I can’t find the Action Name to enter (can’t find mapped actions for my controller)…

Hi again, just found a turnaround. The Motioncontroller Component has an visualization option to “display device model”, detected by Unreal and set up by default (or not). At beginplay, set this in your motioncontrollerBP :

Then in your vrpawn BP (at beginplay after short delay) :

You’ll have to define an Enum variable (mine says vive, index or octouch).
It looks like it works…

EDIT : for some reason using “Set Display Device Model” at runtime doesn’t work. You’ll have to set it visible in the BP and set Display Model Source as Custom and leave it empty to hide the model during runtime.

Hey my last post is not completely right… It works well in the editor, but when the game is packaged it only works for Vive and Valve Index. Oculus Controllers are not detected even if using SteamVR. Any advice ?

Here is my working setup :
In my motioncontroller BP :

And preview controller mesh set as Custom with some invisible mesh named with “oculus” somewhere :

controller2.JPG

This combined with the Pawn setup 2 posts earlier and the thing is working in packaged builds too.

Yep, This won’t work, for some reason “GetHMDDeviceName” actually only get the “platform” you are running on. So, Oculus or SteamVR. Yeah… Useless. In the case of SteamVR it can be a Samsung Odyssey, an Index, a VIVE, so we can’t know with the poorly named “GetHMDDeviceName” function.

Well actually get HMDDeviceName is here only used to say that OculusHMD model has to be set manually. SteamVR founds the model (index and Vive, didn’t test with another headset) alone.
When launching the game with Index HMD, the model is an index controller. Also with Vive the model is a Vive one. Just for Oculus was the issue. In my setup for Oculus the model has to be the one set by hand (with “oculus” in its name), and for SteamVR the model is set automatically. It works in my project !