Go to file
Alexey Chubar e7314e688b
Build and Publish NPM Package / docker (push) Successful in 14s Details
iOS implementation now uses Main Dispatch Queue to improve thread safety
2024-05-07 17:16:21 +03:00
.gitea/workflows Initial commit 2023-07-26 00:40:46 +03:00
MMNiceVibrations iOS implementation now uses Main Dispatch Queue to improve thread safety 2024-05-07 17:16:21 +03:00
Resources Introducing AHAP patterns support for iOS + more built-in primitives 2023-08-09 16:58:58 +03:00
Runtime Migrating to re-newed bits package 2024-04-22 16:49:13 +03:00
.gitignore Migrating to re-newed bits package 2024-04-22 16:49:13 +03:00
CHANGELOG.md iOS implementation now uses Main Dispatch Queue to improve thread safety 2024-05-07 17:16:21 +03:00
CHANGELOG.md.meta Initial commit 2023-07-26 00:40:46 +03:00
MMNiceVibrations.meta Introducing AHAP patterns support for iOS + more built-in primitives 2023-08-09 16:58:58 +03:00
README.md Initial commit 2023-07-26 00:40:46 +03:00
README.md.meta Initial commit 2023-07-26 00:40:46 +03:00
Resources.meta Introducing AHAP patterns support for iOS + more built-in primitives 2023-08-09 16:58:58 +03:00
Runtime.meta Initial commit 2023-07-26 00:40:46 +03:00
package.json iOS implementation now uses Main Dispatch Queue to improve thread safety 2024-05-07 17:16:21 +03:00
package.json.meta Initial commit 2023-07-26 00:40:46 +03:00

README.md

At a glance

Lightweight wrapper for native haptic feedback APIs for Android & iOS.

Currently contains:

  • HapticFeedbackAndroid & HapticFeedbackIOS wrappers to access OS APIs with little to no allocations
  • HapticFeedbackChirp: combine OS haptic primitives to build pleasant vibration patterns
  • HapticsManager: helper class for feedback pacing control

Usage

using BitGames.Haptics;
...
//Step 1: Create a manager
var haptics = new HapticsManager(maxConcurrentFeedbacks: 1, () => UnityEngine.Time.time);
haptics.Init();

//Step 2: Register a pattern
const int myPatternID = 1337;
haptics.Register(myPatternID, new HapticFeedbackChirp(haptics.ChirpEngine, 
  HapticChirpIntensity.High,
  HapticChirpIntensity.Low,
  HapticChirpIntensity.None,
  HapticChirpIntensity.None,
  HapticChirpIntensity.High,
  HapticChirpIntensity.Low
));
//(pro-tip: no need to hardcode: use HapticFeedbackChirpPatternAsset for pattern content)
//(pro-tip 2: use project-specific metagen enums for pattern IDs)

//Step 3: Fire a haptic feedback when necessary
haptics.Feedback(myPatternID);