UNPKG

react-native-hapticlabs

Version:

A package to play back haptics developed using Hapticlabs Studio

246 lines 9.96 kB
/** * This command will play an HLA file from the specified `path`, including corresponding audio files. * * *Note*: This command is only supported on Android. * @param path The path to the HLA file. This can be a path relative to the assets directory or a fully qualified path. * @returns A promise that resolves when the HLA file has been played. */ export declare function playHLA(path: string): Promise<void>; /** * This command will play an OGG file from the specified `path`, including encoded haptic feedback. * If the device's haptic support level is less than 3, the device will play the audio file without haptic feedback. * To automatically select adequate haptic feedback for the device, use `playAndroidHaptics` instead. * * *Note*: This command is only supported on Android. * @param path The path to the OGG file. This can be a path relative to the assets directory or a fully qualified path. * @returns A promise that resolves when the OGG file has been played. */ export declare function playOGG(path: string): Promise<void>; /** * This command will play a haptic pattern from the specified `directoryPath`. * Depending on the device's haptic support level, different haptic feedback will be played. * For instance, if the device's haptic support level is 3, the device will play the haptic pattern * specified in the `lvl3` subdirectory. If the device's haptic support level is 0, no haptic feedback will be played. * Make sure that the directory follows the following structure: * ``` * directoryPath * ├── lvl1 * │ └── main.hla * ├── lvl2 * │ └── main.hla * └── lvl3 * └── main.ogg * ``` * *Note*: This command is only supported on Android. * @param directoryPath The path to the haptic pattern directory. This can be a path relative to the assets directory or a fully qualified path. * @returns A promise that resolves when the haptic pattern has been played. */ export declare function playAndroidHaptics(directoryPath: string): Promise<void>; /** * This command will preload the OGG file from the specified `path`. * * This is useful for reducing latency when playing haptic patterns. Currently, * OGG filse will only be preloaded and cached if their uncompressed size is * less than 1 MB * (see [Android's SoundPool documentation](https://developer.android.com/reference/android/media/SoundPool)). * * @param path The path to the haptic pattern directory to unload. The same * you would pass to `playOGG`. */ export declare function preloadOGG(path: string): void; /** * This command will preload haptic patterns from the specified `directoryPath`. * * This is useful for reducing latency when playing haptic patterns. Currently, * only OGG files will be preloaded and cached, and only so if their * uncompressed size is less than 1 MB * (see [Android's SoundPool documentation](https://developer.android.com/reference/android/media/SoundPool)). * * @param directoryPath The path to the haptic pattern directory. See the * `playAndroidHaptics` documentation for the expected directory structure. */ export declare function preloadAndroidHaptics(directoryPath: string): void; /** * This command will unload the OGG file from the specified `path`. * * This is useful for freeing up memory when the haptic patterns are no longer * needed, and to clear the cache and enforce a reload if the file has changed. * * @param path The path to the haptic pattern directory to unload. The same * you would pass to `playOGG`. */ export declare function unloadOGG(path: string): void; /** * This command will unload the haptic patterns loaded from the specified * `path`. * * This is useful for freeing up memory when the haptic patterns are no longer * needed, and to clear the cache and enforce a reload if the files have * changed. * * @param path The path to the haptic pattern directory to unload. See the * `playAndroidHaptics` documentation for the expected directory structure. */ export declare function unloadAndroidHaptics(path: string): void; /** * This command will unload all haptic patterns that have been preloaded or * played. * * Equivalent to calling `unloadAndroidHaptics()` for all directories and OGG * files that have been preloaded or played. */ export declare function unloadAllAndroidHaptics(): void; /** * The device's haptic support level. * This value is a number between 0 and 3, where: * - 0: The device does not support haptics. * - 1: The device supports on / off haptic feedback. * - 2: The device supports amplitude control haptic feedback. * - 3: The device supports fully customizable haptic feedback. * * *Note*: This value is only supported on Android. */ export declare const androidHapticSupportLevel: 0 | 1 | 2 | 3; /** * Whether the device supports on/off haptic feedback. * * On/Off haptic feedback is the most basic form of haptic feedback with timing * being the only controllable parameter. * * *Note**: This value is only supported on Android. */ export declare const areOnOffHapticsSupported: boolean; /** * Whether the device supports amplitude control haptic feedback. * * Amplitude control haptic feedback allows for more nuanced haptic feedback * by controlling the amplitude of the haptic signal over time. * * **Note**: This value is only supported on Android. */ export declare const areAmplitudeControlHapticsSupported: boolean; /** * Whether the device supports audio coupled haptic feedback. * * Audio coupled haptic feedback allows for full control over the haptic * feedback, while at the same time offering playback synchronized with audio. * * **Note**: This value is only supported on Android. */ export declare const areAudioCoupledHapticsSupported: boolean; /** * Whether the device supports envelope-controlled haptic feedback. * * Similar to amplitude control haptic feedback, envelope-controlled haptic * feedback allows for controlling both the amplitude and the frequency of the * haptic signal over time. * * **Note**: This value is only supported on Android. */ export declare const areEnvelopeHapticsSupported: boolean; /** * The device's haptic actuator's resonance frequency. * * This is the frequency at which the haptic actuator is driven for e.g. HLA * level 2 files. At this frequency, the actuator will resonate and produce * the strongest and most energy-efficient haptic feedback. * * **Note**: This value is only supported on Android. */ export declare const resonanceFrequency: number | null; /** * The device's haptic actuator's q factor. * * See https://en.wikipedia.org/wiki/Q_factor for more information. * * **Note**: This value is only supported on Android. */ export declare const qFactor: number | null; /** * The device's haptic actuator's self-reported minimum frequency. * * **Note**: This value is only supported on Android. * * **Note**: With audio-coupled haptics (OGG files), there are no frequency * limits. */ export declare const minFrequency: number | null; /** * The device's haptic actuator's self-reported maximum frequency. * * **Note**: This value is only supported on Android. * * **Note**: With audio-coupled haptics (OGG files), there are no frequency * limits. */ export declare const maxFrequency: number | null; /** * The device's haptic actuator's self-reported maximum acceleration (in Gs). * * **Note**: This value is only supported on Android. */ export declare const maxAcceleration: number | null; declare let frequencyResponse: Map<number, number> | null; /** * The device's haptic actuator's self-reported frequency response. * * This is a map from frequency (in Hz) to acceleration (in Gs) at that * frequency. * * **Note**: This value is only supported on Android. */ export { frequencyResponse }; /** * The minimum duration (in milliseconds) for an envelope control point. * * **Note**: This value is only supported on Android. */ export declare const envelopeControlPointMinDurationMillis: number | null; /** * The maximum duration (in milliseconds) for an envelope control point. * * **Note**: This value is only supported on Android. */ export declare const envelopeControlPointMaxDurationMillis: number | null; /** * The maximum duration (in milliseconds) for an envelope effect. * * **Note**: This value is only supported on Android. */ export declare const envelopeMaxDurationMillis: number | null; /** * The maximum number of control points for an envelope effect. * * **Note**: This value is only supported on Android. */ export declare const envelopeMaxControlPointCount: number | null; /** * This command will play an AHAP file from the specified `path`, including corresponding AHAP files and audio files. * * *Note*: This command is only supported on iOS. * @param path The path to the AHAP file. * @returns A promise that resolves when the AHAP file has been played. */ export declare function playAHAP(path: string): Promise<void>; /** * This command will play the haptic pattern specified by the `iosPath` on iOS and the `androidPath` on Android. * @param iosPath The path to the AHAP file. * @param androidPath The path to the Android haptic pattern directory. This can be a path relative to the assets directory or a fully qualified path. * @returns A promise that resolves when the haptic pattern has finished playing. */ export declare function playHaptics({ iosPath, androidPath, }: { iosPath: string; androidPath: string; }): Promise<void>; export declare enum PredefinedHaptics { ANDROID_CLICK = "Click", ANDROID_DOUBLE_CLICK = "Double Click", ANDROID_HEAVY_CLICK = "Heavy Click", ANDROID_TICK = "Tick" } /** * This command will play a predefined (built-in) haptic signal. * @param signal The predefined haptic signal to play. */ export declare function playPredefinedHaptics(signal: PredefinedHaptics): void; //# sourceMappingURL=index.d.ts.map