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
Returns the controller's current acceleration in meters per second squared.
|
ApiStatus
|
GvrControllerApiStatus
Returns the API status of the current controller state.
|
BatteryLevel
|
GvrControllerBatteryLevel
Returns the controller's current battery charge level.
|
ErrorDetails
|
string
If State == GvrConnectionState.Error, this contains details about the error.
|
Gyro
|
Vector3
Returns the controller's current angular speed in radians per second, using the right-hand rule (positive means a right-hand rotation about the given axis), as measured by the controller's gyroscope.
|
IsCharging
|
bool
Returns true if the controller is currently being charged.
|
IsDominantHand
|
bool
|
IsRightHand
|
bool
|
Orientation
|
Quaternion
Returns the controller's current orientation in space, as a quaternion.
|
Position
|
Vector3
|
Recentered
|
bool
Returns true if the user just completed the recenter gesture.
|
State
|
GvrConnectionState
Returns the controller's current connection state.
|
StatePtr
|
IntPtr
Returns the GVR C library controller state pointer (gvr_controller_state*).
|
TouchPos
|
Vector2
Position of the current touch, if touching the touchpad.
|
Public functions |
|
---|---|
GetButton(GvrControllerButton buttons)
|
bool
Returns true if the user is holding down any of the buttons specified in
buttons . |
GetButtonDown(GvrControllerButton buttons)
|
bool
Returns true in the frame the user starts pressing down any of the buttons specified in
buttons . |
GetButtonUp(GvrControllerButton buttons)
|
bool
Returns true 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
Returns 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.
ApiStatus
GvrControllerApiStatus ApiStatus
Returns the API status of the current controller state.
BatteryLevel
GvrControllerBatteryLevel BatteryLevel
Returns the controller's current battery charge level.
ErrorDetails
string ErrorDetails
If State == GvrConnectionState.Error, this contains details about the error.
Gyro
Vector3 Gyro
Returns the controller's current angular speed in radians per second, 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
IsCharging
bool IsCharging
Returns true if the controller is currently being charged.
IsDominantHand
bool IsDominantHand
IsRightHand
bool IsRightHand
Orientation
Quaternion Orientation
Returns 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.
Position
Vector3 Position
Recentered
bool Recentered
Returns true if the user just completed the recenter gesture.
The headset and the controller's orientation are now being reported in the new recentered coordinate system. This is an event flag (it is true for only one frame after the event happens, then reverts to false).
State
GvrConnectionState State
Returns the controller's current connection state.
StatePtr
IntPtr StatePtr
Returns the GVR C library controller state pointer (gvr_controller_state*).
TouchPos
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 -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 <= 1.0.
Public functions
GetButton
bool GetButton( GvrControllerButton buttons )
Returns true if the user is holding down any of the buttons specified in buttons
.
GvrControllerButton types can be OR-ed together to check for multiple buttons at once.
GetButtonDown
bool GetButtonDown( GvrControllerButton buttons )
Returns true in the frame 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. Also, ButtonDown and ButtonUp will never both be true in the same frame for an individual button. Using multiple button enums OR'ed together can result in multiple ButtonDowns before a ButtonUp.
GetButtonUp
bool GetButtonUp( GvrControllerButton buttons )
Returns true 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. Also, ButtonDown and ButtonUp will never both be true in the same frame for an individual button. Using multiple button enums OR'ed together can result in multiple ButtonUps after multiple ButtonDowns.