Announcement

Collapse
No announcement yet.

Detect motion controller device type

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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 (https://docs.unrealengine.com/en-US/...ol-/index.html), however I don't quite understand where and how I would implement this interface.
    Last edited by Gitschi91; 11-22-2019, 06:12 AM.

    #2
    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.
    DownToCode Website

    VR Debug Plugin - Debug your VR game/application inside VR

    Email Plugin - Send emails from one email address to another.

    FREE VR Content Examples - A bunch of VR examples to get you started and for free.

    Comment


      #3
      Hey DownToCode.

      Thank you for the support and great explanation

      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.
      https://www.unrealengine.com/marketp...put-for-unreal

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

      Comment


        #4
        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.

        Comment


          #5
          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.
          DownToCode Website

          VR Debug Plugin - Debug your VR game/application inside VR

          Email Plugin - Send emails from one email address to another.

          FREE VR Content Examples - A bunch of VR examples to get you started and for free.

          Comment


            #6
            Originally posted by Gitschi91 View Post
            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.

            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.

            Comment


              #7
              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.

              Comment


                #8
                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.

                Click image for larger version  Name:	GetControllerNames.png Views:	0 Size:	331.0 KB ID:	1761499
                Last edited by GNVR_DEV; 05-17-2020, 12:03 PM.

                Comment


                  #9
                  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)...

                  Comment


                    #10
                    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 :

                    Click image for larger version

Name:	controllertype1bis.JPG
Views:	143
Size:	65.0 KB
ID:	1766381

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

                    Click image for larger version  Name:	controllertype2.JPG Views:	12 Size:	53.0 KB ID:	1765251

                    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.
                    Last edited by Teapot Creation; 05-25-2020, 04:01 AM.

                    Comment


                      #11
                      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 ?

                      Comment


                        #12
                        Here is my working setup :
                        In my motioncontroller BP :

                        Click image for larger version

Name:	controller1.JPG
Views:	115
Size:	47.7 KB
ID:	1771701

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

                        Click image for larger version

Name:	controller2.JPG
Views:	106
Size:	15.1 KB
ID:	1771702

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

                        Comment


                          #13
                          Originally posted by Teapot Creation View Post
                          Here is my working setup :
                          In my motioncontroller BP :

                          Click image for larger version

Name:	controller1.JPG
Views:	115
Size:	47.7 KB
ID:	1771701

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

                          Click image for larger version

Name:	controller2.JPG
Views:	106
Size:	15.1 KB
ID:	1771702

                          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.

                          Comment


                            #14
                            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 !

                            Comment

                            Working...
                            X