objc2-game-controller 0.3.2

Bindings to the GameController framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-haptics")]
#[cfg(any(target_os = "ios", target_os = "tvos", target_os = "visionos"))]
use objc2_core_haptics::*;
use objc2_foundation::*;

use crate::*;

/// A GCHapticsLocality represents the locations of haptic actuators on a controller. You can create a haptic engine with a given
/// GCHapticsLocality, and any patterns you send to that engine will play on all specified actuators.
///
/// ```text
/// CHHapticEngine *engine = [controller.haptics createEngineWithLocality:GCHapticsLocalityDefault];
/// ```
///
///
/// See: GCDeviceHaptics
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gchapticslocality?language=objc)
// NS_TYPED_ENUM
pub type GCHapticsLocality = NSString;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gchapticslocalitydefault?language=objc)
    pub static GCHapticsLocalityDefault: &'static GCHapticsLocality;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gchapticslocalityall?language=objc)
    pub static GCHapticsLocalityAll: &'static GCHapticsLocality;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gchapticslocalityhandles?language=objc)
    pub static GCHapticsLocalityHandles: &'static GCHapticsLocality;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gchapticslocalitylefthandle?language=objc)
    pub static GCHapticsLocalityLeftHandle: &'static GCHapticsLocality;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gchapticslocalityrighthandle?language=objc)
    pub static GCHapticsLocalityRightHandle: &'static GCHapticsLocality;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gchapticslocalitytriggers?language=objc)
    pub static GCHapticsLocalityTriggers: &'static GCHapticsLocality;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gchapticslocalitylefttrigger?language=objc)
    pub static GCHapticsLocalityLeftTrigger: &'static GCHapticsLocality;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gchapticslocalityrighttrigger?language=objc)
    pub static GCHapticsLocalityRightTrigger: &'static GCHapticsLocality;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gchapticdurationinfinite?language=objc)
    pub static GCHapticDurationInfinite: c_float;
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcdevicehaptics?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GCDeviceHaptics;
);

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

impl GCDeviceHaptics {
    extern_methods!(
        /// The set of supported haptic localities for this device - representing the locations of its haptic actuators.
        ///
        ///
        /// Note: GCHapticsLocalityDefault and GCHapticsLocalityAll are guaranteed to be supported - and they may be equivalent.
        ///
        ///
        /// See: GCHapticsLocality
        #[unsafe(method(supportedLocalities))]
        #[unsafe(method_family = none)]
        pub unsafe fn supportedLocalities(&self) -> Retained<NSSet<GCHapticsLocality>>;

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

        #[cfg(feature = "objc2-core-haptics")]
        #[cfg(any(target_os = "ios", target_os = "tvos", target_os = "visionos"))]
        /// Creates and returns a new instance of CHHapticEngine with a given GCHapticsLocality. Any patterns you send to this engine will play on
        /// all specified actuators.
        ///
        ///
        /// Note: Often times, it is best to use GCHapticsLocalityDefault. Engines created with the default locality will give users an expected
        /// haptic experience. On most game controllers, this will cause your haptic patterns to play on the handles. If you want to play different
        /// experiences on different actuators (for example, using the left handle actuator as a woofer and the right actuator as a tweeter), you can
        /// create multiple engines (for example, one with a GCHapticsLocalityLeftHandle locality and another with a GCHapticsLocalityRightHandle
        /// locality).
        ///
        ///
        /// See: CHHapticEngine
        ///
        /// See: GCHapticsLocality
        #[unsafe(method(createEngineWithLocality:))]
        #[unsafe(method_family = none)]
        pub unsafe fn createEngineWithLocality(
            &self,
            locality: &GCHapticsLocality,
        ) -> Option<Retained<CHHapticEngine>>;
    );
}

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