Feel  5.3
The best way to improve your game's feel and make it extra juicy
LofeltHaptics Class Reference

The LofeltHaptics class @discussion Defines the API of Lofelt SDK for iOS. More...

#import <LofeltHaptics.h>

Inheritance diagram for LofeltHaptics:

Instance Methods

(instancetype) - NS_UNAVAILABLE
 
(nullable instancetype) - initAndReturnError:
 
(BOOL) - load:error:
 
(BOOL) - loadFromData:error:
 
(BOOL) - play:
 
(BOOL) - stop:
 
(BOOL) - seek:error:
 
(BOOL) - setAmplitudeMultiplication:error:
 
(BOOL) - setFrequencyShift:error:
 
(BOOL) - loop:error:
 
(float) - getClipDuration
 

Class Methods

(BOOL) + deviceMeetsMinimumRequirement
 

Protected Attributes

void * _controller
 
id< NSObject > _foregroundNotificationObserver
 
id< NSObject > _backgroundNotificationObserver
 

Detailed Description

The LofeltHaptics class @discussion Defines the API of Lofelt SDK for iOS.

        The LofeltHaptics class is not thread safe and can only be used from
        the main thread.

        When the app is put into the background, Core Haptics will not allow
        playing any haptics. LofeltHaptics will detect this situation and cease
        all activity.
        When the app is put into the foreground again, Core Haptics will allow
        playing haptics again, and LofeltHaptics re-initalizes itself. However,
        haptics that were interrupted when the app was backgrounded do not
        automatically resume and need to be started again by calling @c play().
Author
Joao Freire, James Kneafsey, Thomas McGuire, Tomash GHz

Method Documentation

◆ deviceMeetsMinimumRequirement

+ (BOOL) deviceMeetsMinimumRequirement

@abstract Checks if the iPhone meets the minimum requirements @discussion This allows for a runtime check on iPhones that won't meet the requirements for Lofelt Haptics.

Returns
Whether the iPhone supports or not Lofelt Haptics

◆ getClipDuration

- (float) getClipDuration

@abstract Returns the duration of the loaded clip @discussion It will return 0.0 for an invalid clip

Returns
Duration of the loaded clip

◆ initAndReturnError:

- (nullable instancetype) initAndReturnError: (init())  NS_SWIFT_NAME

@abstract Creates an instance of LofeltHaptics. @discussion There should only be one instance of LofeltHaptics created in a given application.

Parameters
errorIf the initialization fails, this will be set to a valid NSError describing the error.

◆ load:error:

- (BOOL) load: (NSString *_Nonnull)  data
error: (ios(13))  API_AVAILABLE 

@abstract Loads a haptic clip from string data. @discussion The data must be in a valid Lofelt JSON format. If a haptic clip is currently playing, it will be stopped.

Parameters
dataThe Lofelt JSON format string.
errorIf the load operation fails, this will be set to a valid NSError describing the error.
Returns
Whether the operation succeeded

◆ loadFromData:error:

- (BOOL) loadFromData: (NSData *_Nonnull)  data
error: (ios(13))  API_AVAILABLE 

@abstract A version of load() taking NSData instead of NSString. @discussion This method can be faster than load(), as it avoids string conversions.

Parameters
dataThe .haptic clip, as UTF-8 encoded JSON string without a null terminator.
errorIf the load operation fails, this will be set to a valid NSError describing the error.
Returns
Whether the operation succeeded

◆ loop:error:

- (BOOL) loop: (BOOL)  enabled
error: (ios(13))  API_AVAILABLE 

@abstract Sets the playback to repeat from the start at the end of the clip. @discussion Changes done with this function are only applied when play() is called. When load() is called, looping is always disabled. Playback will always start at the beginning of the clip, even if seek() was used to jump to a different clip position before.

Parameters
enabledWhen true, looping is set enabled; false disables looping.
errorIf the loop operation fails, this will be set to a valid NSError describing the error.
Returns
Whether the operation succeeded

