Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
wntrkwl's avatar
wntrkwl
Explorer
8 years ago

OVRInput.GetActiveController() == OVRInput.Controller.LTrackedRemote ... Not working in Unity3D

Hi I'm having a little trouble using OVRInput.GetActiveController, perhaps I'm misunderstanding how it's used.
I'm building a Samsung GearVR app which needs to support both IF the player has a SamsungGearVR Controller paired with their phone as well as the condition where they do not. 

What I need to achieve is a branching input scheme dependent on if they have a controller paired. But I'm stuck just trying to determine whether they have the controller paired. The following code is the bare bones test I was trying to do, but if the controller IS paired it never kicks off the ProcessControllerClickAtPosition method.

The other method works fine, I can get the 
ProcessHMDClickAtPosition to correctly get triggered whenever the touchpad on the HMD is clicked.

I'm forced to use Unity 5.5.4 because my work is being integrated into a larger project of which I can't control so any advice will have to work on that version of Unity I'm afraid.

Any help at all is greatly appreciated!

public class ManualGaze : MonoBehaviour
{
// Update is called once per frame
void Update()
{
if (OVRInput.GetActiveController() == OVRInput.Controller.LTrackedRemote || OVRInput.GetActiveController() == OVRInput.Controller.RTrackedRemote)
{
// yes, are they touching the touchpad?
if (OVRInput.Get(OVRInput.Touch.PrimaryTouchpad))
{
// yes, let's require an actual click rather than just a touch.
if (OVRInput.Get(OVRInput.Button.PrimaryTouchpad))
{
// button is depressed, handle the touch.
Vector2 touchPosition = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad);
ProcessControllerClickAtPosition(touchPosition);
}
}
}
else if (OVRInput.Get(OVRInput.Touch.PrimaryTouchpad)) // finger on HMD pad?
{
// not using controller, same behavior as before.
Vector2 touchPosition = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad);
ProcessHMDClickAtPosition(touchPosition);
}
}

private void ProcessHMDClickAtPosition(Vector2 touchPosition)
{
Debug.Log("Heard that since there is no controller the touchpad was clicked instead!");
}

private void ProcessControllerClickAtPosition(Vector2 touchPosition)
{
Debug.Log("Heard the touchpad on the controller clicked!");
}
}


Replies have been turned off for this discussion