GameControllerSession
ClassRepresents an active game controller session.
- Snapchat: not supported
- SPECS: fully supported
- Camera Kit Web: not supported
- Camera Kit Mobile: not supported
- 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
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
Properties
Methods
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
readonlyonAnalogStickEvent:event1<AnalogStickInputEvent,void>
ExperimentalSPECS
Event fired when a stick's axis values change.
Since
Lens Scripting Version 373
onAnalogTriggerEvent
readonlyonAnalogTriggerEvent:event1<AnalogTriggerInputEvent,void>
ExperimentalSPECS
Event fired when a trigger's analog axis value changes.
Since
Lens Scripting Version 373
onButtonEvent
readonlyonButtonEvent:event1<ButtonInputEvent,void>
ExperimentalSPECS
Event fired when a button is pressed or released on any connected controller.
Since
Lens Scripting Version 373
onControllerConnected
readonlyonControllerConnected:event1<ControllerConnectedEvent,void>
ExperimentalSPECS
Event fired when a new game controller is connected. Use .add() to subscribe.
Since
Lens Scripting Version 373
onControllerDisconnected
readonlyonControllerDisconnected:event1<ControllerDisconnectedEvent,void>
ExperimentalSPECS
Event fired when a game controller is disconnected. Use .add() to subscribe.
Since
Lens Scripting Version 373
onMotionEvent
readonlyonMotionEvent:event1<MotionInputEvent,void>
ExperimentalSPECS
Event fired when motion sensor data is received. Only on motion-capable controllers.
Since
Lens Scripting Version 373
onTouchpadEvent
readonlyonTouchpadEvent: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
Since
Lens Scripting Version 373
getTypeName()
staticgetTypeName():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
getTypeName()
getTypeName():
string
Experimental
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Experimental
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
options | RumbleOptions |
Returns
void
Since
Lens Scripting Version 373