Skip to content

PointerProviderOptions

Defined in: src/modules/input/pointer-provider.ts:86

Options for PointerProvider.

optional buttons?: readonly PointerButton[]

Defined in: src/modules/input/pointer-provider.ts:92

Buttons to emit as digital events. Defaults to [0, 1, 2] (left, middle, right). Pass an empty array to disable button reporting while still tracking position.


optional initialPosition?: object

Defined in: src/modules/input/pointer-provider.ts:99

Seed position used before the first pointermove. Handy for games that want the aim vector to start at the screen centre rather than (0, 0). Ignored if omitted — state.x / state.y default to 0.

x: number

y: number


optional preventContextMenu?: boolean

Defined in: src/modules/input/pointer-provider.ts:107

Whether to call preventDefault() on the native context-menu event. Defaults to true when button 2 is reported (so right-click can be used as a game action without the browser popping up a menu). Set to false if the consumer wants the native menu, or handles it elsewhere.


optional project?: PointerProjector

Defined in: src/modules/input/pointer-provider.ts:119

Coordinate projector. Default behaviour:

  • If target looks like an HTMLCanvasElement (has numeric width/height properties), scale clientX/Y - rect.left/top by canvas.width / rect.width (and analogously for Y) so the reported position is in canvas-internal pixel coordinates even when the canvas is CSS-scaled.
  • Otherwise, return clientX - rect.left / clientY - rect.top (target-local pixels).

target: PointerTarget

Defined in: src/modules/input/pointer-provider.ts:126

Element (or structural equivalent) to attach pointer listeners to. In real apps this is the canvas / game container. The provider needs getBoundingClientRect for coordinate projection.


optional windowTarget?: EventTarget | null

Defined in: src/modules/input/pointer-provider.ts:133

EventTarget that receives the pointerup listener so button releases outside the target still register. Defaults to window when available. Pass an explicit target for headless environments (tests).