Preparing search index...

    Class GameControllerModuleExperimental

    Provides access to game controller input on Spectacles. Import this module to enable game controller support in your Lens.

    Use createController() to open a session and subscribe to input events from connected Bluetooth game controllers. The session provides controller discovery, input events, and haptic feedback (rumble). Subscribe to events via the session's event properties (e.g. onButtonEvent.add(...)). Multiple controller sessions may be active simultaneously.

    Lens Scripting Version 373

    //@input Asset.GameControllerModule gameControllerModule
    var provider = script.gameControllerModule.createController();
    provider.onControllerConnected.add(function(event) {
    print("Connected: " + event.controller.name + " (type: " + event.controller.type + ")");
    });
    provider.onButtonEvent.add(function(event) {
    if (event.button === GameControllerModule.Button.South
    && event.eventType === GameControllerModule.ButtonEventType.Pressed) {
    var options = new GameControllerModule.RumbleOptions();
    options.controllerId = event.controllerId;
    options.lowFrequencyIntensity = 0.5;
    options.highFrequencyIntensity = 0.3;
    options.durationSec = 0.2;
    provider.rumble(options);
    }
    });

    Hierarchy (View Summary)

    • Asset
      • GameControllerModule
    Index

    Properties

    name: string

    The name of the Asset in Lens Studio.

    ""
    
    uniqueIdentifier: string

    Lens Scripting Version 176

    Methods

    • Experimental

      Creates a new game controller session and subscribes to the platform service. Returns a GameControllerSession whose event properties can be used to subscribe to controller lifecycle and input events.

      Returns GameControllerSession

      Lens Scripting Version 373

    • Experimental

      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 string

      Lens Scripting Version 373

    • Experimental

      Returns the name of this object's type.

      Returns string

    • Experimental

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

      Parameters

      • type: string

      Returns boolean

    • Experimental

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

      Parameters

      Returns boolean