# Controller

class in `gamepad-manager`, extends `EventDispatcher`

```js
import { Controller } from 'gamepad-manager';
```

Base class for an input device with named buttons and axes.

## Properties

### .type: string

The kind of device: `'gamepad'`, `'keyboard'` or `'mouse'`.

### .connected: boolean

Whether the device is available. Always true for the keyboard and mouse.

### .pressThreshold: number

How far an analog button must be pressed to count as held.

### .releaseThreshold: number

How far a held analog button must come back to count as released.

## Methods

### .getButtonName

```js
.getButtonName( name: string ): string
```

The name printed on the device for a button, e.g. `'A'` or `'W'`.

- `name`, `string`

### .getButtonHeld

```js
.getButtonHeld( name: string ): boolean
```

Whether the button is down.

- `name`, `string`

### .getButtonPressed

```js
.getButtonPressed( name: string ): boolean
```

Whether the button went down in the last update.

- `name`, `string`

### .getButtonReleased

```js
.getButtonReleased( name: string ): boolean
```

Whether the button went up in the last update.

- `name`, `string`

### .getAxis

```js
.getAxis( name: string ): number
```

The axis value from -1 to 1, or how far a button is pressed from 0 to 1.

- `name`, `string`

## Events

### pressed

Fired when a button goes down. The event object is reused.

- `name`, `string`: The button's name.

### released

Fired when a button goes up. The event object is reused.

- `name`, `string`: The button's name.