◆ NS_UNAVAILABLE

- (instancetype) NS_UNAVAILABLE

◆ play:

- (BOOL) play: (ios(13))  API_AVAILABLE

@abstract Plays a loaded haptic clip. @discussion The data must be preloaded using load() . Only one haptic clip can play at a time. Playback will start from the beginning of the haptic clip, or from the seek position if seek() has been called before. Calling play() if the clip is already playing has no effect.

Parameters
errorIf the play operation fails, this will be set to a valid NSError describing the error.
Returns
Whether the operation succeeded

◆ seek:error:

- (BOOL) seek: (float)  time
error: (ios(13))  API_AVAILABLE 

@abstract Jumps to a time position in the haptic clip @discussion The playback state (playing or stopped) will not be changed unless seeking beyond the end of the haptic clip. Seeking beyond the end of the clip will stop playback. Seeking to a negative position will start playback after a delay.

Parameters
timeThe new position within the clip, as seconds from the beginning of the clip
errorIf the seek operation fails, this will be set to a valid NSError describing the error.
Returns
Whether the operation succeeded

◆ setAmplitudeMultiplication:error:

- (BOOL) setAmplitudeMultiplication: (float)  amplitudeMultiplication
error: (ios(13))  API_AVAILABLE 

@abstract Multiplies the amplitude of every breakpoint of the clip with the given multiplication factor @discussion In other words, this function applies a gain (for factors greater than 1.0) or an attenuation (for factors less than 1.0) to the clip. If the resulting amplitude of a breakpoint is greater than 1.0, it is clipped to 1.0. The amplitude is clipped hard, no limiter is used. The clip needs to be loaded with load() first. Loading a clip resets the multiplication factor back to the default of 1.0. If no clip is currently playing, the multiplication will take effect once play() is called. If a clip is currently playing, the multiplication will take effect immediately.

Parameters
amplitudeMultiplicationThe factor by which each amplitude will be multiplied. This value is a multiplication factor, it is not a dB value. The factor needs to be 0 or greater.
errorIf the operation fails, this will be set to a valid NSError describing the error. An error can for example happen if no clip is loaded, or if the factor is outside of the valid range.
Returns
Whether the operation succeeded

◆ setFrequencyShift:error:

- (BOOL) setFrequencyShift: (float)  shift
error: (ios(13))  API_AVAILABLE 

@abstract Adds the given shift to the frequency of every breakpoint in the clip, including the emphasis. @discussion In other words, this function shifts all frequencies of the clip. If the resulting frequency of a breakpoint is smaller than 0.0 or greater than 1.0, it is clipped to that range. The frequency is clipped hard, no limiter is used. The clip needs to be loaded with load() first. Loading a clip resets the shift back to the default of 0.0. If no clip is currently playing, the shift will take effect once play() is called. If a clip is currently playing, the shift will take effect immediately.

Parameters
shiftThe amount by which each frequency should be shifted. This number is added to each frequency value. The shift needs to be between -1.0 and 1.0.
errorIf the operation fails, this will be set to a valid NSError describing the error. An error can for example happen if no clip is loaded, or if the shift is outside of the valid range.
Returns
Whether the operation succeeded

◆ stop:

- (BOOL) stop: (ios(13))  API_AVAILABLE

@abstract Stops the haptic clip that is currently playing. @discussion The call is ignored if no clip is loaded or no clip is playing.

Parameters
errorIf the stop operation fails, this will be set to a valid NSError describing the error.
Returns
Whether the operation succeeded

Member Data Documentation

◆ _backgroundNotificationObserver

- (id<NSObject>) _backgroundNotificationObserver
protected

◆ _controller

- (void*) _controller
protected

◆ _foregroundNotificationObserver

- (id<NSObject>) _foregroundNotificationObserver
protected

The documentation for this class was generated from the following file: