# Haptics

> Play cross-brand haptic presets, pulses, sweeps, and continuous textures that adapt to each controller's hardware.

Source: https://gamepadly.com/sdk/guides/haptics

Every haptic call picks the best output the controller has (DualSense voice coils, Switch Pro HD Rumble, Xbox
trigger motors, or dual-motor rumble) and returns which one it used. See
[haptic routing](https://gamepadly.com/sdk/start/tiers#haptic-routing).

## Presets

```ts
const tier = p1.haptics.playPreset('recoil', { pan: 0.4, intensity: 0.8 });
```

`pan` runs from `-1` (left) to `1` (right), and `intensity` from `0` to `1`.

| Preset | Typical use | Base pulse |
| :--- | :--- | :--- |
| `'click'` | UI clicks and confirmations | 210 Hz, 26 ms |
| `'ratchet'` | Menu steps, dial notches | 180 Hz, 22 ms |
| `'wall_hit'` | Bumping into walls | 135 Hz, 65 ms |
| `'marble_click'` | Small objects tapping | 290 Hz, 32 ms |
| `'recoil'` | Gunshots | 115 Hz, 75 ms |
| `'heavy_impact'` | Taking a big hit | 75 Hz, 140 ms |
| `'lock_unlock'` | Locks and latches | 95 Hz, 120 ms |
| `'splash'` | Water | 90 Hz, 110 ms |
| `'boost'` | Dashes and speed boosts | 65 Hz, 160 ms |
| `'error_buzz'` | Rejected actions | 145 Hz, 95 ms |

## Pulses and sweeps

For custom effects, describe the vibration directly:

```ts
p1.haptics.pulse({ freqHz: 160, durationMs: 90, intensity: 0.7, pan: -0.5 });
p1.haptics.sweep({ fromPan: -1, toPan: 1, fromHz: 80, toHz: 220, durationMs: 400, intensity: 0.6 });
```

Frequencies around 25–360 Hz suit the DualSense voice coils. Other controllers approximate the same effect with
their own motors.

## Continuous textures

```ts
const engine = p1.haptics.createContinuous('engine');
engine.update({ intensity: throttle, speed: rpm / 8000 });
// later
engine.stop();
```

Textures: `'ice'`, `'metal'`, `'gravel'`, `'grass'`, `'water'`, `'engine'`, `'tension'`. Call `update()` every frame
with `intensity`, `speed`, `pan`, or `freqScale`.

## Combos

`p1.haptics.playComboPreset(id, pan)` plays multi-part effects tuned for specific moments: `'ratchet_tick'`,
`'lock_sweet_spot'`, `'lock_unlock'`, `'fish_bite'`, `'fish_splash'`, `'pistol'`, `'shotgun'`, `'bow_release'`,
`'thunder'`.

## Brand-specific calls

- `p1.haptics.rumble({ weak, strong, durationMs })`: plain dual-motor rumble on any controller.
- `p1.haptics.hdRumble({ left, right, durationMs })` and `hdSequence(steps)`: raw Switch Pro HD Rumble.
- `p1.triggers.pulseImpulse({ left, right, durationMs })`: Xbox impulse trigger motors.
- `p1.haptics.stop()`: stop everything on this controller.

## Safety

The SDK clamps Switch Pro amplitudes, ends every effect with a neutral packet, and resets rumble, triggers, and
continuous effects on `pagehide` and `hub.dispose()`. You do not need to stop effects on page exit yourself.
