@vrspace/babylonjs
Version:
vrspace.org babylonjs client
51 lines (50 loc) • 2.27 kB
TypeScript
/**
* Gamepad helper class used by HUD and VRHelper, NOT used by 3rd person camera.
* Implementes UI control with gamepad: selecting and activating HUD buttons in and out of XR,
* and XR teleportation and interaction with scene. As gamepad is not standard XR controller,
* and mobiles don't come with XR controller, this is the only option to interact with scene in mobile VR.
* Traverse through hud menus with gamepad buttons, left/right/up/down, either left or right hand.
* Activate current option with either trigger or up.
* To teleport and rotate in (mobile) XR, use thumbstick, and to interact, use trigger.
*/
export class GamepadHelper {
/**
* @type {GamepadHelper}
*/
static instance: GamepadHelper;
static getInstance(scene: any): GamepadHelper;
constructor(scene: any);
scene: any;
gamepadState: {};
connectListeners: any[];
axisListeners: any[];
triggerListeners: any[];
hudLeft: number[];
hudRight: number[];
hudUp: number[];
hudDown: number[];
/**
* Main point of gamepad support, called from the constructor.
* Once the browser emits gamepadconnected event,
* installs tracker function into main rendering loop, to track states that
* rotate the camera, teleport, and fire gamepad button events.
*/
trackGamepad(): void;
gamepad: Gamepad;
/**
* Gamepad button event handler. Buttons left/right/up/down are forwarded to the HUD.
* Trigger button and select button events are forwarded either to HUD, or to the scene, as appropriate.
* @param index button index, see https://github.com/alvaromontoro/gamecontroller.js/blob/master/public/gamepad.svg
* @param state true/false for pressed/released
*/
gamepadButton(index: any, state: any): void;
/** Returns true if HUD can process gamepad event, i.e. a button or form is currently active.*/
forwardToHud(index: any): boolean;
notifyListeners(listeners: any, event: any): void;
addAxisListener(callback: any): void;
removeAxisListener(callback: any): void;
addConnectListener(callback: any): void;
removeConnectListener(callback: any): void;
addTriggerListener(callback: any): void;
removeTriggerListener(callback: any): void;
}