Oculus Quest Controllers Battery Levels

Hello everybody,

I am struggling for a bit to find a way to get the battery levels of the controllers (maybe even the headset) on Oculus Quest/Quest 2. I can’t seem to find any link to battery percentages in the Oculus Plugin. I am using Unreal 4.22.3 with the latest plugins from Oculus. Also to mention that I want to track the battery levels when connected via Oculus Link. Any advice or help would be much appreciated.

Best regards, Alex.

Not sure if you can get this from Blueprints, but from C++ the OVRPlugin header file contains these functions which should give you access to what you want:


/// Gets the status of the system's battery or "Unknown" if there is none.
OVRP_EXPORT ovrpResult ovrp_GetSystemBatteryStatus2(ovrpBatteryStatus* systemBatteryStatus);

/// Gets the current available battery charge, ranging from 0 (empty) to 1 (full).
OVRP_EXPORT ovrpResult ovrp_GetSystemBatteryLevel2(float* systemBatteryLevel);

Hope this helps,

1 Like

Sorry, that’s system battery only. The controller battery state can be read from the ovrpControllerState4 structure received from GetControllerState4.


/// Gets the controller state for the given controllers.
OVRP_EXPORT ovrpResult ovrp_GetControllerState4(ovrpController controllerMask, ovrpControllerState4* controllerState);

/// Describes Input State for use with Gamepads and Oculus Controllers.
typedef struct {
    unsigned int ConnectedControllerTypes;
    unsigned int Buttons;
    unsigned int Touches;
    unsigned int NearTouches;
    float IndexTrigger[2];
    float HandTrigger[2];
    ovrpVector2f Thumbstick[2];
    ovrpVector2f Touchpad[2];
    unsigned char BatteryPercentRemaining[2];
    unsigned char RecenterCount[2];
    unsigned char Reserved[28];
} ovrpControllerState4;


1 Like

That is perfect .Thank you very much for the replay.

Best regards, Alex.

Sorry to necro an old post. I’m a bit of novice with c++. Would someone be able to explain in more detail how to use that logic to read the battery levels? I have put that logic into a function on a custom class but don’t understand how to get information from that ovrpResult.

Regards, Matthew

Finally got the time to figure this one out. Just want to leave some details in case anyone else could use them. In your GameName.Build.cs folder include “OculusHMD” and “OVRPlugin” in the PublicDependencyModuleNames list. Then you can call functions using the oculus plugin wrapper. No idea if it’s the best way but does the trick.

Header file

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"

#pragma warning(push)
#pragma warning(disable:4201)		// nonstandard extension used: nameless struct/union
//#pragma warning(disable:4668)		// 'symbol' is not defined as a preprocessor macro, replacing with '0' for 'directives'
#define OVRP_EXPORT typedef
#include "OVR_Plugin.h"
#include "OVR_Plugin_MixedReality.h"
#include "OVR_Plugin_Media.h"

#undef OVRP_EXPORT
#pragma warning(pop)


#include "OculusFunctionLibraryCureo.generated.h"

/**
 * 
 */
UCLASS()
class MAP_API UOculusFunctionLibraryCureo : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()
	
	UFUNCTION(BlueprintPure, Category = "OculusFunctionLibraryCureo")
		static void GetControllerBatteryLevels(float& BatteryPercentRemainingL, float& BatteryPercentRemainingR);
};

.cpp file

#include "OculusFunctionLibraryCureo.h"
#include "OculusHMD/Private/OculusHMDModule.h"

void UOculusFunctionLibraryCureo::GetControllerBatteryLevels(float& BatteryPercentRemainingL, float& BatteryPercentRemainingR)
{

#if OCULUS_HMD_SUPPORTED_PLATFORMS
#if PLATFORM_ANDROID
    ovrpController ControllerTypes = ovrpController_Touch; 
    ovrpControllerState4 OvrpControllerState;
    FOculusHMDModule::GetPluginWrapper().GetControllerState4(ControllerTypes, &OvrpControllerState);
    BatteryPercentRemainingL = (float)OvrpControllerState.BatteryPercentRemaining[0];
    BatteryPercentRemainingR = (float)OvrpControllerState.BatteryPercentRemaining[1];

#else
    BatteryPercentRemainingL = -1.0;
    BatteryPercentRemainingR = -1.0;
#endif 
#endif

}
1 Like