Skip to content
lsl.devlsl.devLSL Dev

Input

Users interact with objects by clicking them, and with scripted vehicles, weapons and HUDs through captured controls. A script can capture movement keys and the mouse button, and read gamepad buttons and axes.

Input is not free text: for choices and typed input, use dialogs, text boxes or chat commands.

Touch needs no permission. Controls need PERMISSION_TAKE_CONTROLS; gamepads need PERMISSION_GAME_CONTROL and viewer support.

Concepts

Functions and events

eventtouch_start(integer num_detected)
eventtouch(integer num_detected)
eventtouch_end(integer num_detected)
integerllDetectedTouchFace(integer index)
voidllSetClickAction(integer action)
voidllTakeControls(integer controls, integer accept, integer pass_on)
voidllReleaseControls()
eventcontrol(key id, integer level, integer edge)
eventgame_control(key id, integer button_levels, list axes)

Touch

Touch events, where a prim was touched, click actions and touch text.

Gamepad

Game controller buttons and axes and the avatar’s game-control mode, with modal axes and buttons per mode.

Scripting Details

voidllRequestPermissions(key agent, integer permissions)
Requests permissions (a bitfield specified by permissions) from the agent in the same region, calling run_time_permissions if granted. This call does not pause script execution.
eventrun_time_permissions(integer perm)
Triggered when an agent grants or denies runtime permissions requested by llRequestPermissions. Passes the active integer permissions bitfield perm (returns 0 if no permissions are currently granted).
voidllTakeControls(integer controls, integer accept, integer pass_on)
Intercepts inputs (keyboard/mouse clicks) from the agent, specifically those specified by controls. The boolean accept determines if events are generated, and pass_on determines if inputs also perform their default functions. Requires the PERMISSION_TAKE_CONTROLS runtime permission.
voidllReleaseControls()
Stops taking inputs (previously acquired via llTakeControls) from the avatar, dequeuing any remaining control events and revoking the PERMISSION_TAKE_CONTROLS permission.
eventcontrol(key id, integer level, integer edge)
Triggered to pass captured avatar control inputs into the script. The parameter level indicates held controls, and edge indicates change in controls (both are bitfields of CONTROL_* constants).
voidllForceMouselook(integer mouselook)
Sets whether any avatar sitting on this prim is forced into mouselook mode. Setting mouselook to TRUE forces the mode; FALSE (default) allows the avatar to keep their current camera mode.
integerllGetAgentInfo(key id)
Returns an integer bitfield containing status information about the agent specified by id (such as AGENT_FLYING, AGENT_ATTACHMENTS, AGENT_SITTING, etc.).

Additional

Constant groups ControlButton 10

See also Category InputSL Wiki LSL ControlsPlanned Guide: capturing controls for a vehicle or weapon

See also Feature DialogFeature CommunicationsFeature Camera