Skip to content
lsl.devlsl.devLSL Dev

llGetGameControlModeAxes

function
Function syntax
list llGetGameControlModeAxes(
  1. key id// UUID of the avatar whose game-controller state to query.
);
Returns
list
Energy
10

Returns the semantic (mode-dependent) axis values of id for the current game_control input. Element count and index meanings vary by mode; use the GAME_CONTROL_AXIS_* constants as indices.

Returns a list of float values whose length and meaning depend on the mode returned by llGetGameControlMode. The list is empty when no game-control data is available for id.

How to use
list result = llGetGameControlModeAxes(NULL_KEY);

Where the axes parameter of the game_control event reports the raw gamepad sticks and triggers, this function reports the axes the viewer derived from them for the current mode: reordered, combined (the two triggers become one axis) and remapped according to the user’s bindings.

For GAME_CONTROL_MODE_AVATAR, GAME_CONTROL_MODE_MOUSELOOK and GAME_CONTROL_MODE_CAPTIVE the list has 5 elements, each in the range [-1.0, 1.0]:

IndexName
0GAME_CONTROL_AXIS_STRAFE
1GAME_CONTROL_AXIS_ADVANCE
2GAME_CONTROL_AXIS_TURN
3GAME_CONTROL_AXIS_LOOK
4GAME_CONTROL_AXIS_RISE

For GAME_CONTROL_MODE_FLYCAM the list has 7 elements, each in the range [-1.0, 1.0]:

IndexNameDescription
0GAME_CONTROL_AXIS_TRUCKCamera sideways movement (left/right); equivalent to GAME_CONTROL_AXIS_STRAFE
1GAME_CONTROL_AXIS_DOLLYCamera forward/back movement; equivalent to GAME_CONTROL_AXIS_ADVANCE
2GAME_CONTROL_AXIS_PANCamera yaw: rotation left/right around the vertical axis; equivalent to GAME_CONTROL_AXIS_TURN
3GAME_CONTROL_AXIS_TILTCamera pitch: rotation up/down around the horizontal axis; equivalent to GAME_CONTROL_AXIS_LOOK
4GAME_CONTROL_AXIS_BOOMCamera vertical movement (up/down); equivalent to GAME_CONTROL_AXIS_RISE
5GAME_CONTROL_AXIS_ROLLCamera roll: rotation around the forward axis (banking)
6GAME_CONTROL_AXIS_ZOOMCamera field of view (zoom in/out)

For GAME_CONTROL_MODE_CURSOR the list has 6 elements:

IndexNameRangeDescription
0CURSOR_DX[-1.0, 1.0]Cursor horizontal motion, normalized to the cursor movement rectangle
1CURSOR_DY[-1.0, 1.0]Cursor vertical motion, normalized to the cursor movement rectangle
2CURSOR_PX[0.0, width]Cursor horizontal position in pixels, measured from the left edge of the cursor movement rectangle
3CURSOR_PY[0.0, height]Cursor vertical position in pixels, measured from the top edge of the cursor movement rectangle
4CURSOR_NX[0.0, 1.0]Cursor horizontal position normalized to the cursor movement rectangle; 0.0 is the left edge, 1.0 is the right edge
5CURSOR_NY[0.0, 1.0]Cursor vertical position normalized to the cursor movement rectangle; 0.0 is the top edge, 1.0 is the bottom edge

CURSOR_PX/CURSOR_PY are measured within the rectangle the cursor is allowed to move in: <0, 0> is its upper-left corner. CURSOR_NX/CURSOR_NY are the same position normalized to that rectangle. CURSOR mode has no turn/look slot: turning and looking still work, they are simply not mirrored here because those slots carry cursor position instead.

  • Only meaningful inside a game_control event: the values are 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 an empty list when the script has no game-control snapshot for id, for example when called outside of a game_control event.
  • Game-control input is only delivered to scripts which have been granted PERMISSION_GAME_CONTROL by id.
  • The length of the list depends on the mode and may grow in the future. Do not read the list from the end, do not use negative indexes, and do not assume its length; check llGetGameControlMode and index from the front.
  • Unlike the game_control event’s axes list, CURSOR_PX and CURSOR_PY are not restricted to [-1.0, 1.0]: they are pixel values.
  • Several directional buttons are folded into these axes (for example the D-pad contributes to AXIS_ADVANCE and AXIS_STRAFE) while also appearing in llGetGameControlModeButtons; reacting to both will double-count the input. In CURSOR mode the D-pad is not folded into the axes.
  • If enabled at the client, keyboard avatar movement may also be translated into game-control input.
Example 1
default
{
game_control(key id, integer button_levels, list axes)
{
integer mode = llGetGameControlMode(id);
list mode_axes = llGetGameControlModeAxes(id);
if (mode_axes == [])
return;
19 collapsed lines
if (mode == GAME_CONTROL_MODE_AVATAR
|| mode == GAME_CONTROL_MODE_MOUSELOOK
|| mode == GAME_CONTROL_MODE_CAPTIVE)
{
float strafe = llList2Float(mode_axes, 0);
float advance = llList2Float(mode_axes, 1);
float rise = llList2Float(mode_axes, 4);
llOwnerSay("move: " + (string)llList2Vector(
[<strafe, advance, rise>], 0));
}
else if (mode == GAME_CONTROL_MODE_CURSOR)
{
llOwnerSay("cursor at <"
+ (string)llList2Float(mode_axes, 4) + ", "
+ (string)llList2Float(mode_axes, 5) + "> (normalized)");
}
}
}

The semantic axes are supplied by the viewer in the GameControlData message. Older viewers that only send the deprecated GameControlInput message provide raw axes through the game_control event but no semantic axes, so this function returns an empty list for them.

LSL Game Control Beta

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.