You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+88-18Lines changed: 88 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,15 +27,15 @@ They’re separate because they’re different object types in Core Haptics (eve
27
27
28
28
## Usage
29
29
30
-
### Haptic “provider” (recommended)
30
+
### Haptic "provider" (recommended)
31
31
32
-
Wrap your app inside `HapticsProvider`. This initializes the engine, creates the continuous player, and automatically destroys the engine when the app goes to background.
32
+
Wrap your app inside `HapticProvider`. This initializes the engineand automatically destroys it when the app goes to background.
|`startHaptic(events, curves)`| Play a pattern (transient + continuous events, optional curves) |
203
+
|`stopAllHaptics()`| Stop any running haptics (useful on unmount/navigation) |
204
+
|`useContinuousPlayer(playerId, initialIntensity, initialSharpness)`| Hook to manage a continuous player lifecycle |
205
+
|`createContinuousPlayer(playerId, initialIntensity, initialSharpness)`| Create a continuous player with given ID |
206
+
|`startContinuousPlayer(playerId)` / `stopContinuousPlayer(playerId)`| Start/stop continuous playback for player |
207
+
|`updateContinuousPlayer(playerId, intensityControl, sharpnessControl)`| Update intensity/sharpness for player |
208
+
|`destroyContinuousPlayer(playerId)`| Destroy player and release resources |
179
209
180
210
## Types (inputs)
181
211
@@ -213,6 +243,46 @@ export function SomeScreen() {
213
243
|`relativeTime`|`number`|
214
244
|`controlPoints`|`HapticCurveControlPoint[]`|
215
245
246
+
## Limitations
247
+
248
+
### Parameter curves affect all events in a pattern
249
+
250
+
In CoreHaptics, `CHHapticParameterCurve` uses `hapticIntensityControl` and `hapticSharpnessControl` — these are **pattern-level multipliers**, not per-event modifiers. Any curve you define will multiply the intensity/sharpness of **all events** playing at that moment, including transients.
{ relativeTime: 1000, value: 0.3 }, // At t=1000ms, intensity control = 0.3
264
+
{ relativeTime: 2000, value: 0.3 },
265
+
]},
266
+
]
267
+
);
268
+
```
269
+
270
+
The transient at `t=1000ms` has base intensity `1.0`, but the curve sets `intensityControl=0.3` at that moment. **Effective intensity: 1.0 × 0.3 = 0.3**. The transient feels weaker than expected.
271
+
272
+
**Workaround:** Play continuous and transient events in separate `startHaptic()` calls:
273
+
274
+
```ts
275
+
// Continuous with curves
276
+
startHaptic(continuousEvents, curves);
277
+
278
+
// Transients without curves (separate pattern)
279
+
startHaptic(transientEvents, []);
280
+
```
281
+
282
+
Each call creates an isolated pattern/player — curves from one won't affect events in the other.
283
+
284
+
> **Note:** The library automatically resets control values to `1.0` at the end of each continuous event, so transients **after** a continuous event finishes are not affected. This limitation only applies to transients **during** a continuous event with active curves.
0 commit comments