API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classGamepadAxis

@codexo/exojs / input / stable

Single mappable analog axis on a physical gamepad. Holds the raw browser `Gamepad.axes[]` index, the canonical channel the value is written to, and the transform pipeline applied each frame by transformValue. Direction-split axis channels (e.g. `LeftStickLeft`, `LeftStickRight`) live in the 0..1 range - set `invert: true` on the negative half so it reads positive when pushed in its direction. Aggregate channels (e.g. `LeftStickX`, `LeftStickY`) live in the full -1..1 range - set `bipolar: true` to preserve sign through the pipeline. The static namespace exports (`GamepadAxis.LeftStickLeft`, `.LeftStickX`, ...) carry the canonical channel offsets used to address each axis. `channel` can also target a GamepadButtonChannel - some devices report an inherently analog, button-shaped control (a trigger) through the raw `axes[]` array rather than `buttons[]`; routing such an axis at the canonical trigger channel keeps app code that binds `GamepadButton.LeftTrigger`/`RightTrigger` portable across devices regardless of which raw array the hardware happens to report through.

7
props
1
methods
0
events
Import
import { GamepadAxis } from '@codexo/exojs'

Single mappable analog axis on a physical gamepad. Holds the raw browser `Gamepad.axes[]` index, the canonical channel the value is written to, and the transform pipeline applied each frame by transformValue.

Direction-split axis channels (e.g. `LeftStickLeft`, `LeftStickRight`) live in the 0..1 range - set `invert: true` on the negative half so it reads positive when pushed in its direction.

Aggregate channels (e.g. `LeftStickX`, `LeftStickY`) live in the full -1..1 range - set `bipolar: true` to preserve sign through the pipeline.

The static namespace exports (`GamepadAxis.LeftStickLeft`, `.LeftStickX`, ...) carry the canonical channel offsets used to address each axis. `channel` can also target a GamepadButtonChannel - some devices report an inherently analog, button-shaped control (a trigger) through the raw `axes[]` array rather than `buttons[]`; routing such an axis at the canonical trigger channel keeps app code that binds `GamepadButton.LeftTrigger`/`RightTrigger` portable across devices regardless of which raw array the hardware happens to report through.

Constructors1
Methods1
transformValue(value: number, pairValue: number): number
Apply the axis transform pipeline to a raw browser axis value (typically Gamepad.axes[i], in -1..1). pairValue is the raw value of the axis at pair for the same poll, and is ignored when this axis has no partner. The deadzone is radial, never per-axis: a stick's two raw components are judged together on their radius, and everything past that radius is rescaled so the channel ramps from 0 at the deadzone edge to full travel at the rim. Per-axis deadzones are what produce the two artefacts this avoids - a jump to threshold's magnitude the instant the stick leaves the deadzone, and a square response curve where a diagonal reads further than a cardinal push of the same physical deflection. The scaled radius is capped at 1, so hardware that reports a square gate (x = y = 1) still lands on the unit circle with its direction intact rather than overshooting. A one-dimensional control (a trigger reported through axes[], a standalone auxiliary axis) gets the same rescaled deadzone applied to its own magnitude, in the channel's own domain - i.e. after normalize has moved a trigger's rest position from -1 to 0, so the deadzone covers the bottom of the pull rather than the middle of it. Pipeline: clamp to [-1, 1] → radial deadzone (paired axes) → optional invert → optional normalize to [0, 1] → scalar deadzone (unpaired axes) → range clamp. A bipolar channel keeps the full [-1, +1] range; every other channel is unipolar and clamps to [0, 1].
Properties7
bipolar: boolean
index: number
invert: boolean
normalize: boolean
pair: null | number
Raw axis index of this axis's stick partner, or null for a one-dimensional control. See GamepadAxisOptions.pair.
threshold: number
Constants24
Secondary touchpad X (0..1) on dual-touchpad hardware. Device-specific: no built-in mapping writes this channel.
Secondary touchpad Y (0..1) on dual-touchpad hardware. Device-specific: no built-in mapping writes this channel.
Source