LlGetGameControlModeButtons
Looking for the current API? Open the llGetGameControlModeButtons reference →
Wiki description
Returns the semantic (mode-dependent) button bitfield of
id for the current game_control input.Return value notes
Returns an integer of the buttons held down, interpreted according to the mode returned by llGetGameControlMode.
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:
| Bit | Name |
|---|---|
| 0 | GAME_CONTROL_BUTTON_JUMP |
| 1 | GAME_CONTROL_BUTTON_CROUCH |
| 2 | GAME_CONTROL_BUTTON_SIT |
| 3 | (unbound) |
| 4 | GAME_CONTROL_BUTTON_TOGGLE_CURSOR |
| 5 | GAME_CONTROL_BUTTON_TOGGLE_SPEAK |
| 6 | GAME_CONTROL_BUTTON_TOGGLE_MOUSELOOK |
| 7 | (unbound) |
| 8 | GAME_CONTROL_BUTTON_TOGGLE_FLYCAM |
| 9 | (unbound) |
| 10 | (unbound) |
| 11 | GAME_CONTROL_BUTTON_ADVANCE_FORWARD |
| 12 | GAME_CONTROL_BUTTON_ADVANCE_BACK |
| 13 | GAME_CONTROL_BUTTON_STRAFE_LEFT |
| 14 | GAME_CONTROL_BUTTON_STRAFE_RIGHT |
| 15–31 | (unbound) |
For GAME_CONTROL_MODE_MOUSELOOK:
| Bit | Name |
|---|---|
| 0 | GAME_CONTROL_BUTTON_JUMP |
| 1 | GAME_CONTROL_BUTTON_CROUCH |
| 2 | GAME_CONTROL_BUTTON_SIT |
| 3 | (unbound) |
| 4 | GAME_CONTROL_BUTTON_TOGGLE_CURSOR |
| 5 | GAME_CONTROL_BUTTON_TOGGLE_SPEAK |
| 6 | GAME_CONTROL_BUTTON_TOGGLE_MOUSELOOK |
| 7 | (unbound) |
| 8 | GAME_CONTROL_BUTTON_TOGGLE_FLYCAM |
| 9 | GAME_CONTROL_BUTTON_CURSOR_BUTTON_LEFT |
| 10 | GAME_CONTROL_BUTTON_CURSOR_BUTTON_RIGHT |
| 11 | GAME_CONTROL_BUTTON_ADVANCE_FORWARD |
| 12 | GAME_CONTROL_BUTTON_ADVANCE_BACK |
| 13 | GAME_CONTROL_BUTTON_STRAFE_LEFT |
| 14 | GAME_CONTROL_BUTTON_STRAFE_RIGHT |
| 15–31 | (unbound) |
For GAME_CONTROL_MODE_CURSOR:
| Bit | Name |
|---|---|
| 0 | GAME_CONTROL_BUTTON_JUMP |
| 1 | GAME_CONTROL_BUTTON_CROUCH |
| 2 | GAME_CONTROL_BUTTON_SIT |
| 3 | (unbound) |
| 4 | GAME_CONTROL_BUTTON_TOGGLE_CURSOR |
| 5 | GAME_CONTROL_BUTTON_TOGGLE_SPEAK |
| 6 | GAME_CONTROL_BUTTON_TOGGLE_MOUSELOOK |
| 7 | (unbound) |
| 8 | GAME_CONTROL_BUTTON_TOGGLE_FLYCAM |
| 9 | GAME_CONTROL_BUTTON_CURSOR_BUTTON_LEFT |
| 10 | GAME_CONTROL_BUTTON_CURSOR_BUTTON_RIGHT |
| 11 | GAME_CONTROL_BUTTON_ADVANCE_FORWARD |
| 12 | GAME_CONTROL_BUTTON_ADVANCE_BACK |
| 13 | GAME_CONTROL_BUTTON_STRAFE_LEFT |
| 14 | GAME_CONTROL_BUTTON_STRAFE_RIGHT |
| 15–31 | (unbound) |
For GAME_CONTROL_MODE_FLYCAM:
| Bit | Name |
|---|---|
| 0 | GAME_CONTROL_BUTTON_ZOOM_OUT |
| 1 | GAME_CONTROL_BUTTON_PAN_RIGHT |
| 2 | GAME_CONTROL_BUTTON_PAN_LEFT |
| 3 | GAME_CONTROL_BUTTON_ZOOM_IN |
| 4 | GAME_CONTROL_BUTTON_TOGGLE_ALT_ZOOM |
| 5 | (unbound) |
| 6 | GAME_CONTROL_BUTTON_TOGGLE_FOLLOW |
| 7 | GAME_CONTROL_BUTTON_RESET |
| 8 | GAME_CONTROL_BUTTON_TOGGLE_FLYCAM |
| 9 | GAME_CONTROL_BUTTON_ROLL_CCW |
| 10 | GAME_CONTROL_BUTTON_ROLL_CW |
| 11 | GAME_CONTROL_BUTTON_DOLLY_FORWARD |
| 12 | GAME_CONTROL_BUTTON_DOLLY_BACK |
| 13 | GAME_CONTROL_BUTTON_TRUCK_LEFT |
| 14 | GAME_CONTROL_BUTTON_TRUCK_RIGHT |
| 15–31 | (unbound) |
Caveats
- Only meaningful inside a game_control event: 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 0 when the script has no game-control snapshot for
id, for example when called outside of a game_control event. A return of 0 therefore does not prove that no buttons are held down; check llGetGameControlMode for -1 first. - Game-control input is only delivered to scripts which have been granted PERMISSION_GAME_CONTROL by
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
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;
// 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");
}
}
}Notes
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: functions
See also: events
See also: 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.