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

/// One or more directions associated with a
/// `GCPhysicalInputSource.`
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcphysicalinputsourcedirection?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GCPhysicalInputSourceDirection(pub NSUInteger);
bitflags::bitflags! {
    impl GCPhysicalInputSourceDirection: NSUInteger {
        #[doc(alias = "GCPhysicalInputSourceDirectionNotApplicable")]
        const NotApplicable = 0;
        #[doc(alias = "GCPhysicalInputSourceDirectionUp")]
        const Up = 1<<0;
        #[doc(alias = "GCPhysicalInputSourceDirectionRight")]
        const Right = 1<<1;
        #[doc(alias = "GCPhysicalInputSourceDirectionDown")]
        const Down = 1<<2;
        #[doc(alias = "GCPhysicalInputSourceDirectionLeft")]
        const Left = 1<<3;
    }
}

unsafe impl Encode for GCPhysicalInputSourceDirection {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for GCPhysicalInputSourceDirection {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_protocol!(
    /// A description of the actual physical input element that a user interacts
    /// with to manipulate the the value of an input that is exposed to the app.
    ///
    /// By querying the source of an element's input that is returned from
    /// `GCDevicePhysicalInput`or
    /// `GCDevicePhysicalInputState,`an app
    /// can see through element remappings applied by the user in the system
    /// game controller settings.  For example, assuming the user has
    /// swapped the A and B buttons in the system game controller settings...
    ///
    /// YES == [physicalInput.buttons[GCInputButtonA].pressedInput.source.elementAliases contains:GCInputButtonB]
    /// YES == [physicalInput.buttons[GCInputButtonB].pressedInput.source.elementAliases contains:GCInputButtonA]
    ///
    /// Examining an input's source is discouraged, but may be necessary depending
    /// on how your game's input handling code is implemented.  If possible, prefer
    /// to load and display the
    /// `sfSymbolsName`and
    /// `localizedName`from the
    /// `GCPhysicalInputElement`in any in-game U.I.
    ///
    /// // Use these anywhere you need to instruct the user to press the 'A'
    /// // button in your game UI.  The symbol name and localized string
    /// // returned will reflect the element that GCInputButtonA has been
    /// // remapped to (Button B in the above case).
    /// physicalInput.buttons[GCInputButtonA].localizedName
    /// physicalInput.buttons[GCInputButtonA].sfSymbolsName
    ///
    ///
    /// Note: Objects conforming to
    /// `GCPhysicalInputSource`protocol are vended by the
    /// GameController framework.  You should not conform to this protocol in your
    /// own types.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcphysicalinputsource?language=objc)
    pub unsafe trait GCPhysicalInputSource: NSObjectProtocol {
        #[cfg(feature = "GCInputNames")]
        /// The set of aliases for the element that the user interacts with.
        #[unsafe(method(elementAliases))]
        #[unsafe(method_family = none)]
        unsafe fn elementAliases(&self) -> Retained<NSSet<NSString>>;

        /// The localized name of the element that the user interacts with.
        #[unsafe(method(elementLocalizedName))]
        #[unsafe(method_family = none)]
        unsafe fn elementLocalizedName(&self) -> Option<Retained<NSString>>;

        /// The SF Symbol of the element that the user interacts with.
        #[unsafe(method(sfSymbolsName))]
        #[unsafe(method_family = none)]
        unsafe fn sfSymbolsName(&self) -> Option<Retained<NSString>>;

        /// One or more directions associated with the source.
        #[unsafe(method(direction))]
        #[unsafe(method_family = none)]
        unsafe fn direction(&self) -> GCPhysicalInputSourceDirection;
    }
);