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::*;
use objc2_foundation::*;

use crate::*;

extern "C" {
    /// Use these constants with NSNotificationCenter to listen to connection and disconnection events.
    ///
    /// Use GCRacingWheelDidConnectNotification for observing connections of racing wheels.
    /// Use GCRacingWheelDidDisconnectNotification for observing disconnections of racing wheels.
    ///
    /// Connections and disconnections of racing wheels will also be reflected in the connectedRacingWheels array
    /// of the GCRacingWheel class.
    ///
    /// The 'object' property of the notification will contain the GCRacingWheel that was connected or disconnected.
    /// For example:
    ///
    /// - (void)wheelDidConnect:(NSNotification *)note {
    /// GCRacingWheel *controller = note.object;
    /// ....
    /// }
    ///
    ///
    /// See: NSNotificationCenter
    ///
    /// See: GCRacingWheel.connectedRacingWheels
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcracingwheeldidconnectnotification?language=objc)
    pub static GCRacingWheelDidConnectNotification: &'static NSString;
}

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

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

#[cfg(feature = "GCDevice")]
extern_conformance!(
    unsafe impl GCDevice for GCRacingWheel {}
);

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

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

        /// Get the collection of racing wheels currently attached to the system.
        ///
        ///
        /// See: GCRacingWheelDidConnectNotification
        ///
        /// See: GCRacingWheelDidDisconnectNotification
        #[unsafe(method(connectedRacingWheels))]
        #[unsafe(method_family = none)]
        pub unsafe fn connectedRacingWheels() -> Retained<NSSet<GCRacingWheel>>;

        /// A GCRacingWheel must be acquired before your application can begin receiving
        /// events from it.  Prior to acquisition, your application may only query the
        /// properties of the racing wheel.  Acquisition is exclusive and may fail.
        #[unsafe(method(acquireDeviceWithError:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn acquireDeviceWithError(&self) -> Result<(), Retained<NSError>>;

        /// Releases a previous acquisition of the racing wheel.
        #[unsafe(method(relinquishDevice))]
        #[unsafe(method_family = none)]
        pub unsafe fn relinquishDevice(&self);

        /// Checks if the racing wheel has been acquired by the application.
        ///
        /// This property is observable.
        #[unsafe(method(isAcquired))]
        #[unsafe(method_family = none)]
        pub unsafe fn isAcquired(&self) -> bool;

        #[cfg(feature = "GCRacingWheelInput")]
        /// Get the physical input profile for the racing wheel.
        #[unsafe(method(wheelInput))]
        #[unsafe(method_family = none)]
        pub unsafe fn wheelInput(&self) -> Retained<GCRacingWheelInput>;

        /// A GCRacingWheel may represent a real device managed by the operating system,
        /// or a snapshot created by the developer.
        ///
        ///
        /// See: capture
        #[unsafe(method(isSnapshot))]
        #[unsafe(method_family = none)]
        pub unsafe fn isSnapshot(&self) -> bool;

        /// Polls the state vector of the racing wheel and saves it to a new instance of
        /// GCRacingWheel.
        ///
        /// If your application is heavily multithreaded this may also be useful to
        /// guarantee atomicity of input handling as a snapshot will not change based on
        /// user input once it is taken.
        ///
        ///
        /// See: snapshot
        ///
        /// Returns: A new racing wheel with the duplicated state vector of the receiver.
        #[unsafe(method(capture))]
        #[unsafe(method_family = none)]
        pub unsafe fn capture(&self) -> Retained<GCRacingWheel>;
    );
}

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