use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-avf-audio")]
use objc2_avf_audio::*;
use objc2_foundation::*;
use crate::*;
pub const CHHapticTimeImmediate: NSTimeInterval = 0.0;
#[cfg(feature = "block2")]
pub type CHHapticCompletionHandler = *mut block2::DynBlock<dyn Fn(*mut NSError)>;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CHHapticEngineFinishedAction(pub NSInteger);
impl CHHapticEngineFinishedAction {
#[doc(alias = "CHHapticEngineFinishedActionStopEngine")]
pub const StopEngine: Self = Self(1);
#[doc(alias = "CHHapticEngineFinishedActionLeaveEngineRunning")]
pub const LeaveEngineRunning: Self = Self(2);
}
unsafe impl Encode for CHHapticEngineFinishedAction {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for CHHapticEngineFinishedAction {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[cfg(feature = "block2")]
pub type CHHapticEngineFinishedHandler =
*mut block2::DynBlock<dyn Fn(*mut NSError) -> CHHapticEngineFinishedAction>;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CHHapticEngineStoppedReason(pub NSInteger);
impl CHHapticEngineStoppedReason {
#[doc(alias = "CHHapticEngineStoppedReasonAudioSessionInterrupt")]
pub const AudioSessionInterrupt: Self = Self(1);
#[doc(alias = "CHHapticEngineStoppedReasonApplicationSuspended")]
pub const ApplicationSuspended: Self = Self(2);
#[doc(alias = "CHHapticEngineStoppedReasonIdleTimeout")]
pub const IdleTimeout: Self = Self(3);
#[doc(alias = "CHHapticEngineStoppedReasonNotifyWhenFinished")]
pub const NotifyWhenFinished: Self = Self(4);
#[doc(alias = "CHHapticEngineStoppedReasonEngineDestroyed")]
pub const EngineDestroyed: Self = Self(5);
#[doc(alias = "CHHapticEngineStoppedReasonGameControllerDisconnect")]
pub const GameControllerDisconnect: Self = Self(6);
#[doc(alias = "CHHapticEngineStoppedReasonSystemError")]
pub const SystemError: Self = Self(-1);
}
unsafe impl Encode for CHHapticEngineStoppedReason {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for CHHapticEngineStoppedReason {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[cfg(feature = "block2")]
pub type CHHapticEngineStoppedHandler = *mut block2::DynBlock<dyn Fn(CHHapticEngineStoppedReason)>;
#[cfg(feature = "block2")]
pub type CHHapticEngineResetHandler = *mut block2::DynBlock<dyn Fn()>;
pub type CHHapticAudioResourceKey = NSString;
extern "C" {
pub static CHHapticAudioResourceKeyUseVolumeEnvelope: &'static CHHapticAudioResourceKey;
}
extern "C" {
pub static CHHapticAudioResourceKeyLoopEnabled: &'static CHHapticAudioResourceKey;
}
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct CHHapticEngine;
);
extern_conformance!(
unsafe impl NSObjectProtocol for CHHapticEngine {}
);
impl CHHapticEngine {
extern_methods!(
#[cfg(feature = "CHHapticDeviceCapability")]
#[unsafe(method(capabilitiesForHardware))]
#[unsafe(method_family = none)]
pub unsafe fn capabilitiesForHardware(
) -> Retained<ProtocolObject<dyn CHHapticDeviceCapability>>;
#[unsafe(method(currentTime))]
#[unsafe(method_family = none)]
pub unsafe fn currentTime(&self) -> NSTimeInterval;
#[cfg(feature = "block2")]
#[unsafe(method(stoppedHandler))]
#[unsafe(method_family = none)]
pub unsafe fn stoppedHandler(&self) -> CHHapticEngineStoppedHandler;
#[cfg(feature = "block2")]
#[unsafe(method(setStoppedHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn setStoppedHandler(&self, stopped_handler: CHHapticEngineStoppedHandler);
#[cfg(feature = "block2")]
#[unsafe(method(resetHandler))]
#[unsafe(method_family = none)]
pub unsafe fn resetHandler(&self) -> CHHapticEngineResetHandler;
#[cfg(feature = "block2")]
#[unsafe(method(setResetHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn setResetHandler(&self, reset_handler: CHHapticEngineResetHandler);
#[unsafe(method(playsHapticsOnly))]
#[unsafe(method_family = none)]
pub unsafe fn playsHapticsOnly(&self) -> bool;
#[unsafe(method(setPlaysHapticsOnly:))]
#[unsafe(method_family = none)]
pub unsafe fn setPlaysHapticsOnly(&self, plays_haptics_only: bool);
#[unsafe(method(playsAudioOnly))]
#[unsafe(method_family = none)]
pub unsafe fn playsAudioOnly(&self) -> bool;
#[unsafe(method(setPlaysAudioOnly:))]
#[unsafe(method_family = none)]
pub unsafe fn setPlaysAudioOnly(&self, plays_audio_only: bool);
#[unsafe(method(isMutedForAudio))]
#[unsafe(method_family = none)]
pub unsafe fn isMutedForAudio(&self) -> bool;
#[unsafe(method(setIsMutedForAudio:))]
#[unsafe(method_family = none)]
pub unsafe fn setIsMutedForAudio(&self, is_muted_for_audio: bool);
#[unsafe(method(isMutedForHaptics))]
#[unsafe(method_family = none)]
pub unsafe fn isMutedForHaptics(&self) -> bool;
#[unsafe(method(setIsMutedForHaptics:))]
#[unsafe(method_family = none)]
pub unsafe fn setIsMutedForHaptics(&self, is_muted_for_haptics: bool);
#[unsafe(method(isAutoShutdownEnabled))]
#[unsafe(method_family = none)]
pub unsafe fn isAutoShutdownEnabled(&self) -> bool;
#[unsafe(method(setAutoShutdownEnabled:))]
#[unsafe(method_family = none)]
pub unsafe fn setAutoShutdownEnabled(&self, auto_shutdown_enabled: bool);
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Option<Retained<Self>>;
#[unsafe(method(initAndReturnError:_))]
#[unsafe(method_family = init)]
pub unsafe fn initAndReturnError(
this: Allocated<Self>,
) -> Result<Retained<Self>, Retained<NSError>>;
#[cfg(feature = "objc2-avf-audio")]
#[unsafe(method(initWithAudioSession:error:_))]
#[unsafe(method_family = init)]
pub unsafe fn initWithAudioSession_error(
this: Allocated<Self>,
audio_session: Option<&AVAudioSession>,
) -> Result<Retained<Self>, Retained<NSError>>;
#[cfg(feature = "block2")]
#[unsafe(method(startWithCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn startWithCompletionHandler(
&self,
completion_handler: CHHapticCompletionHandler,
);
#[unsafe(method(startAndReturnError:_))]
#[unsafe(method_family = none)]
pub unsafe fn startAndReturnError(&self) -> Result<(), Retained<NSError>>;
#[cfg(feature = "block2")]
#[unsafe(method(stopWithCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn stopWithCompletionHandler(
&self,
completion_handler: CHHapticCompletionHandler,
);
#[cfg(feature = "block2")]
#[unsafe(method(notifyWhenPlayersFinished:))]
#[unsafe(method_family = none)]
pub unsafe fn notifyWhenPlayersFinished(
&self,
finished_handler: CHHapticEngineFinishedHandler,
);
#[cfg(all(feature = "CHHapticPattern", feature = "CHHapticPatternPlayer"))]
#[unsafe(method(createPlayerWithPattern:error:_))]
#[unsafe(method_family = none)]
pub unsafe fn createPlayerWithPattern_error(
&self,
pattern: &CHHapticPattern,
) -> Result<Retained<ProtocolObject<dyn CHHapticPatternPlayer>>, Retained<NSError>>;
#[cfg(all(feature = "CHHapticPattern", feature = "CHHapticPatternPlayer"))]
#[unsafe(method(createAdvancedPlayerWithPattern:error:_))]
#[unsafe(method_family = none)]
pub unsafe fn createAdvancedPlayerWithPattern_error(
&self,
pattern: &CHHapticPattern,
) -> Result<Retained<ProtocolObject<dyn CHHapticAdvancedPatternPlayer>>, Retained<NSError>>;
#[cfg(feature = "CHHapticEvent")]
#[unsafe(method(unregisterAudioResource:error:_))]
#[unsafe(method_family = none)]
pub unsafe fn unregisterAudioResource_error(
&self,
resource_id: CHHapticAudioResourceID,
) -> Result<(), Retained<NSError>>;
#[unsafe(method(playPatternFromURL:error:_))]
#[unsafe(method_family = none)]
pub unsafe fn playPatternFromURL_error(
&self,
file_url: &NSURL,
) -> Result<(), Retained<NSError>>;
#[unsafe(method(playPatternFromData:error:_))]
#[unsafe(method_family = none)]
pub unsafe fn playPatternFromData_error(
&self,
data: &NSData,
) -> Result<(), Retained<NSError>>;
);
}
impl CHHapticEngine {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}