Download

Interface to SteamVR and SteamVRController

I have the Vive up working with 4.8.

I want to interface to the steam VR libraries but setting up the include files to create my own actor component or such is aluding me.

I can get as far as adding some includes to the build CS file as such:
PublicDependencyModuleNames.AddRange(new string] { “Core”, “CoreUObject”, “Engine”, “InputCore”, “InputDevice”, “SteamVR”, “SteamVRController” });

With this I can’t seem to include the actual code, but I can get the abstract class as in:

#include “ISteamVRControllerPlugin.h”

Then I can try this but it can’t instantiate the abstract class.
ISteamVRControllerPlugin steamVR = ISteamVRControllerPlugin::Get();

How can I set up Unreal to let me interface to the methods? In particular, I want to get to GetTrackedDevicePositionAndOrientation and other methods from \Engine\Plugins\Runtime\Steam\SteamVR\Source\SteamVR\Classes\SteamVRFunctionLibrary

We have a fix for this, which I’m rolling into our main branch. Will reply this afternoon with directions on how to get it!

Okay, this fix has gone in Perforce, and been mirrored over to GitHub.

P4 CL: 2599910
GitHub: https://github.com/EpicGames/UnrealEngine/commit/90520bd40e572907e622c6f2446e7bfea236d4f5

The change is very simple, and basically consists of making your SteamVRFunctionLibrary.h have the following:

The same changelist also has a fix for input being sent all the time in the editor, which made it hard to use the editor with the new wireless Vive controllers. I recommend taking both.

If you want to get tracking information in your project, update your project’s Build.cs file to include PrivateDependencyModuleNames with “SteamVR,” and then #include “SteamVRFunctionLibrary.h”, and use the functions defined in there to get tracking information for the controllers.

For the SteamController inputs (e.g. key presses), you shouldn’t have to directly add the module as a dependency. Those route through our normal input system, so you can bind them to standard game presses. The mapping is defined in SteamVRController.cpp. Look for:

You simply need to listen for those events as you would any other controller (mouse, keyboard, Xbox controller, etc), and use them normally. You shouldn’t define a dependency to SteamController in your project explicitly.

Hope that helps!

Thanks Nick,

Do I need to rebuild the engine for this to work. I changed the header and then just built the game code and it gave an error:

1>D:\Projects\UE4\4.8\Engine\Plugins\Runtime\Steam\SteamVR\Source\SteamVR\Classes\SteamVRFunctionLibrary.h(46): error C2487: ‘GetPrivateStaticClass’ : member of dll interface class may not be declared with dll interface
1>D:\Projects\UE4\4.8\Engine\Plugins\Runtime\Steam\SteamVR\Source\SteamVR\Classes\SteamVRFunctionLibrary.h(46): error C2487: ‘USteamVRFunctionLibrary::{ctor}’ : member of dll interface class may not be declared with dll interface

I did change the code in SteamController.cpp also but it doesn’t seem to build the engine DLL. IIRC I had to do something other than build my Game project to get the full engine to rebuild.

Yes, you’ll need to rebuild the engine for it to work. If you run GenerateProjectFiles.bat in the root of your engine source code directory, and rebuild, you should be good to go!

Thanks Nick,

I am able to build now with the SteamVRFunctionLibrary.h included. Will update thread once I have controllers working.

Thanks Nick,

This is working now and I have the controllers tracking with my own controller class. Works great. Next up is setting up the buttons.

Nick,

Question about this. We have this working with Controller ID 0 using the “Gamepad Left Trigger press” input. But the Right controller (ID 1) doesn’t work with “Gamepad Right Trigger.” It wasn’t clear to me if it needed to be set up as a second controller somehow.

How do we get the buttons passed through the input system for the second controller?

Thanks.

There been another topic about this.
Around way is to spawn another player with own controller and then provide his controller data to the first player as Right.

I’m trying to make calls into the USteamVRFunctionLibrary from code (not blueprint), but I’m having no luck. I’ve tried to follow the instructions from Nick above, with my call being:

but I get the following error:

Any idea what I’m doing wrong? Is there any example code showing how to call into a UBlueprintFunctionLibrary from code? I haven’t been able to find any in my web searching.

Hi Nick and Jeff, sorry for replying at this thread after 2 years…

I have a problem here, I have updated my project’s Build.cs file to include PrivateDependencyModuleNames with SteamVR, but at the #include “SteamVRFunctionLibrary.h” it still says that it could not open the source file… (But I can compile it just fine, UE says compilation finished)

Do you perhaps have any idea why it’s like that?

Note: I need to track the motion controllers, too

Thanks!