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 GCKeyboardDidConnectNotification for observing keyboard connection
    /// Use GCKeyboardDidDisconnectNotification for observing keyboard disconnection
    ///
    /// The 'object' property of the notification will contain the GCKeyboard that was connected or disconnected.
    ///
    ///
    /// See: NSNotificationCetner
    ///
    /// Note: All connected keyboards are coalesced into one keyboard object, so notification about connection/disconnection will only be delivered once until last keyboard disconnects.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gckeyboarddidconnectnotification?language=objc)
    pub static GCKeyboardDidConnectNotification: &'static NSString;
}

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

extern_class!(
    /// GCKeyboard is available to an application that links to GameController.framework
    /// There are 2 ways to access keyboard paired to the system:
    /// 1: Querying for the coalescedKeyboard using [GCKeyboard coalescedKeyboard]
    /// 2: Registering for Connection/Disconnection notifications from NSNotificationCenter
    ///
    ///
    /// Note: All connected keyboards are coalesced into one keyboard object, so notification about connection/disconnection will only be delivered once.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gckeyboard?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GCKeyboard;
);

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

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

impl GCKeyboard {
    extern_methods!(
        #[cfg(all(feature = "GCKeyboardInput", feature = "GCPhysicalInputProfile"))]
        /// Unlike GCController GCKeyboard only has one input profile.
        ///
        /// This profile allows you to query buttons and button state
        #[unsafe(method(keyboardInput))]
        #[unsafe(method_family = none)]
        pub unsafe fn keyboardInput(&self) -> Option<Retained<GCKeyboardInput>>;

        /// Keyboard object that represents all keyboards connected to the device
        /// Should be used to query key states every time input needs to be handled
        #[unsafe(method(coalescedKeyboard))]
        #[unsafe(method_family = none)]
        pub unsafe fn coalescedKeyboard() -> Option<Retained<GCKeyboard>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl GCKeyboard {
    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>;
    );
}