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_protocol!(
    /// The
    /// `GCPhysicalInputElement`protocol is a base protocol for specific types
    /// of elements that represent controls on a device.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcphysicalinputelement?language=objc)
    pub unsafe trait GCPhysicalInputElement: NSObjectProtocol {
        /// The set of aliases that can be used to access this element with keyed subscript
        /// notation.
        #[unsafe(method(aliases))]
        #[unsafe(method_family = none)]
        unsafe fn aliases(&self) -> Retained<NSSet<NSString>>;

        /// The element's localized display name.
        ///
        /// This is the string that your app should display in any on-screen messages
        /// instructing the user to interact with the control.  For example:
        ///
        /// "Press \(buttonA.localizedName) to jump!"
        ///
        /// Do not cache this value - it can change when the user remaps controls.
        #[unsafe(method(localizedName))]
        #[unsafe(method_family = none)]
        unsafe fn localizedName(&self) -> Option<Retained<NSString>>;

        /// The SF Symbols name for the element.
        #[unsafe(method(sfSymbolsName))]
        #[unsafe(method_family = none)]
        unsafe fn sfSymbolsName(&self) -> Option<Retained<NSString>>;
    }
);

extern_class!(
    /// An instance of
    /// `GCPhysicalInputElementCollection`contains the collection of
    /// input elements found in a device's physical input profile.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcphysicalinputelementcollection?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GCPhysicalInputElementCollection<
        Key: ?Sized = AnyObject,
        Element: ?Sized = AnyObject,
    >;
);

impl<
        Key: ?Sized + Message + AsRef<NSString>,
        Element: ?Sized + Message + GCPhysicalInputElement,
    > GCPhysicalInputElementCollection<Key, Element>
{
    /// Unchecked conversion of the generic parameters.
    ///
    /// # Safety
    ///
    /// The generics must be valid to reinterpret as the given types.
    #[inline]
    pub unsafe fn cast_unchecked<
        NewKey: ?Sized + Message + AsRef<NSString>,
        NewElement: ?Sized + Message + GCPhysicalInputElement,
    >(
        &self,
    ) -> &GCPhysicalInputElementCollection<NewKey, NewElement> {
        unsafe { &*((self as *const Self).cast()) }
    }
}

extern_conformance!(
    unsafe impl<Key: ?Sized + AsRef<NSString>, Element: ?Sized + GCPhysicalInputElement>
        NSFastEnumeration for GCPhysicalInputElementCollection<Key, Element>
    {
    }
);

extern_conformance!(
    unsafe impl<Key: ?Sized + AsRef<NSString>, Element: ?Sized + GCPhysicalInputElement>
        NSObjectProtocol for GCPhysicalInputElementCollection<Key, Element>
    {
    }
);

impl<Key: Message + AsRef<NSString>, Element: Message + GCPhysicalInputElement>
    GCPhysicalInputElementCollection<Key, Element>
{
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

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

        /// The number of elements in the collection.
        #[unsafe(method(count))]
        #[unsafe(method_family = none)]
        pub unsafe fn count(&self) -> NSUInteger;

        /// Returns the element associated with a given alias.
        ///
        ///
        /// Parameter `alias`: The alias for which to return the corresponding element.  Typically, you
        /// pass one of the constants defined in
        /// `GCInputNames.h.`
        /// Returns: The element associated with
        /// _alias,_or nil if no element is associated
        /// with
        /// _alias._
        #[unsafe(method(elementForAlias:))]
        #[unsafe(method_family = none)]
        pub unsafe fn elementForAlias(&self, alias: &Key) -> Option<Retained<Element>>;

        #[unsafe(method(objectForKeyedSubscript:))]
        #[unsafe(method_family = none)]
        pub unsafe fn objectForKeyedSubscript(&self, key: &Key) -> Option<Retained<Element>>;

        /// # Safety
        ///
        /// The returned enumerator's underlying collection should not be mutated while in use.
        #[unsafe(method(elementEnumerator))]
        #[unsafe(method_family = none)]
        pub unsafe fn elementEnumerator(&self) -> Retained<NSEnumerator<Element>>;
    );
}