Create a new instance of a Controller.
const c = new pc.Controller(document);
// Register the "fire" action and assign it to both the Enter key and the space bar.
c.registerKeys("fire", [pc.KEY_ENTER, pc.KEY_SPACE]);
Private
_actionsPrivate
_axesPrivate
_axesPrivate
_elementPrivate
_gamepadsPrivate
_keyboardPrivate
_mouseHelper function to append an action.
The name of the action.
An action object to add.
Mouse: e.g. pc.MOUSEBUTTON_LEFT
- Gamepad: e.g. pc.PAD_FACE_1
Keyboard: A list of keycodes e.g. [pc.KEY_A, pc.KEY_ENTER]
.
Gamepad: An index of the pad to register (use PAD_1, etc).
The name of the action.
Attach Controller to an Element. This is required before you can monitor for key/mouse inputs.
The element to attach mouse and keyboard event handler too.
Register an action against a controller axis.
Optional
options: { Optional options object.
The index of the game pad to register for (use PAD_1, etc).
Create or update an action which is enabled when the gamepad button is pressed.
The name of the action.
The index of the pad to register (use PAD_1, etc).
The pad button.
A general input handler which handles both mouse and keyboard input assigned to named actions. This allows you to define input handlers separately to defining keyboard/mouse configurations.