objc2_core_haptics/generated/
CHHapticEvent.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// Types of haptic and audio events.
11///
12///
13/// An event which generates a haptic with a fixed length, such as a tap.  Transient events will complete on their own.  If a duration longer than the
14/// haptic is provided, the pattern containing the event will be "padded" out to the duration specified.
15///
16///
17/// An event which generates a haptic of arbitrary length.  The event can behave as either Transient or Continuous depending on the value
18/// of the CHHapticEventParameterIDSustained parameter.  These events also include an AR or ADR gain envelope that may be controlled via Event or
19/// Dynamic parameters.
20/// See `CHHapticEventParameterIDAttackTime`, `CHHapticEventParameterIDDecayTime`, and `CHHapticEventParameterIDReleaseTime`.
21///
22///
23/// An event which generates an audio signal.  The event can behave as either Transient or Continuous depending on the value of the
24/// CHHapticEventParameterIDSustained parameter.  These events also include an AR or ADR gain envelope that may be controlled via Event or
25/// Dynamic parameters.
26/// See `CHHapticEventParameterIDAttackTime`, `CHHapticEventParameterIDDecayTime`, and `CHHapticEventParameterIDReleaseTime`.
27///
28///
29/// An event which generates an audio signal using a client-supplied waveform (see `CHHapticEngine(registerAudioResource:options:error)`).
30/// Currently, these behave as Transient events (i.e., no looping or enveloping).
31///
32/// See also [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticeventtype?language=objc)
33// NS_TYPED_ENUM
34pub type CHHapticEventType = NSString;
35
36extern "C" {
37    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticeventtypehaptictransient?language=objc)
38    pub static CHHapticEventTypeHapticTransient: &'static CHHapticEventType;
39}
40
41extern "C" {
42    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticeventtypehapticcontinuous?language=objc)
43    pub static CHHapticEventTypeHapticContinuous: &'static CHHapticEventType;
44}
45
46extern "C" {
47    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticeventtypeaudiocontinuous?language=objc)
48    pub static CHHapticEventTypeAudioContinuous: &'static CHHapticEventType;
49}
50
51extern "C" {
52    /// [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticeventtypeaudiocustom?language=objc)
53    pub static CHHapticEventTypeAudioCustom: &'static CHHapticEventType;
54}
55
56/// Identifier for registered, client-loaded audio data which can be used as custom event types
57/// (see `CHHapticEngine(registerAudioResource:options:error)`).
58///
59/// See also [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticaudioresourceid?language=objc)
60pub type CHHapticAudioResourceID = NSUInteger;
61
62extern_class!(
63    /// The description of a single haptic/audio event, plus optional Event parameters which modify the event.
64    ///
65    /// CHHapticEvents have a relative time property to allow specifying the time relationship between events in a pattern.
66    ///
67    /// See also [Apple's documentation](https://developer.apple.com/documentation/corehaptics/chhapticevent?language=objc)
68    #[unsafe(super(NSObject))]
69    #[derive(Debug, PartialEq, Eq, Hash)]
70    pub struct CHHapticEvent;
71);
72
73extern_conformance!(
74    unsafe impl NSObjectProtocol for CHHapticEvent {}
75);
76
77impl CHHapticEvent {
78    extern_methods!(
79        /// The type of event.
80        #[unsafe(method(type))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn r#type(&self) -> Retained<CHHapticEventType>;
83
84        #[cfg(feature = "CHHapticParameter")]
85        /// NSArray of Event parameters.  Can be empty.
86        #[unsafe(method(eventParameters))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn eventParameters(&self) -> Retained<NSArray<CHHapticEventParameter>>;
89
90        /// The relative time for this event versus the start time of the pattern.  Units are seconds.
91        #[unsafe(method(relativeTime))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn relativeTime(&self) -> NSTimeInterval;
94
95        /// Setter for [`relativeTime`][Self::relativeTime].
96        #[unsafe(method(setRelativeTime:))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn setRelativeTime(&self, relative_time: NSTimeInterval);
99
100        /// The duration for this event.  Units are seconds.  If unset (0.0), Continuous event types will have no fixed end.
101        #[unsafe(method(duration))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn duration(&self) -> NSTimeInterval;
104
105        /// Setter for [`duration`][Self::duration].
106        #[unsafe(method(setDuration:))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn setDuration(&self, duration: NSTimeInterval);
109
110        #[unsafe(method(init))]
111        #[unsafe(method_family = init)]
112        pub unsafe fn init(this: Allocated<Self>) -> Option<Retained<Self>>;
113
114        #[cfg(feature = "CHHapticParameter")]
115        /// Initialize a new CHHapticEvent.  This can only be used to create Transient event types (which do not require a duration).
116        ///
117        /// Parameter `type`: The type of event.
118        ///
119        /// Parameter `eventParams`: An NSArray of Event parameters.  Can be empty.
120        ///
121        /// Parameter `time`: The relative time for this event versus the other events in the CHHapticPattern.
122        #[unsafe(method(initWithEventType:parameters:relativeTime:))]
123        #[unsafe(method_family = init)]
124        pub unsafe fn initWithEventType_parameters_relativeTime(
125            this: Allocated<Self>,
126            r#type: &CHHapticEventType,
127            event_params: &NSArray<CHHapticEventParameter>,
128            time: NSTimeInterval,
129        ) -> Retained<Self>;
130
131        #[cfg(feature = "CHHapticParameter")]
132        /// Initialize a new CHHapticEvent, providing a duration.
133        ///
134        /// Parameter `type`: The type of event.
135        ///
136        /// Parameter `eventParams`: An NSArray of Event parameters.  Can be empty.
137        ///
138        /// Parameter `time`: The relative time for this event versus the other events in the CHHapticPattern.
139        ///
140        /// Parameter `duration`: For Continuous event types, the length of time before the event playback begins its release.
141        /// For Transient event types, the logical length of the event (used to determine pattern end and loop points).
142        #[unsafe(method(initWithEventType:parameters:relativeTime:duration:))]
143        #[unsafe(method_family = init)]
144        pub unsafe fn initWithEventType_parameters_relativeTime_duration(
145            this: Allocated<Self>,
146            r#type: &CHHapticEventType,
147            event_params: &NSArray<CHHapticEventParameter>,
148            time: NSTimeInterval,
149            duration: NSTimeInterval,
150        ) -> Retained<Self>;
151
152        #[cfg(feature = "CHHapticParameter")]
153        /// Initialize a new CHHapticEvent using a previously-loaded audio resource.
154        ///
155        /// Parameter `resID`: A previously-registered audio resource ID (see `CHHapticEngine(registerAudioResource:options:error)`).
156        ///
157        /// Parameter `eventParams`: An NSArray of Event parameters.  Can be empty.
158        ///
159        /// Parameter `time`: The relative time for this event versus the other events in the CHHapticPattern.
160        #[unsafe(method(initWithAudioResourceID:parameters:relativeTime:))]
161        #[unsafe(method_family = init)]
162        pub unsafe fn initWithAudioResourceID_parameters_relativeTime(
163            this: Allocated<Self>,
164            res_id: CHHapticAudioResourceID,
165            event_params: &NSArray<CHHapticEventParameter>,
166            time: NSTimeInterval,
167        ) -> Retained<Self>;
168
169        #[cfg(feature = "CHHapticParameter")]
170        /// Initialize a new CHHapticEvent using a previously-loaded audio resource.
171        ///
172        /// Parameter `resID`: A previously-registered audio resource ID (see `CHHapticEngine(registerAudioResource:options:error)`).
173        ///
174        /// Parameter `eventParams`: An NSArray of Event parameters.  Can be empty.
175        ///
176        /// Parameter `time`: The relative time for this event versus the other events in the CHHapticPattern.
177        ///
178        /// Parameter `duration`: The duration of this event in seconds.
179        ///
180        /// If the specified duration is less than the duration of the audio resource, its playback will be truncated.  If it
181        /// is greater, its playback will be padded with silence.  If zero, it will be ignored.
182        #[unsafe(method(initWithAudioResourceID:parameters:relativeTime:duration:))]
183        #[unsafe(method_family = init)]
184        pub unsafe fn initWithAudioResourceID_parameters_relativeTime_duration(
185            this: Allocated<Self>,
186            res_id: CHHapticAudioResourceID,
187            event_params: &NSArray<CHHapticEventParameter>,
188            time: NSTimeInterval,
189            duration: NSTimeInterval,
190        ) -> Retained<Self>;
191    );
192}
193
194/// Methods declared on superclass `NSObject`.
195impl CHHapticEvent {
196    extern_methods!(
197        #[unsafe(method(new))]
198        #[unsafe(method_family = new)]
199        pub unsafe fn new() -> Retained<Self>;
200    );
201}