Skip to content

@ue-too/board / index / ObservableInputTracker

Class: ObservableInputTracker ​

Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:717

Production implementation of KmtInputContext that tracks input state for the state machine.

Remarks ​

This class provides the concrete implementation of the KMT input context, maintaining all state required by the state machine to recognize and track gestures:

State Tracking:

  • Initial cursor position for calculating pan deltas
  • Input modality score to distinguish mouse vs trackpad
  • Determined input mode (kmt/trackpad/TBD)
  • Coordinate system alignment preference

Input Modality Detection: The kmtTrackpadTrackScore accumulates evidence about the input device:

  • Positive values indicate mouse behavior (middle-click, no horizontal scroll)
  • Negative values indicate trackpad behavior (horizontal scroll, two-finger gestures)
  • Score is used to determine zoom behavior (Ctrl+Scroll for mouse vs Scroll for trackpad)

Design Pattern: This class follows the Context pattern from the @ue-too/being state machine library, providing stateful data and operations that states can access and modify during transitions.

Example ​

typescript
const canvasProxy = new CanvasProxy(canvasElement);
const context = new ObservableInputTracker(canvasProxy);
const stateMachine = createKmtInputStateMachine(context);

// Context tracks state as the state machine processes events
stateMachine.happens("leftPointerDown", {x: 100, y: 200});
console.log(context.initialCursorPosition); // {x: 100, y: 200}

Implements ​

Constructors ​

Constructor ​

new ObservableInputTracker(canvasOperator): ObservableInputTracker

Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:725

Parameters ​

canvasOperator ​

Canvas

Returns ​

ObservableInputTracker

Accessors ​

alignCoordinateSystem ​

Get Signature ​

get alignCoordinateSystem(): boolean

Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:774

Whether to use standard screen coordinate system (vs inverted Y-axis)

Returns ​

boolean

Set Signature ​

set alignCoordinateSystem(value): void

Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:786

Whether to use standard screen coordinate system (vs inverted Y-axis)

Parameters ​
value ​

boolean

Returns ​

void

Whether to use standard screen coordinate system (vs inverted Y-axis)

Implementation of ​

KmtInputContext.alignCoordinateSystem


canvas ​

Get Signature ​

get canvas(): Canvas

Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:778

Canvas accessor for dimensions and cursor control

Returns ​

Canvas

Canvas accessor for dimensions and cursor control

Implementation of ​

KmtInputContext.canvas


initialCursorPosition ​

Get Signature ​

get initialCursorPosition(): Point

Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:782

The cursor position when a pan gesture started

Returns ​

Point

The cursor position when a pan gesture started

Implementation of ​

KmtInputContext.initialCursorPosition


kmtTrackpadTrackScore ​

Get Signature ​

get kmtTrackpadTrackScore(): number

Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:748

Score tracking input modality: >0 for mouse, <0 for trackpad, 0 for undetermined

Returns ​

number

Score tracking input modality: >0 for mouse, <0 for trackpad, 0 for undetermined

Implementation of ​

KmtInputContext.kmtTrackpadTrackScore


mode ​

Get Signature ​

get mode(): "kmt" | "trackpad" | "TBD"

Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:733

The current input modality: 'kmt' (mouse), 'trackpad', or 'TBD' (to be determined)

Returns ​

"kmt" | "trackpad" | "TBD"

The current input modality: 'kmt' (mouse), 'trackpad', or 'TBD' (to be determined)

Implementation of ​

KmtInputContext.mode

Methods ​

addKmtTrackpadTrackScore() ​

addKmtTrackpadTrackScore(): void

Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:763

Increases the score toward mouse

Returns ​

void

Implementation of ​

KmtInputContext.addKmtTrackpadTrackScore


cancelCurrentAction() ​

cancelCurrentAction(): void

Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:790

Cancels the current action and resets cursor position

Returns ​

void

Implementation of ​

KmtInputContext.cancelCurrentAction


cleanup() ​

cleanup(): void

Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:798

Returns ​

void

Implementation of ​

KmtInputContext.cleanup


enableInputModeDetection() ​

enableInputModeDetection(): void

Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:742

Returns ​

void


setInitialCursorPosition() ​

setInitialCursorPosition(position): void

Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:794

Sets the initial cursor position when starting a pan gesture

Parameters ​

position ​

Point

Returns ​

void

Implementation of ​

KmtInputContext.setInitialCursorPosition


setMode() ​

setMode(mode): void

Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:737

Sets the determined input modality

Parameters ​

mode ​

"kmt" | "trackpad" | "TBD"

Returns ​

void

Implementation of ​

KmtInputContext.setMode


setup() ​

setup(): void

Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:800

Returns ​

void

Implementation of ​

KmtInputContext.setup


subtractKmtTrackpadTrackScore() ​

subtractKmtTrackpadTrackScore(): void

Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:752

Decreases the score toward trackpad

Returns ​

void

Implementation of ​

KmtInputContext.subtractKmtTrackpadTrackScore