GvrControllerInputDevice

Device instance of the Daydream controller API.

Summary

Events

OnStateChanged
Event handler for when the connection state of the controller changes.

Properties

Accel
Vector3
Gets the controller's current acceleration in meters per second squared.
ApiStatus
GvrControllerApiStatus
Gets the API status of the current controller state.
BatteryLevel
GvrControllerBatteryLevel
Gets the controller's current battery charge level.
Buttons
GvrControllerButton
Gets the bitmask of the buttons that are down in the current frame.
ButtonsDown
GvrControllerButton
Gets the bitmask of the buttons that began being pressed in the current frame.
ButtonsUp
GvrControllerButton
Gets the bitmask of the buttons that ended being pressed in the current frame.
ErrorDetails
string
Gets GvrConnectionState error details.
Gyro
Vector3
Gets the controller's current angular speed in radians per second.
IsCharging
bool
Gets a value indicating whether the controller is currently being charged.
IsDominantHand
bool
Gets a value indicating whether this instance is dominant hand.
IsRightHand
bool
Gets a value indicating whether this instance is configured as being the right hand.
Orientation
Quaternion
Gets the controller's current orientation in space, as a quaternion.
Position
Vector3
Gets the controller's current position in world space.
Recentered
bool
Gets a value indicating whether the user just completed the recenter gesture.
State
GvrConnectionState
Gets the controller's current connection state.
StatePtr
IntPtr
Gets the GVR C library controller state pointer (gvr_controller_state*).
TouchPos
Vector2
Gets the position of the current touch, if touching the touchpad.

Public functions

GetButton(GvrControllerButton buttons)
bool
Gets a value indicating whether the user is holding down any of the buttons specified in buttons.
GetButtonDown(GvrControllerButton buttons)
bool
Gets a value indicating whether the user starts pressing down any of the buttons specified in buttons.
GetButtonUp(GvrControllerButton buttons)
bool
Gets a value indicating whether this is the frame after the user stops pressing down any of the buttons specified in buttons.

Events

OnStateChanged

GvrControllerInput.OnStateChangedEvent OnStateChanged

Event handler for when the connection state of the controller changes.

Properties

Accel

Vector3 Accel

Gets the controller's current acceleration in meters per second squared.

The controller's axes are:

  • X points to the right.
  • Y points perpendicularly up from the controller's top surface.
  • Z lies along the controller's body, pointing towards the front.

Note that gravity is indistinguishable from acceleration, so when the controller is resting on a surface, expect to 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.

The acceleration in m/s^2.

ApiStatus

GvrControllerApiStatus ApiStatus

Gets the API status of the current controller state.

The API status.

BatteryLevel

GvrControllerBatteryLevel BatteryLevel

Gets the controller's current battery charge level.

The battery charge level.

Buttons

GvrControllerButton Buttons

Gets the bitmask of the buttons that are down in the current frame.

The bitmask of currently-down buttons.

ButtonsDown

GvrControllerButton ButtonsDown

Gets the bitmask of the buttons that began being pressed in the current frame.

Each individual button enum is guaranteed to be followed by exactly one ButtonsUp event in a later frame. ButtonsDown and ButtonsUp will never both be true in the same frame for an individual button.

The bitmask of just-pressed-down buttons.

ButtonsUp

GvrControllerButton ButtonsUp

Gets the bitmask of the buttons that ended being pressed in the current frame.

Each individual button enum is guaranteed to be preceded by exactly one ButtonsDown event in an earlier frame. ButtonsDown and ButtonsUp will never both be true in the same frame for an individual button.

The bitmask of just-released buttons.

ErrorDetails

string ErrorDetails

Gets GvrConnectionState error details.

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

The error details.

Gyro

Vector3 Gyro

Gets the controller's current angular speed in radians per second.

Generated using the right-hand rule (positive means a right-hand rotation about the given axis), as measured by the controller's gyroscope.

The controller's axes are:

  • X points to the right.
  • Y points perpendicularly up from the controller's top surface.
  • Z lies along the controller's body, pointing towards the front.

The gyro's angular speed.

IsCharging

bool IsCharging

Gets a value indicating whether the controller is currently being charged.

Value true if this instance is charging. Otherwise, false.

IsDominantHand

bool IsDominantHand

Gets a value indicating whether this instance is dominant hand.

Value true if this instance is dominant hand, false otherwise.

IsRightHand

bool IsRightHand

Gets a value indicating whether this instance is configured as being the right hand.

Value true if this instance is right hand, false otherwise.

Orientation

Quaternion Orientation

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

The rotation is provided in 'orientation space' which means the rotation is given relative to the last time the user recentered their controller. To make a game object in your scene have the same orientation as the controller, simply assign this quaternion to the object's transform.rotation. To match the relative rotation, use transform.localRotation instead.

The orientation.

Position

Vector3 Position

Gets the controller's current position in world space.

The controller's current position in world space.

Recentered

bool Recentered

Gets a value indicating whether the user just completed the recenter gesture.

The headset and the controller's orientation are now being reported in the new recentered coordinate system.

Value true if the user just completed the recenter gesture, false otherwise. This is an event flag (it is true for only one frame after the event happens, then reverts to false).

State

GvrConnectionState State

Gets the controller's current connection state.

The state.

StatePtr

IntPtr StatePtr

Gets the GVR C library controller state pointer (gvr_controller_state*).

The state pointer.

TouchPos

Vector2 TouchPos

Gets the position of the current touch, if touching the touchpad.

The X and Y range is from -1.0 to 1.0. (0, 0) is the center of the touchpad. (-.707, -.707) is bottom left, (.707, .707) is upper right. The magnitude of the touch vector is guaranteed to be less than or equal to 1.0.

The 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).

Public functions

GetButton

bool GetButton(
  GvrControllerButton buttons
)

Gets a value indicating whether the user is holding down any of the buttons specified in buttons.

Multiple GvrControllerButton types can be checked at once using a bitwise-or operation.

Details
Parameters
buttons
The button to get the held state for this frame.
Returns
Returns true if the designated button is being held this frame.

GetButtonDown

bool GetButtonDown(
  GvrControllerButton buttons
)

Gets a value indicating whether the user starts pressing down any of the buttons specified in buttons.

For an individual button enum, every ButtonDown event is guaranteed to be followed by exactly one ButtonUp event in a later frame. ButtonDown and ButtonUp will never both be true in the same frame for an individual button.

Using multiple button enums together with an or statement can result in multiple ButtonDowns before a ButtonUp.

Details
Parameters
buttons
The button to get the press-state for this frame.
Returns
Returns true if the designated button was pressed this frame.

GetButtonUp

bool GetButtonUp(
  GvrControllerButton buttons
)

Gets a value indicating whether this is the frame after the user stops pressing down any of the buttons specified in buttons.

For an individual button enum, every ButtonUp event is guaranteed to be preceded by exactly one ButtonDown event in an earlier frame. ButtonDown and ButtonUp will never both be true in the same frame for an individual button.

Using multiple button enums together with an or statement can result in multiple ButtonUps after multiple ButtonDowns.

Details
Parameters
buttons
The button to get the release-state for this frame.
Returns
Returns true if the designated button was released this frame.