objc2-core-haptics 0.3.2

Bindings to the CoreHaptics framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// Keys used to define a CHHapticPattern.
///
///
/// A definition for a haptic pattern consists of a heirarchical set of key/value pairs, starting at the topmost level with
/// a "Version" and a "Pattern" key.  The "Pattern" marks the beginning of an array of event (CHHapticPatternKeyEvent)
/// and parameter (CHHapticPatternKeyParameter) definitions.  Each of these has an associated time which indicates when the event or parameter
/// will be delivered to the haptic engine.
///
///
/// The version of the system for which the pattern was authored.
/// Value type: Real.
///
///
/// Indicates the beginning of a haptic pattern definition.
/// Value type: Array.
///
///
/// Indicates the beginning of a haptic event definition, which will include an event type, a time, and an optional set
/// of event parameters (CHHapticPatternKeyEventParameters).
/// Value type: Dictionary.
///
///
/// The type of haptic or audio event.
/// Value type: NSString (CHHapticEventType).
///
///
/// The duration in seconds for an event.
/// Value type: Real.
///
///
/// Indicates the beginning of an array of event parameter (CHHapticPatternKeyParameter) definitions for a specific event.
/// Value type: Array.
///
///
/// Indicates the beginning of a parameter definition, which will include a parameter type and value, and a time.
/// Value type: Dictionary.
///
///
/// The ID of the parameter.
/// Value type: NSString (CHHapticEventParameterID for event parameters and CHHapticDynamicParameterID for dynamic parameters).
///
///
/// The value of the parameter.  The range will vary with the parameter.
/// Value type: Real.
///
///
/// The relative time for any event or parameter.  Units are seconds.
/// Value type: Real.
///
///
/// For events of type CHHapticEventTypeAudioCustom, the path to the local file containing the audio waveform.
/// Value type: NSString.
///
///
/// For events of type CHHapticEventTypeAudioCustom, indicates whether the audio file playback should be ramped in and out with an envelope.
/// This can be useful for preventing clicks during playback, or for cases where the application wants to modulate this envelope to use different
/// attack and release times.
/// Value type: boolean.  Default is true.
///
///
/// For events of type CHHapticEventTypeAudioCustom, indicates whether the audio file playback will be looped.
/// Value type: boolean.  Default is false.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkey?language=objc)
// NS_TYPED_ENUM
pub type CHHapticPatternKey = NSString;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyversion?language=objc)
    pub static CHHapticPatternKeyVersion: &'static CHHapticPatternKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeypattern?language=objc)
    pub static CHHapticPatternKeyPattern: &'static CHHapticPatternKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyevent?language=objc)
    pub static CHHapticPatternKeyEvent: &'static CHHapticPatternKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyeventtype?language=objc)
    pub static CHHapticPatternKeyEventType: &'static CHHapticPatternKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeytime?language=objc)
    pub static CHHapticPatternKeyTime: &'static CHHapticPatternKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyeventduration?language=objc)
    pub static CHHapticPatternKeyEventDuration: &'static CHHapticPatternKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyeventwaveformpath?language=objc)
    pub static CHHapticPatternKeyEventWaveformPath: &'static CHHapticPatternKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyeventparameters?language=objc)
    pub static CHHapticPatternKeyEventParameters: &'static CHHapticPatternKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyeventwaveformusevolumeenvelope?language=objc)
    pub static CHHapticPatternKeyEventWaveformUseVolumeEnvelope: &'static CHHapticPatternKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyeventwaveformloopenabled?language=objc)
    pub static CHHapticPatternKeyEventWaveformLoopEnabled: &'static CHHapticPatternKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyparameter?language=objc)
    pub static CHHapticPatternKeyParameter: &'static CHHapticPatternKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyparameterid?language=objc)
    pub static CHHapticPatternKeyParameterID: &'static CHHapticPatternKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyparametervalue?language=objc)
    pub static CHHapticPatternKeyParameterValue: &'static CHHapticPatternKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyparametercurve?language=objc)
    pub static CHHapticPatternKeyParameterCurve: &'static CHHapticPatternKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpatternkeyparametercurvecontrolpoints?language=objc)
    pub static CHHapticPatternKeyParameterCurveControlPoints: &'static CHHapticPatternKey;
}

