Skip to main content

GameControllerSession

Class

Represents an active game controller session.

  • Snapchat: not supported
  • SPECS: fully supported
  • Camera Kit Web: not supported
  • Camera Kit Mobile: not supported
1 platform note
  • SnapchatNot supported — Available on SPECS only
  • SPECSFully supported
    • Experimental API; it may change or be removed.
  • Camera Kit WebNot supported — Available on SPECS only
  • Camera Kit MobileNot supported — Available on SPECS only

Platform details

  • Snapchat — Not supported — Available on SPECS only.

  • SPECS — Fully supported. Experimental API; it may change or be removed

  • Camera Kit Web — Not supported — Available on SPECS only.

  • Camera Kit Mobile — Not supported — Available on SPECS only.

Since Lens Scripting v373Experimental

Represents an active game controller session. Exposes event properties to subscribe to controller input and lifecycle changes, plus methods to query connected controllers and trigger haptic feedback. Obtained by calling GameControllerModule.createController. Subscribe to events via the on* properties (e.g. onButtonEvent.add(handler)).

Index

Example

//@input Asset.GameControllerModule gameControllerModule
var session = script.gameControllerModule.createController();
session.onButtonEvent.add(function(event) {
print("Button " + event.button);
});
session.getConnectedControllers().forEach(function(controller) {
print("Connected: " + controller.name);
});

Extends

Properties

onAnalogStickEvent

readonly onAnalogStickEvent: event1<AnalogStickInputEvent, void>

ExperimentalSPECS

Event fired when a stick's axis values change.

Since

Lens Scripting Version 373


onAnalogTriggerEvent

readonly onAnalogTriggerEvent: event1<AnalogTriggerInputEvent, void>

ExperimentalSPECS

Event fired when a trigger's analog axis value changes.

Since

Lens Scripting Version 373


onButtonEvent

readonly onButtonEvent: event1<ButtonInputEvent, void>

ExperimentalSPECS

Event fired when a button is pressed or released on any connected controller.

Since

Lens Scripting Version 373


onControllerConnected

readonly onControllerConnected: event1<ControllerConnectedEvent, void>

ExperimentalSPECS

Event fired when a new game controller is connected. Use .add() to subscribe.

Since

Lens Scripting Version 373


onControllerDisconnected

readonly onControllerDisconnected: event1<ControllerDisconnectedEvent, void>

ExperimentalSPECS

Event fired when a game controller is disconnected. Use .add() to subscribe.

Since

Lens Scripting Version 373


onMotionEvent

readonly onMotionEvent: event1<MotionInputEvent, void>

ExperimentalSPECS

Event fired when motion sensor data is received. Only on motion-capable controllers.

Since

Lens Scripting Version 373


onTouchpadEvent

readonly onTouchpadEvent: event1<TouchpadInputEvent, void>

ExperimentalSPECS

Event fired when touchpad input is received. Only on controllers with a touchpad.

Since

Lens Scripting Version 373

Methods

getConnectedControllers()

getConnectedControllers(): ControllerInfo[]

ExperimentalSPECS

Returns an array of ControllerInfo objects describing each currently connected game controller.

Returns

ControllerInfo[]

Since

Lens Scripting Version 373


getTypeName()

static getTypeName(): TypeName<GameControllerSession>

ExperimentalSPECS

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<GameControllerSession>

Since

Lens Scripting Version 373

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Experimental

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Experimental

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isSame()

isSame(other): boolean

Experimental

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame


rumble()

rumble(options): void

ExperimentalSPECS

Triggers haptic feedback (rumble) on the specified controller. Intensity values range from 0.0 (off) to 1.0 (max); duration is in seconds.

Parameters

ParameterType
optionsRumbleOptions

Returns

void

Since

Lens Scripting Version 373