llGetGameControlModeButtons
integer llGetGameControlModeButtons(key id// UUID of the avatar whose game-controller state to query.
);- Returns
integer- Energy
- 10
Returns the semantic (mode-dependent) button bitfield of id for the current game_control input. Bit meanings vary by mode; use the GAME_CONTROL_BUTTON_* constants as masks.
Returns an integer of the buttons held down, interpreted according to the mode returned by llGetGameControlMode.
integer result = llGetGameControlModeButtons(NULL_KEY);Specification
Section titled “Specification”A bit is set while the corresponding action is being held down. A semantic bit index is always identical to the canonical button index it is mapped to by default, no matter how the user has actually remapped their controller. This is the difference between this function and the button_levels parameter of the game_control event: button_levels reports the raw physical buttons, while this function reports the actions the viewer derived from them.
Canonical buttons with no action in a given mode still occupy a bit, but that bit is never set for that mode.
For GAME_CONTROL_MODE_AVATAR and GAME_CONTROL_MODE_CAPTIVE:
For GAME_CONTROL_MODE_MOUSELOOK:
Caveats
Section titled “Caveats”- Only meaningful inside a
game_controlevent: the value is a snapshot taken when the event was queued, so the mode, buttons and axes read by a script are all consistent with the event being processed. - Returns
0when the script has no game-control snapshot for id, for example when called outside of agame_controlevent. A return of0therefore does not prove that no buttons are held down; checkllGetGameControlModefor-1first. - Game-control input is only delivered to scripts which have been granted
PERMISSION_GAME_CONTROLby id. - The meaning of every bit changes when the mode changes, so always pair this with
llGetGameControlMode. - In most modes several directional buttons are also folded into the axes returned by
llGetGameControlModeAxes; reacting to both will double-count the input. - Bit 31 is the sign bit of an LSL integer. Use the bit-mask constants rather than comparing against a signed value.
Examples
Section titled “Examples”Example 1
8 collapsed lines
integer prev_buttons = 0;
default{ game_control(key id, integer button_levels, list axes) { integer mode = llGetGameControlMode(id); if (mode != GAME_CONTROL_MODE_AVATAR) return;
integer buttons = llGetGameControlModeButtons(id); integer edges = buttons ^ prev_buttons; prev_buttons = buttons;11 collapsed lines
// Bit 0 is "Jump" in AVATAR mode, whichever physical button is bound to it. if (edges & GAME_CONTROL_BUTTON_A) { if (buttons & GAME_CONTROL_BUTTON_A) llOwnerSay("jump pressed"); else llOwnerSay("jump released"); } }}The semantic button mask is supplied by the viewer in the GameControlData message. Older viewers that only send the deprecated GameControlInput message provide raw buttons through the game_control event but no semantic mask, so this function returns 0 for them.
See also
Section titled “See also”Functions
Section titled “Functions”llGetGameControlMode— Current game-control modellGetGameControlModeAxes— Semantic axes for the current mode
Events
Section titled “Events”Articles
Section titled “Articles”Original wiki source
Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.