How to access the motion controllers in c++?

I can’t seem to find any documentation for SteamVR’s C++ APIs. How would I go about getting access to the controllers?

The IMotionController Class looks promising:
https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Runtime/HeadMountedDisplay/Public/IMotionController.h

However it is not clear how to get a reference from it. In the case of the HMD getting a reference looks something like:

IHeadMountedDisplay* HMD = (IHeadMountedDisplay*)(GEngine->HMDDevice.Get());

Looks like I have mostly solved it. Although any further help with error handling/making it more stable would be appreciated:

TArray<IMotionController*> controllers = GEngine->MotionControllerDevices;
IMotionController* playerMotionControls = controllers[0];

FVector leftHandPosition;
FRotator leftHandOrientation;
FVector rightHandPosition;
FRotator rightHandOrientation;

bool leftTrack = playerMotionControls->GetControllerOrientationAndPosition(0, EControllerHand::Left, leftHandOrientation, leftHandPosition);
bool rightTrack = playerMotionControls->GetControllerOrientationAndPosition(0, EControllerHand::Right, rightHandOrientation, rightHandPosition);

Also what is the relation between the array of IMotionControllers and the index that the GetControllerOrientationAndPosition function takes as a first argument?

The call

 TArray<IMotionController*> controllers = GEngine->MotionControllerDevices;

No longer works in unreal 4.12

Figured out a solution. This requires that a blueprint exists with at least one Motion Controller Component as part of the child tree of the Scene Root.

On begin play:

	TArray<UMotionControllerComponent*> comps;

	this->GetComponents(comps);
	for (UMotionControllerComponent* motionController : comps)
	{
		if (motionController->Hand == EControllerHand::Left) {
			leftHand = motionController;
		}
		else if (motionController->Hand == EControllerHand::Right) {
			rightHand = motionController;
		}
	}

You can use this line of code :

//If you don't want to use a MotionController component and still need to access motion controllers in C++
TArray<IMotionController*> controllers = ModularFeatures::Get().GetModularFeatureImplementations<IMotionController>(IMotionController::GetModularFeatureName());