GvrControllerInput

Main entry point for the Daydream controller API.

Summary

To use this API, add this behavior to a GameObject in your scene, or use the GvrControllerMain prefab. There can only be one object with this behavior on your scene.

This is a singleton object.

To access the controller state, simply read the static properties of this class. For example, to know the controller's current orientation, use GvrControllerInput.Orientation.

Inheritance

Inherits from: MonoBehaviour

Public types

EmulatorConnectionMode enum

Events

OnControllerInputUpdated
static Action
Event handler for receiving button, track pad, and IMU updates from the controller.
OnPostControllerInputUpdated
static Action

Public attributes

emulatorConnectionMode = EmulatorConnectionMode.USB
EmulatorConnectionMode
Indicates how we connect to the controller emulator.

Properties

Accel
static Vector3
Returns the controller's accelerometer reading.
ApiStatus
static GvrControllerApiStatus
Returns the API status of the current controller state.
AppButton
static bool
If true, the app button (touchpad button) is currently being pressed.
AppButtonDown
static bool
If true, the app button was just pressed.
AppButtonUp
static bool
If true, the app button was just released.
BatteryLevel
static GvrControllerBatteryLevel
If true, the user is currently touching the controller's touchpad.
ClickButton
static bool
If true, the click button (touchpad button) is currently being pressed.
ClickButtonDown
static bool
If true, the click button (touchpad button) was just pressed.
ClickButtonUp
static bool
If true, the click button (touchpad button) was just released.
ErrorDetails
static string
If State == GvrConnectionState.Error, this contains details about the error.
Gyro
static Vector3
Returns the controller's gyroscope reading.
HomeButtonDown
static bool
If true, the home button was just pressed.
HomeButtonState
static bool
If true, the home button is currently being pressed.
IsCharging
static bool
If true, the user is currently touching the controller's touchpad.
IsTouching
static bool
If true, the user is currently touching the controller's touchpad.
Orientation
static Quaternion
Returns the controller's current orientation in space, as a quaternion.
Recentered
static bool
If true, the user just completed the recenter gesture.
Recentering
static bool
If true, the user is currently performing the recentering gesture.
State
static GvrConnectionState
Returns the controller's current connection state.
StatePtr
static IntPtr
SupportsBatteryStatus
static bool
Returns true if battery status is supported.
TouchDown
static bool
If true, the user just started touching the touchpad.
TouchPos
static Vector2
Position of the current touch, if touching the touchpad.
TouchPosCentered
static Vector2
Position of the current touch, if touching the touchpad.
TouchUp
static bool
If true, the user just stopped touching the touchpad.

Public types

EmulatorConnectionMode

 EmulatorConnectionMode

Events

OnControllerInputUpdated

static Action OnControllerInputUpdated

Event handler for receiving button, track pad, and IMU updates from the controller.

OnPostControllerInputUpdated

static Action OnPostControllerInputUpdated

Public attributes

emulatorConnectionMode

EmulatorConnectionMode emulatorConnectionMode = EmulatorConnectionMode.USB

Indicates how we connect to the controller emulator.

Properties

Accel

static Vector3 Accel

Returns the controller's accelerometer reading.

The accelerometer indicates the effect of acceleration and gravity in the direction of each of the controller's local axes. The controller's local axes are: X points to the right, Y points perpendicularly up from the controller's top surface and Z lies along the controller's body, pointing towards the front. The acceleration is measured in meters per second squared. Note that gravity is combined with acceleration, so when the controller is resting on a table top, it will measure an acceleration of 9.8 m/s^2 on the Y axis. The accelerometer reading will be zero on all three axes only if the controller is in free fall, or if the user is in a zero gravity environment like a space station.

ApiStatus

static GvrControllerApiStatus ApiStatus

Returns the API status of the current controller state.

AppButton

static bool AppButton

If true, the app button (touchpad button) is currently being pressed.

This is not an event: it represents the button's state (it remains true while the button is being pressed).

AppButtonDown

static bool AppButtonDown

If true, the app button was just pressed.

This is an event flag: it will be true for only one frame after the event happens.

AppButtonUp

static bool AppButtonUp

If true, the app button was just released.

This is an event flag: it will be true for only one frame after the event happens.

BatteryLevel

static GvrControllerBatteryLevel BatteryLevel

If true, the user is currently touching the controller's touchpad.

ClickButton

static bool ClickButton

If true, the click button (touchpad button) is currently being pressed.

This is not an event: it represents the button's state (it remains true while the button is being pressed).

ClickButtonDown

static bool ClickButtonDown

If true, the click button (touchpad button) was just pressed.

This is an event flag: it will be true for only one frame after the event happens.

ClickButtonUp

static bool ClickButtonUp

If true, the click button (touchpad button) was just released.

This is an event flag: it will be true for only one frame after the event happens.

ErrorDetails

static string ErrorDetails

If State == GvrConnectionState.Error, this contains details about the error.

Gyro

static Vector3 Gyro

Returns the controller's gyroscope reading.

The gyroscope indicates the angular about each of its local axes. The controller's axes are: X points to the right, Y points perpendicularly up from the controller's top surface and Z lies along the controller's body, pointing towards the front. The angular speed is given in radians per second, using the right-hand rule (positive means a right-hand rotation about the given axis).

HomeButtonDown

static bool HomeButtonDown

If true, the home button was just pressed.

HomeButtonState

static bool HomeButtonState

If true, the home button is currently being pressed.

IsCharging

static bool IsCharging

If true, the user is currently touching the controller's touchpad.

IsTouching

static bool IsTouching

If true, the user is currently touching the controller's touchpad.

Orientation

static Quaternion Orientation

Returns the controller's current orientation in space, as a quaternion.

The space in which the orientation is represented is the usual Unity space, with X pointing to the right, Y pointing up and Z pointing forward. Therefore, to make an object in your scene have the same orientation as the controller, simply assign this quaternion to the GameObject's transform.rotation.

Recentered

static bool Recentered

If true, the user just completed the recenter gesture.

The controller's orientation is now being reported in the new recentered coordinate system (the controller's orientation when recentering was completed was remapped to mean "forward"). This is an event flag (it is true for only one frame after the event happens, then reverts to false). The headset is recentered together with the controller.

Recentering

static bool Recentering

If true, the user is currently performing the recentering gesture.

Most apps will want to pause the interaction while this remains true.

State

static GvrConnectionState State

Returns the controller's current connection state.

StatePtr

static IntPtr StatePtr

SupportsBatteryStatus

static bool SupportsBatteryStatus

Returns true if battery status is supported.

TouchDown

static bool TouchDown

If true, the user just started touching the touchpad.

This is an event flag (it is true for only one frame after the event happens, then reverts to false).

TouchPos

static Vector2 TouchPos

Position of the current touch, if touching the touchpad.

If not touching, this is the position of the last touch (when the finger left the touchpad). The X and Y range is from 0 to 1. (0, 0) is the top left of the touchpad and (1, 1) is the bottom right of the touchpad.

TouchPosCentered

static Vector2 TouchPosCentered

Position of the current touch, if touching the touchpad.

If not touching, this is the position of the last touch (when the finger left the touchpad). The X and Y range is from -1 to 1. (-.707,-.707) is bottom left, (.707,.707) is upper right. (0, 0) is the center of the touchpad. The magnitude of the touch vector is guaranteed to be <= 1.

TouchUp

static bool TouchUp

If true, the user just stopped touching the touchpad.

This is an event flag (it is true for only one frame after the event happens, then reverts to false).