When the controller is unplugged during gameplay, the game does not automatically pause.

Uploaded Build on Steam and recommended this feature to be implemented to publish game on steam.
Using SteamVR input to map Oculus touch controller input binding to support input on steam and to access controller info SteamVR function library is used

Did use a blueprint function " GetValidTrackedDeviceIDs" but it did not updated when controllers unplugged or not tracked.
And in c++ , browse this
(virtual ETrackingStatus GetControllerTrackingStatus(const int32 ControllerIndex, const FName MotionSource) const = 0 but does not know how to implement this
how to get controller tracking status?

Also try this

TArray<IMotionController*> controllers = IModularFeatures::Get().GetModularFeatureImplementations<IMotionController>(IMotionController::GetModularFeatureName());

for (IMotionController* MotionController : controllers)
{

NumOfControllerActive = NumOfControllerActive + 1;
if (NumOfControllerActive != 0)
{
IsControllerActive = true;
NumOfControllerActive = 0;

}
else
{
IsControllerActive = false;

}
return IsControllerActive;
}

this also not working

Also search this function" SteamVRInputDevice::GetControllerTrackingStatus" to access the controller info but need correct way to implement this

what should i use to get the controller tracking status?

This is how I make the calls to GetControllerTrackingStatus:



bool bTrackingStatusChanged = false;
TArray<IMotionController*> IMCs = IModularFeatures::Get().GetModularFeatureImplementations<IMotionController>(IMotionController::GetModularFeatureName());
for (auto & IMC : IMCs)
{
  if (IMC != nullptr)
  {
   // zero player index since only one VR player
   ETrackingStatus NewLeftHandTrackingStatus = IMC->GetControllerTrackingStatus(0, FXRMotionControllerBase::LeftHandSourceId);
   ETrackingStatus NewRightHandTrackingStatus = IMC->GetControllerTrackingStatus(0, FXRMotionControllerBase::RightHandSourceId);
   bTrackingStatusChanged = (NewLeftHandTrackingStatus != LeftHandTrackingStatus) || (NewRightHandTrackingStatus != RightHandTrackingStatus);
   LeftHandTrackingStatus = NewLeftHandTrackingStatus;
   RightHandTrackingStatus = NewRightHandTrackingStatus;
  }
}

[then if bTrackingStatusChanged, trigger execute a delegate to tell everything interested in it]



If you want it to handle detecting untracked controllers distinct from disconnected, or distinguish inertial-only tracking, you need my pull request here, I have it updated for 4.26 too but haven’t put that on github yet:

https://github.com/EpicGames/UnrealEngine/pull/6990

Thank you for your reply
I am just new to C++ , mostly work with blueprints.That’s why I find out one or more methods to track the controllers but did not know how to implement it .
So,I did try this code and call it on Event tick.
This works when controllers are OFF it give “false” and when one of them turns ON it updated to “true” but it does not updated to “false” when controllers are OFF again while playing.

I assign the default values to LeftHandTrackingStatus and RightHandTrackingStatus



ETrackingStatus LeftHandTrackingStatus = ETrackingStatus::NotTracked;
ETrackingStatus RightHandTrackingStatus= ETrackingStatus::NotTracked;

bool bTrackingStatusChanged = false;

TArray<IMotionController*> IMCs = IModularFeatures::Get().GetModularFeatureImplementations<IMotionController>(IMotionController::GetModularFeatureName());
for (auto & IMC : IMCs)
{
if (IMC != nullptr)
{
// zero player index since only one VR player
ETrackingStatus NewLeftHandTrackingStatus = IMC->GetControllerTrackingStatus(0, FXRMotionControllerBase::LeftHandSourceId);
ETrackingStatus NewRightHandTrackingStatus = IMC->GetControllerTrackingStatus(0, FXRMotionControllerBase::RightHandSourceId);
bTrackingStatusChanged = (NewLeftHandTrackingStatus != LeftHandTrackingStatus) || (NewRightHandTrackingStatus != RightHandTrackingStatus);
//LeftHandTrackingStatus = NewLeftHandTrackingStatus;
//RightHandTrackingStatus = NewRightHandTrackingStatus;

}
}

What needs to be done ? Please, Help
I also search this delegate " FCoreDelegates::OnControllerConnectionChange"

For my snippit, ‘LeftHandTrackingStatus’ and ‘RightHandTracking Status’ must be member variables so they aren’t reset every time. Then it compares them with the new status to see if there was a change. The way you have it, they are going to get reset to ETrackingStatus::NotTracked each time the function is called, because they are local variables, and then bTrackingStatusChanged won’t be true when the controllers turn off because it thinks they were already not tracked.

I did define ‘LeftHandTrackingStatus’ and ‘RightHandTrackingStatus’ them at class level



#include "SteamOverlayInstance.h"
#include "Chandrayaan2.h"
#include "steam/steam_api.h"
#include "Misc/CoreDelegates.h"
#include "IMotionController.h"
#include "Features/IModularFeatures.h"
#include "IMotionController.h"
#include "MotionControllerComponent.h"
#include "XRMotionControllerBase.h"


#ifdef ARRAY_COUNT
#undef ARRAY_COUNT
#endif


ETrackingStatus LeftHandTrackingStatus ;
ETrackingStatus RightHandTrackingStatus ;

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

USteamOverlayInstance::USteamOverlayInstance() {
}

USteamOverlayInstance::~USteamOverlayInstance() {
}





bool USteamOverlayInstance::OnControllerTrackingStatus(){


////////////////////////////////////////////////

bool bTrackingStatusChanged = false;

TArray<IMotionController*> IMCs = IModularFeatures::Get().GetModularFeatureImplementations<IMotionController>(IMotionController::GetModularFeatureName());
for (auto & IMC : IMCs)
{
if (IMC != nullptr)
{
UE_LOG(LogSteamworks, Log, TEXT("Number of controller is activated"));

ETrackingStatus NewLeftHandTrackingStatus = IMC->GetControllerTrackingStatus(0, FXRMotionControllerBase::LeftHandSourceId);
ETrackingStatus NewRightHandTrackingStatus = IMC->GetControllerTrackingStatus(0, FXRMotionControllerBase::RightHandSourceId);

bool LeftTrack = IMC->GetControllerOrientationAndPosition(0, FXRMotionControllerBase::LeftHandSourceId, leftHandOrientation, leftHandPosition,0);

bTrackingStatusChanged = (NewLeftHandTrackingStatus != LeftHandTrackingStatus) || (NewRightHandTrackingStatus != RightHandTrackingStatus);
LeftHandTrackingStatus = NewLeftHandTrackingStatus;
RightHandTrackingStatus = NewRightHandTrackingStatus;

}

}

return bTrackingStatusChanged;

}


I also try to compare NewLeftHandTrackingStatus,NewRightHandTrackingStatus with ETrackedStatus value like this


bTrackingStatusChanged = (NewLeftHandTrackingStatus == ETrackingStatus::Tracked) || (NewRightHandTrackingStatus == ETrackingStatus::Tracked);


NewLeftHandTrackingStatus,NewRightHandTrackingStatus does not updated to ETrackingStatus::NotTracked when controllers are not tracked or OFF(It does not toggle )

You were talking about “to handle detecting untracked controllers distinct from disconnected, or distinguish inertial-only tracking” .Please give more information on this .
Because Oculus touch controller tracking status does not updated to NotTacked once it set to Tracked or appears in scene .

I attached the code above that I am using.
Please, review it and let me know where is the problem

That looks like you made them global, not class members. It may still work, but not if there are multiple IMCs. What calls your
OnControllerTrackingStatus function?

bTrackingStatusChanged needs to be compared against the previous value, not always compared against Tracked as you are doing there in the second snippet.

On the other question, did you look through the pull request link? It is only for SteamVR, I didn’t change anything with Oculus, so Oculus might still be wrong in a similar way.

Again, thank you so much to respond to my question.
I actually found a root cause ,that why Oculus touch controllers tracking status not get updated when controllers are turned OFF and ON while playing.
I simply create a new VR project and try this blueprint function ‘IsMotionControllerTracking’ by passing the source name ‘Left’ or ‘Right’ it gives me the updated status when ever controllers are ON and OFF because of OculusVR plugin that is enabled by default.
And In my project, I disabled OculusVR plugin for Steam Overlay that is showing in oculus on pressing Left oculus touch controller ‘Menu Button’.
When I enabled this plugin the issue of controller tracking resolved because now the default VR platform running on Oculus,it give the updated status of controller and its HMD but now the Steam Overlay disabled in VR mode but it is showing in PC mode by pressing Shift+Tab .
I need both Steam Overlay and Controller status.
Don’t know how to resolve both issues with single plugin or should I need to enable both(SteamVR + OculusVR) ?