Skip to content
lsl.devlsl.devLSL Dev

Gamepad

A compatible viewer can send game controller input for an avatar to scripts. Part of the Input feature; lsl.dev lists these APIs together in the Gamepad category.

Gamepad functions and events

eventgame_control(key id, integer button_levels, list axes)
Triggered when a compatible viewer sends game controller input changes for the avatar specified by id. Only triggers for scripts in attachments or seats.
integerllGetGameControlMode(key id)
Returns a GAME_CONTROL_MODE_* integer indicating the current game-control mode for the avatar specified by id.
listllGetGameControlModeAxes(key id)
Returns a list of floats representing the modal axes for the current game-control mode of the avatar specified by id. Element count and index meanings vary by mode; use the GAME_CONTROL_AXIS_* constants as indices.
integerllGetGameControlModeButtons(key id)
Returns a bitmask of the modal buttons currently active for the current game-control mode of the avatar specified by id. Bit meanings vary by mode; use the GAME_CONTROL_BUTTON_* constants as masks.

llGetGameControlMode returns one of these GAME_CONTROL_MODE_* values for the avatar given by id.

Constant groups GameControlMode 5

The six entries of the axes list in game_control.

ConstantIndexDescription
GAME_CONTROL_AXIS_LEFTX0Left stick X axis. Canonical axis index 0.
GAME_CONTROL_AXIS_LEFTY1Left stick Y axis. Canonical axis index 1.
GAME_CONTROL_AXIS_RIGHTX2Right stick X axis. Canonical axis index 2.
GAME_CONTROL_AXIS_RIGHTY3Right stick Y axis. Canonical axis index 3.
GAME_CONTROL_AXIS_LEFT_TRIGGER4Left trigger. Canonical axis index 4.
GAME_CONTROL_AXIS_RIGHT_TRIGGER5Right trigger. Canonical axis index 5.

Indices into the list returned by llGetGameControlModeAxes; which ones apply depends on the mode.

ConstantIndexDescription
GAME_CONTROL_AXIS_STRAFE0Left/right movement. Modal axis index 0 for AVATAR, MOUSELOOK, and CAPTIVE modes.
GAME_CONTROL_AXIS_ADVANCE1Forward/backward movement. Modal axis index 1 for AVATAR, MOUSELOOK, and CAPTIVE modes.
GAME_CONTROL_AXIS_TURN2Turning left/right. Modal axis index 2 for AVATAR, MOUSELOOK, CAPTIVE, and CURSOR modes.
GAME_CONTROL_AXIS_LOOK3Looking up/down. Modal axis index 3 for AVATAR, MOUSELOOK, CAPTIVE, and CURSOR modes.
GAME_CONTROL_AXIS_RISE4Up/down movement. Modal axis index 4 for AVATAR, MOUSELOOK, and CAPTIVE modes.
GAME_CONTROL_AXIS_ZOOM6Camera zoom in/out. Modal axis index 6 for AVATAR, MOUSELOOK, CAPTIVE, and FLYCAM modes.
GAME_CONTROL_AXIS_TRUCK0Camera lateral (left/right) movement. Modal axis index 0 for FLYCAM mode.
GAME_CONTROL_AXIS_DOLLY1Camera forward/backward movement. Modal axis index 1 for FLYCAM mode.
GAME_CONTROL_AXIS_PAN2Camera pan left/right. Modal axis index 2 for FLYCAM mode.
GAME_CONTROL_AXIS_TILT3Camera tilt up/down. Modal axis index 3 for FLYCAM mode.
GAME_CONTROL_AXIS_BOOM4Camera up/down movement. Modal axis index 4 for FLYCAM mode.
GAME_CONTROL_AXIS_ROLL5Camera roll. Modal axis index 5 for FLYCAM mode.

Bits of button_levels in game_control.

Constant groups GameControlButton 21

Masks for the bitmask returned by llGetGameControlModeButtons. Bit meanings vary by mode, so the same value is reused across modes.

