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

/// Set this block if you want to be notified when the mouse was moved
///
/// Parameter `mouse`: this mouse that is being used for input
///
/// Parameter `deltaX`: the value of raw mouse delta along x axis. Not affected by mouse sensitivity settings
///
/// Parameter `deltaY`: the value of raw mouse delta along y axis. Not affected by mouse sensitivity settings
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcmousemoved?language=objc)
#[cfg(all(feature = "GCPhysicalInputProfile", feature = "block2"))]
pub type GCMouseMoved = *mut block2::DynBlock<dyn Fn(NonNull<GCMouseInput>, c_float, c_float)>;

extern_class!(
    /// Mouse profile that represent a physical mouse object with two axis cursor, two axis scroll,
    /// left button, optional right and middle buttons and optional set of auxiliary buttons.
    ///
    /// It only provides information about raw mouse movement deltas. For the valid cursor position
    /// at given point in time, use UIHoverGestureRecognizer and NSEvent.mouseLocation.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcmouseinput?language=objc)
    #[unsafe(super(GCPhysicalInputProfile, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "GCPhysicalInputProfile")]
    pub struct GCMouseInput;
);

#[cfg(feature = "GCPhysicalInputProfile")]
extern_conformance!(
    unsafe impl NSObjectProtocol for GCMouseInput {}
);

#[cfg(feature = "GCPhysicalInputProfile")]
impl GCMouseInput {
    extern_methods!(
        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// The returned block's argument 1 must be a valid pointer.
        #[unsafe(method(mouseMovedHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn mouseMovedHandler(&self) -> GCMouseMoved;

        #[cfg(feature = "block2")]
        /// Setter for [`mouseMovedHandler`][Self::mouseMovedHandler].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `mouse_moved_handler` must be a valid pointer or null.
        #[unsafe(method(setMouseMovedHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMouseMovedHandler(&self, mouse_moved_handler: GCMouseMoved);

        #[cfg(all(
            feature = "GCControllerDirectionPad",
            feature = "GCControllerElement",
            feature = "GCDeviceCursor"
        ))]
        /// Scroll is a dpad with undefined range.
        #[unsafe(method(scroll))]
        #[unsafe(method_family = none)]
        pub unsafe fn scroll(&self) -> Retained<GCDeviceCursor>;

        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
        /// Mouse buttons that can be used only as digital inputs
        #[unsafe(method(leftButton))]
        #[unsafe(method_family = none)]
        pub unsafe fn leftButton(&self) -> Retained<GCControllerButtonInput>;

        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
        #[unsafe(method(rightButton))]
        #[unsafe(method_family = none)]
        pub unsafe fn rightButton(&self) -> Option<Retained<GCControllerButtonInput>>;

        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
        #[unsafe(method(middleButton))]
        #[unsafe(method_family = none)]
        pub unsafe fn middleButton(&self) -> Option<Retained<GCControllerButtonInput>>;

        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
        #[unsafe(method(auxiliaryButtons))]
        #[unsafe(method_family = none)]
        pub unsafe fn auxiliaryButtons(&self)
            -> Option<Retained<NSArray<GCControllerButtonInput>>>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "GCPhysicalInputProfile")]
impl GCMouseInput {
    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>;
    );
}