Skip to content

add support for game-control mode semantic data - #187

Open
AndrewMeadows wants to merge 3 commits into
mainfrom
leviathan/game-control-revamp
Open

AndrewMeadows wants to merge 3 commits into
mainfrom
leviathan/game-control-revamp

Conversation

@AndrewMeadows

Copy link
Copy Markdown
Contributor

This PR adds some constants and new functions for accessing game-control mode semantic data.

Going forward the viewer will send not only the canonical data (1) but also modal data (2) to the server. The canonical data will be presented to the game_control event however the modal data will be available via new function calls inside the game_control event:

integer mode = llGetGameControlMode(agent_id)
integer buttons = llGetGameControlModeButtons(agent_id)
list axes = llGetGameControlModeAxes(agent_id)

(1) Canonical data is organized according to how the buttons and axes as mapped to the device controller:

The canonical button bits are:
0    0x00001   GAME_CONTROL_BUTTON_SOUTH
1    0x00002   GAME_CONTROL_BUTTON_EAST
2    0x00004   GAME_CONTR(1)OL_BUTTON_WEST
3    0x00008   GAME_CONTROL_BUTTON_NORTH
4    0x00010   GAME_CONTROL_BUTTON_SELECT
5    0x00020   GAME_CONTROL_BUTTON_HOME
6    0x00040   GAME_CONTROL_BUTTON_START
7    0x00080   GAME_CONTROL_BUTTON_LEFTSTICK
8    0x00100   GAME_CONTROL_BUTTON_RIGHTSTICK
9    0x00200   GAME_CONTROL_BUTTON_LEFTSHOULDER
10   0x00400   GAME_CONTROL_BUTTON_RIGHTSHOULDER
11   0x00800   GAME_CONTROL_BUTTON_DPAD_UP
12   0x01000   GAME_CONTROL_BUTTON_DPAD_DOWN
13   0x02000   GAME_CONTROL_BUTTON_DPAD_LEFT
14   0x04000   GAME_CONTROL_BUTTON_DPAD_RIGHT
15   0x08000   GAME_CONTROL_BUTTON_MISC1
16   0x10000   GAME_CONTROL_BUTTON_PADDLE1
17   0x20000   GAME_CONTROL_BUTTON_PADDLE2
18   0x40000   GAME_CONTROL_BUTTON_PADDLE3
19   0x80000   GAME_CONTROL_BUTTON_PADDLE4
20   0x100000  GAME_CONTROL_BUTTON_TOUCHPAD
21   Unmapped
...
31   Unmapped

The canonical axes are:

 0   GAME_CONTROL_AXIS_LEFTX
 1   GAME_CONTROL_AXIS_LEFTY
 2   GAME_CONTROL_AXIS_RIGHTX
 3   GAME_CONTROL_AXIS_RIGHTY
 4   GAME_CONTROL_AXIS_LEFT_TRIGGER
 5   GAME_CONTROL_AXIS_RIGHT_TRIGGER

(2) Modal data is organized according to how the buttons and axes are mapped to actions and will vary by the mode being used. The modes are:

AVATAR=0
MOUSELOOK=1
FLYCAM=2
CAPTIVE=3
CURSOR=4

For the AVATAR mode the button bits are:

 0    0x0001  GAME_CONTROL_BUTTON_JUMP              Jump
 1    0x0002  GAME_CONTROL_BUTTON_CROUCH            Crouch
 2    0x0004  GAME_CONTROL_BUTTON_SIT               Toggle sit
 4    0x0010  GAME_CONTROL_BUTTON_TOGGLE_CURSOR     Toggle cursor mode
 5    0x0020  GAME_CONTROL_BUTTON_TOGGLE_SPEAK      Toggle voice speak
 6    0x0040  GAME_CONTROL_BUTTON_TOGGLE_MOUSELOOK  Toggle mouselook
 8    0x0100  GAME_CONTROL_BUTTON_TOGGLE_FLYCAM     Toggle flycam
 11   0x0800  GAME_CONTROL_BUTTON_ADVANCE_FORWARD   Move forward
 12   0x1000  GAME_CONTROL_BUTTON_ADVANCE_BACK      Move backward
 13   0x2000  GAME_CONTROL_BUTTON_STRAFE_LEFT       Strafe left
 14   0x4000  GAME_CONTROL_BUTTON_STRAFE_RIGHT      Strafe right

And the AVATAR axes are:

 0    GAME_CONTROL_AXIS_STRAFE   Strafe left/right
 1    GAME_CONTROL_AXIS_ADVANCE  Advance fwd/back
 2    GAME_CONTROL_AXIS_TURN     Turn left/right
 3    GAME_CONTROL_AXIS_LOOK     Look up/down
 4    GAME_CONTROL_AXIS_RISE     Fly up/down

Note the game controller lists the two triggers as distinct axes, but for the modes the two are always paired together as a single axis.

The CURSOR mode is interesting because the axes are not necessarily normalized to the range [-1,1]. Instead one pair of axes is the actual cursor position inside the view window, and another pair represents the normalized fractional location of the cursor within the view window.

 0    Cursor delta X  [-1.0, 1.0] (input driving the cursor horizontally)
 1    Cursor delta Y  [-1.0, 1.0] (input driving the cursor vertically)
 2    Pixel X         raw S16     (pixel coordinate from left)
 3    Pixel Y         raw S16     (pixel coordinate from top)
 4    Normalized X    [0.0, 1.0]  (fraction of window width from left)
 5    Normalized Y    [0.0, 1.0]  (fraction of window height from top)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant