_Contros

_Contros

new _Contros()

Look at the Input reference pages before reading these docs. Used internally to create the `contros` array (aka `controllers`) of `Contro` objects, which store the input status of buttons, triggers, and sticks on game controllers.
Source:

Extends

Classes

_Contros

Methods

onConnect(gamepad) → {Boolean}

Runs when a controller is connected. By default it always returns true. Overwrite this function to customize the behavior. For example, it could be customized to filter controllers based on their model info. Doesn't run if a controller in the `controllers` array is reconnected.
Source:
Parameters:
Name Type Description
gamepad Gamepad
Returns:
Type:
Boolean
true if the controller should be added to this p5play controllers array

onDisconnect(gamepad) → {Boolean}

Runs when a controller is disconnected. by default it always returns false. Overwrite this function to customize the behavior. Removing a controller from the `controllers` array usually is not desirable, because the controller could be reconnected later. By default, the controller is kept in the array and its state is reset.
Source:
Parameters:
Name Type Description
gamepad Gamepad
Returns:
Type:
Boolean
true if the controllers should be removed from this p5play controllers array

remove(index)

Removes a controller from this controllers array by setting `contros[index] = null`. Newly connected controllers fill the first empty slot.
Source:
Parameters:
Name Type Description
index Number

swap(indexA, indexB)

Swap controller positions in this controllers array.
Source:
Parameters:
Name Type Description
indexA Number
indexB Number
Example
contros.swap(0, 3); // swap the first controller with the fourth