Read and map input
Every normal controller state contains four normalized axes and sixteen normalized buttons. Button names describe position or function, so changing a printed glyph does not change the wire identity.
| Index | Button | Index | Button |
|---|---|---|---|
| 0 | face.south | 8 | menu.select |
| 1 | face.east | 9 | menu.start |
| 2 | face.west | 10 | stick.left.press |
| 3 | face.north | 11 | stick.right.press |
| 4 | shoulder.left | 12 | dpad.up |
| 5 | shoulder.right | 13 | dpad.down |
| 6 | trigger.left | 14 | dpad.left |
| 7 | trigger.right | 15 | dpad.right |
Axes are stick.left.x, stick.left.y, stick.right.x, stick.right.y, in that order. Their range is −1 to 1; positive Y points down in the wire format. Buttons range from 0 to 1 so analog triggers retain pressure. Engine adapters convert axis direction when their engine uses a different convention.
Use actions in game code
import {ControllerManager} from '@controller-plus/sdk';
const input = new ControllerManager();
input.connect('phone-1', {source: 'phone', player: 'player-1'});
input.update('phone-1', {axes: [0, 0, 0, 0], buttons: Array(16).fill(0)});
const actions = input.actions('player-1');
// actions.move, actions.aim, actions.primary, actions.secondary, actions.pause
assign(deviceId, playerId) controls player ownership. Several devices can feed one player, or each can be assigned separately. pollGamepads() reads browser physical controllers; bindSession(engineSession) consumes a developer host's phone frames.
configure applies a validated axis/button map and deadzone to a device. validateBindings checks action definitions before they are used. evaluateActions converts a normalized state to your named actions. Default diagonal movement is normalized, rather than becoming faster than movement along one axis.
Release and reconnect
Call disconnect when a device leaves and neutralize when the game loses an input context. The manager also returns neutral input when a sample becomes stale. It does not replay a held button from an old socket after reconnecting.
The native C core provides the same state and profile concepts without choosing a network stack. Godot provides named-action methods; Unity and Unreal feed their regular engine input systems.