BGE/Controller

Alias: BGE.Controller


Enums

BGE.Controller.ConnectionMode

enumstaticreadonly

Properties

  • http (default: "http")
  • websocket (default: "websocket")

BGE.Controller.ControllerServerEventType

enumstaticreadonly

Properties

  • onOpen (default: "onOpen")
  • onMessage (default: "onMessage")
  • onClose (default: "onClose")

Other

ActionBinding

static

One bindAction() binding - internal bookkeeping, not part of the public API. remoteButtons/controllerButtons are always normalized to arrays by bindAction() - empty means this action has no binding for that source.

Properties

  • remoteButtons (Array.<string>)
  • controllerButtons (Array.<string>)
  • playerIndex (integer)
  • label (dynamic)

AxisBinding

static

One bindAxis() binding - internal bookkeeping, not part of the public API.

Properties

  • stick (string)
  • playerIndex (integer)
  • label (dynamic)

ActionState

static

One action's live press/held/release/duration state - internal bookkeeping, not part of the public API (isActionPressed()/isActionHeld()/isActionReleased()/getActionHeldTimeMs() are how a game reads this).

Properties

  • press (boolean)
  • held (boolean)
  • release (boolean)
  • heldTimeMs (integer)

ControlMap

static

Unified mapping from remote-button and controller input to named actions/axes - the one class a game needs to learn to support both input sources. Exposed as Game.controls; see Game.enableControllerInput().

Parameters

  • registry (BGE.Controller.ControllerRegistry)

Returns

  • BGE.Controller.ControlMap

ANALOG_AXIS_LEFT_X

staticreadonly

Axis indexes for roUniversalControlEvent.GetValue(axis) - brs-engine's AnalogAxis enum (simulator-only extension, PR lvcabral/brs-engine#1226).

Default: 0

ANALOG_AXIS_LEFT_Y

staticreadonly

Default: 1

ANALOG_AXIS_RIGHT_X

staticreadonly

Default: 2

ANALOG_AXIS_RIGHT_Y

staticreadonly

Default: 3

BLUETOOTH_GAMEPAD_REMOTE_ID_PREFIX

staticreadonly

GetRemoteID() prefix for a brs-engine RemoteType.BT (Bluetooth gamepad) remote - the only remote type GetValue() returns real per-axis analog data for. GetRemoteID() returns the enum NAME, not its numeric value (see brs-engine's BrsDevice.updateKeysBuffer(), RemoteType[remoteType])

  • "BT:1", not "30:1". Any other remote (e.g. "WD:0" keyboard-sim) gets a non-directional 1.0/0.0 "is anything pressed" fallback from GetValue() instead (RoUniversalControlEvent.getFloatValue in brs-engine), which would otherwise be misread as real stick input and permanently override the d-pad fallback the instant any button is held.

Default: BT:

ANALOG_DEADZONE

staticreadonly

Below this magnitude, a real gamepad's resting-stick drift is treated as neutral rather than a real deflection - otherwise it would permanently preempt the remote d-pad fallback in ControlMap.getAxis(). Scoped to controller input only; unrelated to BGE.UI.CURSOR_ANALOG_DEADZONE.

Default: 0.15

ControllerConnectionState

static

Internal per-connection controller state (buttons/sticks/held-timers/custom payload) plus the remote's own d-pad fallback state. Not part of the public API - a game uses BGE.Controller.ControlMap (game.controls) instead.

Properties

  • buttons (object)
  • heldTimers (object) — name -> boolean
  • sticks (object) — name -> roTimespan, present only while held
  • custom (object) — name -> BGE.Math.Vector

ControllerRegistry

static

Properties

  • shareFirstControllerWithRemote (boolean) — Default true - the first browser shares playerIndex 0 with the first
  • combineRemoteInputs (boolean) — Default false - each distinct remote/gamepad gets its own stable

CONTROLLER_HTTP_BUFFER_SIZE

staticreadonly

Default: 10240

CONTROLLER_WS_READ_SIZE

staticreadonly

Default: 10240

CONTROLLER_WS_BUFFER_MAX_SIZE

staticreadonly

Cap on connection.wsBuffer's accumulated size, mirroring CONTROLLER_HTTP_BUFFER_SIZE's guard on httpBuffer - without this, a client declaring a huge 64-bit extended WebSocket frame payload length and then trickling/withholding bytes could grow wsBuffer unbounded while decodeFrames() keeps waiting for the rest of the frame to arrive.

Default: 65536

ControllerConnection

static

Properties

  • socket (roStreamSocket)
  • mode (string)
  • wsBuffer (roByteArray)
  • httpBuffer (roByteArray) — Accumulates raw bytes across possibly-multiple recv()/poll() calls
  • staleReadPolls (integer) — Consecutive poll() cycles where isReadable() reported true but
  • pendingSend (roByteArray) — Bytes still waiting to be flushed to the socket - see
  • pendingSendOffset (integer) — How far into pendingSend the previous partial send(s) already got.
  • pendingSendAction (string) — What to do once pendingSend fully flushes - "" (nothing further),

CONTROLLER_MAX_STALE_READ_POLLS

staticreadonly

Consecutive negative-receive polls before a connection is assumed dead and closed - see ControllerConnection.staleReadPolls. At ~60 polls/sec this is a multi-second grace period. The browser client now resends its state once a second (see controller-web/index.html), so this threshold only needs to comfortably clear that 1s heartbeat cadence (it does, by ~5x) - it no longer needs to double as "long enough for the flakiest possible isReadable() behavior on idle, untouched input," since that case no longer exists once the client is always sending.

Default: 300

ControllerServerEvent

static

Properties

  • type (string)
  • connectionId (string) — BGE.Controller.ControllerServerEventType
  • message (string)

HttpRequest

static

A parseHttpRequest() result - the request line plus headers, both used verbatim by onHttpReadable()'s routing. headers stays a plain dictionary (its keys are whatever header names the client happened to send, not a fixed set).

Properties

  • command (string)
  • path (string)
  • protocol (string)
  • headers (object)

ControllerServer

static

Minimal HTTP + WebSocket (RFC 6455) server for streaming controller input from a browser page, without SceneGraph. Adapted and trimmed from https://github.com/markwpearce/roku-gamepad - serves GET only (static files under pkg:/source/controller-web), no upload/directory listing.

Parameters

  • port (integer)

Properties

  • port (integer)

Returns

  • BGE.Controller.ControllerServer