extern_class!(
    /// A set of one or more haptic events and/or Dynamic parameters/parameter curves.
    ///
    /// The passed-in arrays' contents are not owned by the pattern object.  Changes made to those arrays
    /// after a CHHapticPattern object is created have no effect on that object.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticpattern?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CHHapticPattern;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for CHHapticPattern {}
);

impl CHHapticPattern {
    extern_methods!(
        /// Pattern duration is calculated as the start time of the pattern's last event or parameter, plus that event's duration if present.
        #[unsafe(method(duration))]
        #[unsafe(method_family = none)]
        pub unsafe fn duration(&self) -> NSTimeInterval;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Option<Retained<Self>>;

        #[cfg(all(feature = "CHHapticEvent", feature = "CHHapticParameter"))]
        /// Initialize a new CHHapticPattern.
        ///
        /// Parameter `events`: An NSArray of CHHapticEvents.  Can be empty.
        ///
        /// Parameter `parameters`: An NSArray of CHHapticDynamicParameters.  Can be empty.
        #[unsafe(method(initWithEvents:parameters:error:_))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithEvents_parameters_error(
            this: Allocated<Self>,
            events: &NSArray<CHHapticEvent>,
            parameters: &NSArray<CHHapticDynamicParameter>,
        ) -> Result<Retained<Self>, Retained<NSError>>;

        #[cfg(all(feature = "CHHapticEvent", feature = "CHHapticParameter"))]
        /// Initialize a new CHHapticPattern with parameters modulated by parameter curves.
        ///
        /// Parameter `events`: An NSArray of CHHapticEvents.  Can be empty.
        ///
        /// Parameter `parameterCurves`: An NSArray of CHHapticParameterCurves.  Can be empty.
        #[unsafe(method(initWithEvents:parameterCurves:error:_))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithEvents_parameterCurves_error(
            this: Allocated<Self>,
            events: &NSArray<CHHapticEvent>,
            parameter_curves: &NSArray<CHHapticParameterCurve>,
        ) -> Result<Retained<Self>, Retained<NSError>>;

        /// Initialize a new CHHapticPattern using the passed-in NSDictionary.
        ///
        /// Parameter `patternDict`: NSDictionary containing a pattern property list.
        ///
        /// # Safety
        ///
        /// `pattern_dict` generic should be of the correct type.
        #[unsafe(method(initWithDictionary:error:_))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithDictionary_error(
            this: Allocated<Self>,
            pattern_dict: &NSDictionary<CHHapticPatternKey, AnyObject>,
        ) -> Result<Retained<Self>, Retained<NSError>>;

        /// Initialize a new CHHapticPattern using the contents of the passed-in NSURL.
        ///
        /// Parameter `ahapURL`: NSURL of an ahap file.
        ///
        /// This URL must reference a valid AHAP file.
        #[unsafe(method(initWithContentsOfURL:error:_))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithContentsOfURL_error(
            this: Allocated<Self>,
            ahap_url: &NSURL,
        ) -> Result<Retained<Self>, Retained<NSError>>;

        /// Returns a NSDictionary representation of the contents of the pattern.
        ///
        /// Patterns containing custom audio resource IDs cannot be exported and will return nil
        /// with the error code set to CHHapticErrorCodeOperationNotPermitted.
        #[unsafe(method(exportDictionaryAndReturnError:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn exportDictionaryAndReturnError(
            &self,
        ) -> Result<Retained<NSDictionary<CHHapticPatternKey, AnyObject>>, Retained<NSError>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl CHHapticPattern {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}