# Changelog

> Release notes and migration notes for @gamepadly/sdk.

Source: https://gamepadly.com/sdk/changelog

Changes to the `@gamepadly/sdk` package: its API, its runtime behavior and how to migrate. Documentation, examples
and tooling changes are not listed.

The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). While the SDK is at `0.x`, a minor
version (`0.x.0`) can change behavior, always with migration notes here; a patch version (`0.x.y`) only fixes bugs.

## [Unreleased]

## [0.9.0] - 2026-12-05

### Added
- Menu navigation: `actions.repeated(name)` is true on the press, then again after a delay and at an interval while
  the action is held. Set the timing with `repeat: { delayMs, intervalMs }` in the action map (default 400 ms and
  100 ms). `ActionState` has a matching `repeated` field.
- Remapping: `actions.getBindings()` returns the current bindings as JSON-safe data, `actions.setBindings()` replaces
  the bindings of the listed actions and axes, and `actions.lastPressed()` returns the input that went down in the
  latest update (a controller button by its position name, `'l2'` / `'r2'`, a stick direction, a key code or a mouse
  button). A rebound action stays released until its inputs are let go. `setBindings()` ignores names the map does
  not declare. New type `ActionBindings`.
- `isControllerBinding(binding)` tells controller bindings from keyboard and mouse bindings.
- `ignoreHeldOnStart` in the action map keeps actions that are held when the map is created released until they are
  let go.

### Changed
- `getButtonLabel()` also labels `'l2'` and `'r2'` (LT / L2 / ZL and RT / R2 / ZR), and accepts any binding string,
  returning names it does not know unchanged.
- `createActionTracker()` copies the bindings it is given, so `setBindings()` never changes the spec object you passed.

## [0.8.0] - 2026-12-05

### Changed
- `hub.player(n)` keeps its controller. Before, it read whichever controller was n-th in the connected list at that
  moment, so when P1 unplugged, `hub.player(0)` switched to P2's controller and `hub.player(1)` went idle. Connecting a
  DualSense or Switch Pro over WebHID also reordered the list, because WebHID controllers are listed first. Now each
  numbered player stays on its controller while others connect, disconnect or upgrade to WebHID. A player whose
  controller disconnects reads an idle state and `getSlotId()` returns `null`, and the next controller that connects
  takes the lowest free player number.
- `createGameHost()` without `getPlayerSeats` gets the same behavior for `sdk.players.get(n)`.

### Migration notes
- To detect that a player's controller is gone, check `hub.player(n).getSlotId() === null`, for example to pause the
  game.
- Code that relied on players moving up after a disconnect, such as always reading `hub.player(0)` for "whoever is
  still connected", should read `hub.active` instead, or pick from `hub.getSlots()`.

## [0.7.0] - 2026-12-04

### Changed
- `createKeyMouseBridge()` dispatches keyboard events on `document` by default, instead of `window`. Events bubble
  from `document` to `window`, so games that listen on either now work without `keyTarget`. Before, a game listening
  on `document` received nothing unless you passed `keyTarget: document`. Where there is no `document`, the bridge
  still uses `window`.

### Migration notes
- A game that handles the same key on both `window` and `document` now receives each bridged key on both. Pass
  `keyTarget: window` to keep the old behavior.
- A game that listens on an element, such as a focused canvas, still needs `keyTarget: thatElement`.

## [0.6.0] - 2026-12-04

### Added
- Position-based button names. Action maps (`createActions()`, `createActionTracker()`) and bridge profiles accept
  `south`, `east`, `west`, `north`, `select`, `start` and `home` alongside the existing names. `south` is the bottom
  face button on every brand: A on Xbox, Cross on PlayStation, B on Nintendo. New exports: `BUTTON_ALIASES`,
  `resolveButtonName()`, `ButtonAlias`, `ButtonInput`.
- `getButtonLabel(button, brand)` returns the label printed on the player's controller: `'A'`, `'Cross'` or `'B'`;
  `'RT'`, `'R2'` or `'ZR'`.
- `UnifiedInputState.mapping` reports the layout the browser gave: `'standard'`, `'nonstandard'`, `'custom'`, `'hid'`
  or `'none'`. For a non-standard layout, `getCapabilities()` explains why in `standard_input.reason`.
- Custom layouts through `createGamepadly({ gamepadMappings })`, `new DualSenseControllerManager({ gamepadMappings })`
  and `manager.setGamepadMappings()`. They remap buttons, stick axes (optionally inverted) and analog triggers read
  from buttons or axes. New exports: `GamepadMappingRule`, `GamepadAxisSource`, `GamepadTriggerSource`,
  `InputMapping`, `DualSenseControllerManagerOptions`.

### Migration notes
- If you build `UnifiedInputState` objects by hand instead of with `createEmptyInput()`, add the new required
  `mapping` field, for example `mapping: 'none'`.

## [0.5.0] - 2026-12-04

### Added
- Every haptic call returns the output it played on, as a `HapticRouteTier`: `'4ch_vcm'`, `'hd_rumble'`,
  `'impulse_triggers'`, `'dual_rumble'` or `'none'`. This covers `player.haptics.pulse()`, `sweep()` and
  `playPreset()`, `bridge.triggerHaptic()`, and the `routeHapticPulse()`, `routeHapticSweep()` and
  `routeTactilePreset()` functions. Code that ignores the return value is unaffected.
- `@gamepadly/sdk/link` speaks Gamepadly Link protocol v1.1 (Link v0.4.0 and later). `connectDualSenseViaCompanion()`
  checks Link's health, asks for a session bound to the page's origin (Link shows a consent prompt for new
  origins), then lists devices and opens the haptics socket with that session.
  - New `minProtocolVersion` option.
  - New error codes: `'link_outdated'`, `'user_denied'`, `'consent_timeout'`, `'consent_busy'` and
    `'origin_not_allowed'`. Failed results can carry `retryAfterSec`.
  - New exports: `CompanionRequestError`, `CompanionErrorCode`, `LINK_RELEASES_URL`, and
    `CompanionHealth.originAuthorized`.

### Fixed
- The 4-channel audio engine no longer needs a separate `/haptic-worklet.js` file, which failed with a 404 on other
  origins and on sub-path hosting. The AudioWorklet ships inside the package and is loaded from a `blob:` URL. For a
  Content Security Policy that blocks `blob:` worklets, host the file yourself and pass its URL to
  `createLinkAudio({ workletUrl })`.

## [0.4.3] - 2026-12-04

### Changed
- The DualSense speaker plays at a lower default volume (`dsSpeakerGainValue` 0.65), matched to Link's system
  volume mirroring.

### Fixed
- The audio engine reads Link's `syncSystemVolume` setting, and `setGains()` no longer unmutes a muted output.

## [0.4.2] - 2026-12-03

### Fixed
- When a game built on `@gamepadly/sdk/game` or `@gamepadly/sdk/loop` is open in several tabs, only the tab in front
  reads input and drives rumble and adaptive triggers. Loops pause in background tabs.

## [0.4.1] - 2026-12-03

### Fixed
- In `createGameHost()`, PC tones, noise and samples played for a player seat nobody has joined are heard on the PC
  speakers instead of being dropped.

## [0.4.0] - 2026-12-03

### Added
- `@gamepadly/sdk/diagnostics`: `createControllerTelemetry()` with 360° stick circularity in 72 sectors, resting
  drift and button bounce detection.
- `attachControllerLifecycle()`, `SlotAutoSwitcher`, `TriggerFeedbackController` and `createMicLevelMeter()`.
- One-call helpers for 4-channel audio: `connectDualSenseViaCompanion()`, `connectDualSenseViaBrowser()` and
  `launchLinkViaProtocol()`.
