# Class: SinglePad

## Phaser. SinglePad

A single Phaser Gamepad

#### new SinglePad(game, padParent)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `game` | Phaser.Game | Current game instance.
  `padParent` | Object | The parent Phaser.Gamepad object (all gamepads reside under this)

  Source:
    - input/SinglePad.js, line 14

### Members

#### _index

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `index` | number | The gamepad index as per browsers data

  Default Value:
    - null
  Source:
    - input/SinglePad.js, line 30

#### _padParent

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `padParent` | Phaser.Gamepad | Main Phaser Gamepad object

  Source:
    - input/SinglePad.js, line 24

#### callbackContext

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `callbackContext` | Object | The context under which the callbacks are run.

  Source:
    - input/SinglePad.js, line 77

#### <readonly> connected

  Whether or not this particular gamepad is connected or not.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `connected` | boolean | Whether or not this particular gamepad is connected or not.

  Source:
    - input/SinglePad.js, line 543

#### deadZone

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `deadZone` | number | Dead zone for axis feedback - within this value you won't trigger updates.

  Source:
    - input/SinglePad.js, line 112

#### game

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `game` | Phaser.Game | Local reference to game.

  Source:
    - input/SinglePad.js, line 19

#### <readonly> index

  Gamepad index as per browser data

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `index` | number | The gamepad index, used to identify specific gamepads in the browser

  Source:
    - input/SinglePad.js, line 557

#### onAxisCallback

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `onAxisCallback` | function | This callback is invoked every time an axis is changed.

  Source:
    - input/SinglePad.js, line 102

#### onConnectCallback

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `onConnectCallback` | function | This callback is invoked every time this gamepad is connected

  Source:
    - input/SinglePad.js, line 82

#### onDisconnectCallback

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `onDisconnectCallback` | function | This callback is invoked every time this gamepad is disconnected

  Source:
    - input/SinglePad.js, line 87

#### onDownCallback

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `onDownCallback` | function | This callback is invoked every time a button is pressed down.

  Source:
    - input/SinglePad.js, line 92

#### onFloatCallback

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `onFloatCallback` | function | This callback is invoked every time a button is changed to a value where value > 0 and value < 1.

  Source:
    - input/SinglePad.js, line 107

#### onUpCallback

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `onUpCallback` | function | This callback is invoked every time a gamepad button is released.

  Source:
    - input/SinglePad.js, line 97

### Methods

#### addButton(buttonCode) → {Phaser.GamepadButton}

  If you need more fine-grained control over a Key you can create a new Phaser.Key object via this method. The Key object can then be polled, have events attached to it, etc.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `buttonCode` | number | The buttonCode of the button, i.e. Phaser.Gamepad.BUTTON_0 or Phaser.Gamepad.BUTTON_1

  Source:
    - input/SinglePad.js, line 139

  ##### Returns:

  The GamepadButton object which you can store locally and reference directly.

  Type
    Phaser.GamepadButton

#### addCallbacks(context, callbacks)

  Add callbacks to the this Gamepad to handle connect/disconnect/button down/button up/axis change/float value buttons

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `context` | Object | The context under which the callbacks are run.
  `callbacks` | Object | Object that takes six different callbak methods: onConnectCallback, onDisconnectCallback, onDownCallback, onUpCallback, onAxisCallback, onFloatCallback

  Source:
    - input/SinglePad.js, line 118

#### axis(axisCode) → {number}

  Returns value of requested axis

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `axisCode` | number | The index of the axis to check

  Source:
    - input/SinglePad.js, line 439

  ##### Returns:

  Axis value if available otherwise false

  Type
    number

#### buttonValue(buttonCode) → {boolean}

  Returns the value of a gamepad button. Intended mainly for cases when you have floating button values, for example analog trigger buttons on the XBOX 360 controller

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `buttonCode` | number | The buttonCode of the button to check.

  Source:
    - input/SinglePad.js, line 503

  ##### Returns:

  Button value if available otherwise false.

  Type
    boolean

#### connect(rawPad)

  Gamepad connect function, should be called by Phaser.Gamepad

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `rawPad` | Object | The raw gamepad object

  Source:
    - input/SinglePad.js, line 208

#### disconnect()

  Gamepad disconnect function, should be called by Phaser.Gamepad

  Source:
    - input/SinglePad.js, line 235

#### isDown(buttonCode) → {boolean}

  Returns true if the button is currently pressed down.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `buttonCode` | number | The buttonCode of the key to check.

  Source:
    - input/SinglePad.js, line 456

  ##### Returns:

  True if the key is currently down.

  Type
    boolean

#### justPressed(buttonCode, duration) → {boolean}

  Returns the "just pressed" state of a button from this gamepad. Just pressed is considered true if the button was pressed down within the duration given (default 250ms).

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `buttonCode` | number |  |  | The buttonCode of the button to check for.
  `duration` | number | <optional> | 250 | The duration below which the button is considered as being just pressed.

  Source:
    - input/SinglePad.js, line 488

  ##### Returns:

  True if the button is just pressed otherwise false.

  Type
    boolean

#### justReleased(buttonCode, duration) → {boolean}

  Returns the "just released" state of a button from this gamepad. Just released is considered as being true if the button was released within the duration given (default 250ms).

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `buttonCode` | number |  |  | The buttonCode of the button to check for.
  `duration` | number | <optional> | 250 | The duration below which the button is considered as being just released.

  Source:
    - input/SinglePad.js, line 473

  ##### Returns:

  True if the button is just released otherwise false.

  Type
    boolean

#### pollStatus()

  Main update function, should be called by Phaser.Gamepad

  Source:
    - input/SinglePad.js, line 154

#### processAxisChange(axisState)

  Handles changes in axis

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `axisState` | Object | State of the relevant axis

  Source:
    - input/SinglePad.js, line 261

#### processButtonDown(buttonCode, value)

  Handles button down press

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `buttonCode` | number | Which buttonCode of this button
  `value` | Object | Button value

  Source:
    - input/SinglePad.js, line 292

#### processButtonFloat(buttonCode, value)

  Handles buttons with floating values (like analog buttons that acts almost like an axis but still registers like a button)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `buttonCode` | number | Which buttonCode of this button
  `value` | Object | Button value (will range somewhere between 0 and 1, but not specifically 0 or 1.

  Source:
    - input/SinglePad.js, line 398

#### processButtonUp(buttonCode, value)

  Handles button release

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `buttonCode` | number | Which buttonCode of this button
  `value` | Object | Button value

  Source:
    - input/SinglePad.js, line 350

#### reset()

  Reset all buttons/axes of this gamepad

  Source:
    - input/SinglePad.js, line 521