# GvrControllerInputDevice Class Reference

# GvrControllerInputDevice

Device instance of the Daydream controller API.

## Summary

| ### Events ||
|---|---|
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1a29ef914da19488d31da6a9e5ef76a6ea` | `https://developers.google.com/vr/reference/unity/class/GvrControllerInput#classGvrControllerInput_1a9de085bc0a7c592c4cd6bebc707496df` Event handler for when the connection state of the controller changes. |

| ### Properties ||
|---|---|
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1addba5cbc64de4a5858a426401fd24325` | `Vector3` Gets the controller's current acceleration in meters per second squared. |
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1a3ef41a77212c3389aab7d0aed7308452` | `GvrControllerApiStatus` Gets the API status of the current controller state. |
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1a854bdcefc864c0e5759546943afacf1d` | `GvrControllerBatteryLevel` Gets the controller's current battery charge level. |
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1a69b59d8318357a462d94f74c72b63458` | `GvrControllerButton` Gets the bitmask of the buttons that are down in the current frame. |
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1ac5d4dd0a392577bd47d166063199e5f4` | `GvrControllerButton` Gets the bitmask of the buttons that began being pressed in the current frame. |
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1adffc51659c4e99be94b3f3d949e12af7` | `GvrControllerButton` Gets the bitmask of the buttons that ended being pressed in the current frame. |
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1a0f55798b094d9b2c915e3caf625093c1` | `string` Gets `GvrConnectionState` error details. |
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1a25a377c2a923188c6e33099d369c578d` | `Vector3` Gets the controller's current angular speed in radians per second. |
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1adb56a29fb51b36068a935de3caca5e2b` | `bool` Gets a value indicating whether the controller is currently being charged. |
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1a7811ab33e5a32874f87c1864fed92903` | `bool` Gets a value indicating whether this instance is dominant hand. |
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1ae16983b6b5f1f2283ade17cf376b9c07` | `bool` Gets a value indicating whether this instance is configured as being the right hand. |
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1aaa9d9e247cf16e6aed7af591a085913f` | `Quaternion` Gets the controller's current orientation in space, as a quaternion. |
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1af43dbf325ff9bb42e4cf8097a8c4d339` | `Vector3` Gets the controller's current position in world space. |
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1a46c86eeda202d6c5fdaf764587aee265` | `bool` Gets a value indicating whether the user just completed the recenter gesture. |
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1ac0dd37fe365d6b39138b3af67736de7d` | `GvrConnectionState` Gets the controller's current connection state. |
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1ad2580c473bbb082421f993e169466744` | `IntPtr` Gets the GVR C library controller state pointer (`gvr_controller_state*`). |
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1aafb99a683bacb2ac694a42f5410a9018` | `Vector2` Gets the position of the current touch, if touching the touchpad. |

| ### Public functions ||
|---|---|
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1a211230d723885785c1a384891089faaa(GvrControllerButton buttons)` | `bool` Gets a value indicating whether the user is holding down any of the buttons specified in `buttons`. |
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1a8e46e0e8a233540a556f55eb64c7d8a3(GvrControllerButton buttons)` | `bool` Gets a value indicating whether the user starts pressing down any of the buttons specified in `buttons`. |
| `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice_1a129710cec0f1334f08cd602505c910b6(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

```c#
GvrControllerInput.OnStateChangedEvent OnStateChanged
```
Event handler for when the connection state of the controller changes.

## Properties

### Accel

```c#
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.

<br />

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

```c#
GvrControllerApiStatus ApiStatus
```
Gets the API status of the current controller state.

The API status.

### BatteryLevel

```c#
GvrControllerBatteryLevel BatteryLevel
```
Gets the controller's current battery charge level.

The battery charge level.

### Buttons

```c#
GvrControllerButton Buttons
```
Gets the bitmask of the buttons that are down in the current frame.

The bitmask of currently-down buttons.

### ButtonsDown

```c#
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

```c#
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

```c#
string ErrorDetails
```
Gets `GvrConnectionState` error details.

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

The error details.

### Gyro

```c#
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.

<br />

The gyro's angular speed.

### IsCharging

```c#
bool IsCharging
```
Gets a value indicating whether the controller is currently being charged.

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

### IsDominantHand

```c#
bool IsDominantHand
```
Gets a value indicating whether this instance is dominant hand.

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

### IsRightHand

```c#
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

```c#
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

```c#
Vector3 Position
```
Gets the controller's current position in world space.

The controller's current position in world space.

### Recentered

```c#
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

```c#
GvrConnectionState State
```
Gets the controller's current connection state.

The state.

### StatePtr

```c#
IntPtr StatePtr
```
Gets the GVR C library controller state pointer (`gvr_controller_state*`).

The state pointer.

### TouchPos

```c#
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

```c#
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.

<br />

| 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

```c#
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 `ButtonDown`s before a `ButtonUp`.

<br />

| 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

```c#
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 `ButtonUp`s after multiple `ButtonDown`s.

<br />

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