ConstantMaskDescription
GAME_CONTROL_BUTTON_JUMP0x1Jump. Modal button for AVATAR, MOUSELOOK, CAPTIVE, and CURSOR modes.
GAME_CONTROL_BUTTON_CROUCH0x2Crouch. Modal button for AVATAR, MOUSELOOK, CAPTIVE, and CURSOR modes.
GAME_CONTROL_BUTTON_SIT0x4Toggle sitting. Modal button for AVATAR, MOUSELOOK, CAPTIVE, and CURSOR modes.
GAME_CONTROL_BUTTON_TOGGLE_CURSOR0x10Toggle cursor mode. Modal button for AVATAR, MOUSELOOK, CAPTIVE, and CURSOR modes.
GAME_CONTROL_BUTTON_TOGGLE_SPEAK0x20Toggle voice speak. Modal button for AVATAR, MOUSELOOK, CAPTIVE, and CURSOR modes.
GAME_CONTROL_BUTTON_TOGGLE_MOUSELOOK0x40Toggle mouselook mode. Modal button for AVATAR, MOUSELOOK, CAPTIVE, and CURSOR modes.
GAME_CONTROL_BUTTON_TOGGLE_FLYCAM0x100Toggle flycam mode. Modal button for all modes.
GAME_CONTROL_BUTTON_CURSOR_BUTTON_LEFT0x200Left mouse button click. Modal button for MOUSELOOK and CURSOR modes.
GAME_CONTROL_BUTTON_CURSOR_BUTTON_RIGHT0x400Right mouse button click. Modal button for MOUSELOOK and CURSOR modes.
GAME_CONTROL_BUTTON_ADVANCE_FORWARD0x800Move forward. Modal button for AVATAR, MOUSELOOK, CAPTIVE, and CURSOR modes.
GAME_CONTROL_BUTTON_ADVANCE_BACK0x1000Move backward. Modal button for AVATAR, MOUSELOOK, CAPTIVE, and CURSOR modes.
GAME_CONTROL_BUTTON_STRAFE_LEFT0x2000Strafe left. Modal button for AVATAR, MOUSELOOK, CAPTIVE, and CURSOR modes.
GAME_CONTROL_BUTTON_STRAFE_RIGHT0x4000Strafe right. Modal button for AVATAR, MOUSELOOK, CAPTIVE, and CURSOR modes.
GAME_CONTROL_BUTTON_ZOOM_OUT0x1Zoom camera out. Modal button for FLYCAM mode.
GAME_CONTROL_BUTTON_PAN_RIGHT0x2Camera pan right. Modal button for FLYCAM mode.
GAME_CONTROL_BUTTON_PAN_LEFT0x4Camera pan left. Modal button for FLYCAM mode.
GAME_CONTROL_BUTTON_ZOOM_IN0x8Zoom camera in. Modal button for FLYCAM mode.
GAME_CONTROL_BUTTON_TOGGLE_ALT_ZOOM0x10Toggle alt-zoom. Modal button for FLYCAM mode.
GAME_CONTROL_BUTTON_TOGGLE_FOLLOW0x40Toggle camera follow mode. Modal button for FLYCAM mode.
GAME_CONTROL_BUTTON_RESET0x80Reset camera to default view. Modal button for FLYCAM mode.
GAME_CONTROL_BUTTON_ROLL_CCW0x200Roll camera counter-clockwise. Modal button for FLYCAM mode.
GAME_CONTROL_BUTTON_ROLL_CW0x400Roll camera clockwise. Modal button for FLYCAM mode.
GAME_CONTROL_BUTTON_DOLLY_FORWARD0x800Camera dolly forward. Modal button for FLYCAM mode.
GAME_CONTROL_BUTTON_DOLLY_BACK0x1000Camera dolly backward. Modal button for FLYCAM mode.
GAME_CONTROL_BUTTON_TRUCK_LEFT0x2000Camera truck left. Modal button for FLYCAM mode.
GAME_CONTROL_BUTTON_TRUCK_RIGHT0x4000Camera truck right. Modal button for FLYCAM mode.

See also Category GamepadSL Wiki Game controlSL Wiki LSL GameControls