Developing for the Gear VR Controller
Oculus Developer Blog
|
Posted by Chris Pruett
|
March 15, 2017
|
Share

We recently released an update to our Mobile SDK that adds support for the new Gear VR Controller. Support is also shipping in Unity 5.3.8f1, Unity 5.4.5f1, Unity 5.5.2p3, and our Unreal 4 Github. Though the Controller hasn’t shipped yet, it’s useful to look at the updated SDK for development planning. Here’s a quick overview of the device and how you can integrate it into your Gear VR applications.

Features and Capabilities

The Gear VR Controller is a wireless device with a clickable trackpad, binary trigger, and 3DOF orientation sensing. It also has the standard Gear VR Back, Home, and Volume buttons. People can configure their preference for left- or right-handed use in the Oculus application (only one Gear VR Controller can be used at a time). The SDK provides methods for querying button state and orientation direction, as well as enumerating attached input devices and detecting disconnections. The SDK also provides a simple arm model that can be optionally used to approximate hand position based on the Controller's orientation.

The basic Unity interface for this new API is contained within the Oculus Utilities for Unity 5 package (version 1.12 and up), within OVRInput.cs.

// get the orientation of a right-handed remote
Quaternion rotation = OVRInput.GetLocalControllerRotation(
     OVRInput.Controller.RTrackedRemote);

OVRInput.cs now also provides an interface to query the Gear VR HMD Touchpad, which is useful to differentiate between HMD touches and Controller trackpad touches. The Controller trackpad, unlike the HMD trackpad, reports absolute touch positions and is highly accurate. We’ve released complete documentation for Unity and for Unreal.

Event Reporting

The Gear VR Controller trackpad can be used by existing applications without code modifications. When the Gear VR Controller is connected, it’ll report input events both via the Mobile SDK interface and as standard Android input events. The former are highly accurate, unfiltered input from the controller, while the latter events have been filtered to maintain compatibility with legacy applications. All applications should move away from standard Android event reporting (e.g. Unity’s mapping of the Gear VR HMD Trackpad to a mouse) for input and instead use the new SDK interfaces. Orientation and trigger inputs are not available as Android input events.

The Unity integration automatically tracks the “active” controller, which can either be a Gear VR Controller or the HMD trackpad, depending on whatever the player used most recently. Both are reported as OVRInput.Touch.PrimaryTouchpad, but you can differentiate between the two by checking the active controller. Note that in addition to increased accuracy and absolute position reporting, the range of values returned by the Gear VR Controller is a different scale than those returned by the HMD trackpad; if your code relies on swipe distances, you’ll want to detect the current controller and use different thresholds.

// old way
// if (Input.GetMouseButton(0)) // the finger has touched the HMD trackpad.
// {
//     Vector2 touchPosition = Input.mousePosition;
//     ProcessClickAtPosition(touchPosition);
// }

// new way
// The Gear VR Controller has a clickable trackpad, so we can differentiate between
// the finger simply touching the pad and actively depressing it.

// is player using a controller?
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);
}

Designing for the Future

The Gear VR Controller is the default input system for Gear VR going forward. It will be available at launch to existing users for purchase and new users who will get it as a bundle with the new headset. That said, some users who own a Gear VR will not have a Gear VR controller. To reach the widest audience, it’s important that your application be usable with or without a Gear VR Controller. Make sure to list the Controller as “Supported” in the Oculus Dashboard so that users can tell what sort of control interface to expect. Note that games that require a gamepad may continue to do so.

How Do I Get One?

The Gear VR Controller will be released to the public soon. Development kits are not publicly available, but if you have a project in development that you’d like to add Gear VR Controller support to, apply for early access via the Oculus Hardware Request Form. Please note that supply is very limited.

We can’t wait to see how the developer community incorporates the Gear VR Controller into their VR apps.