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::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 GCMouseDidConnectNotification for observing connections of mice.
    /// Use GCMouserDidDisconnectNotification for observing disconnections of mice.
    ///
    /// Connections and disconnections of mice will also be reflected in the mice array
    /// of the GCMouse class.
    ///
    /// The 'object' property of the notification will contain the GCMouse that was connected or disconnected.
    /// For example:
    ///
    /// - (void)controllerDidConnect:(NSNotification *)note {
    ///
    /// GCMouse *mouse = note.object;
    ///
    /// ....
    /// }
    ///
    ///
    /// See: NSNotificationCenter
    ///
    /// See: GCMouse.mice
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcmousedidconnectnotification?language=objc)
    pub static GCMouseDidConnectNotification: &'static NSString;
}

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

extern "C" {
    /// Use these constants with NSNotificationCenter to listen to a controller becoming the most recently used mouse.
    /// This is a good time to swap out UI to match the new current mouse, and unregister any handlers with
    /// the old current controller.
    ///
    /// The 'object' property of the notification will contain the GCMouse that became the current one.
    /// For example:
    ///
    /// - (void)mouseDidBecomeCurrent:(NSNotification *)note {
    ///
    /// GCMouse *mouse = note.object;
    ///
    /// ...
    /// }
    ///
    /// See: NSNotificationCenter
    ///
    /// See: GCMouse.mice
    ///
    /// See: GCMouse.current
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcmousedidbecomecurrentnotification?language=objc)
    pub static GCMouseDidBecomeCurrentNotification: &'static NSString;
}

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

extern_class!(
    /// Mice are available to an application that links to GameController.framework. There are 2 ways to access mice
    /// paired to the system. Adopt both to ensure the best user experience:
    ///
    /// 1: Querying for the current array of mice using [GCMouse mice]
    /// 2: Registering for Connection/Disconnection notifications from NSNotificationCenter.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcmouse?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GCMouse;
);

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

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

impl GCMouse {
    extern_methods!(
        #[cfg(all(feature = "GCMouseInput", feature = "GCPhysicalInputProfile"))]
        /// Unlike GCController GCMouse supports only one input profile
        /// Profile contains mouse buttons, scroll wheel and  pointer delta.
        #[unsafe(method(mouseInput))]
        #[unsafe(method_family = none)]
        pub unsafe fn mouseInput(&self) -> Option<Retained<GCMouseInput>>;

        /// The most recently used mouse device. If a user actuates a mouse input, that mouse will become the current one.
        ///
        /// See: GCMouseDidBecomeCurrentNotification
        ///
        /// See: GCMouseDidStopBeingCurrentNotification
        #[unsafe(method(current))]
        #[unsafe(method_family = none)]
        pub unsafe fn current() -> Option<Retained<GCMouse>>;

        #[unsafe(method(mice))]
        #[unsafe(method_family = none)]
        pub unsafe fn mice() -> Retained<NSArray<GCMouse>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl GCMouse {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}