objc2_game_controller/generated/
GCPhysicalInputSource.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9/// One or more directions associated with a
10/// `GCPhysicalInputSource.`
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcphysicalinputsourcedirection?language=objc)
13// NS_OPTIONS
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct GCPhysicalInputSourceDirection(pub NSUInteger);
17bitflags::bitflags! {
18    impl GCPhysicalInputSourceDirection: NSUInteger {
19        #[doc(alias = "GCPhysicalInputSourceDirectionNotApplicable")]
20        const NotApplicable = 0;
21        #[doc(alias = "GCPhysicalInputSourceDirectionUp")]
22        const Up = 1<<0;
23        #[doc(alias = "GCPhysicalInputSourceDirectionRight")]
24        const Right = 1<<1;
25        #[doc(alias = "GCPhysicalInputSourceDirectionDown")]
26        const Down = 1<<2;
27        #[doc(alias = "GCPhysicalInputSourceDirectionLeft")]
28        const Left = 1<<3;
29    }
30}
31
32unsafe impl Encode for GCPhysicalInputSourceDirection {
33    const ENCODING: Encoding = NSUInteger::ENCODING;
34}
35
36unsafe impl RefEncode for GCPhysicalInputSourceDirection {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40extern_protocol!(
41    /// A description of the actual physical input element that a user interacts
42    /// with to manipulate the the value of an input that is exposed to the app.
43    ///
44    /// By querying the source of an element's input that is returned from
45    /// `GCDevicePhysicalInput`or
46    /// `GCDevicePhysicalInputState,`an app
47    /// can see through element remappings applied by the user in the system
48    /// game controller settings.  For example, assuming the user has
49    /// swapped the A and B buttons in the system game controller settings...
50    ///
51    /// YES == [physicalInput.buttons[GCInputButtonA].pressedInput.source.elementAliases contains:GCInputButtonB]
52    /// YES == [physicalInput.buttons[GCInputButtonB].pressedInput.source.elementAliases contains:GCInputButtonA]
53    ///
54    /// Examining an input's source is discouraged, but may be necessary depending
55    /// on how your game's input handling code is implemented.  If possible, prefer
56    /// to load and display the
57    /// `sfSymbolsName`and
58    /// `localizedName`from the
59    /// `GCPhysicalInputElement`in any in-game U.I.
60    ///
61    /// // Use these anywhere you need to instruct the user to press the 'A'
62    /// // button in your game UI.  The symbol name and localized string
63    /// // returned will reflect the element that GCInputButtonA has been
64    /// // remapped to (Button B in the above case).
65    /// physicalInput.buttons[GCInputButtonA].localizedName
66    /// physicalInput.buttons[GCInputButtonA].sfSymbolsName
67    ///
68    ///
69    /// Note: Objects conforming to
70    /// `GCPhysicalInputSource`protocol are vended by the
71    /// GameController framework.  You should not conform to this protocol in your
72    /// own types.
73    ///
74    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcphysicalinputsource?language=objc)
75    pub unsafe trait GCPhysicalInputSource: NSObjectProtocol {
76        #[cfg(feature = "GCInputNames")]
77        /// The set of aliases for the element that the user interacts with.
78        #[unsafe(method(elementAliases))]
79        #[unsafe(method_family = none)]
80        unsafe fn elementAliases(&self) -> Retained<NSSet<NSString>>;
81
82        /// The localized name of the element that the user interacts with.
83        #[unsafe(method(elementLocalizedName))]
84        #[unsafe(method_family = none)]
85        unsafe fn elementLocalizedName(&self) -> Option<Retained<NSString>>;
86
87        /// The SF Symbol of the element that the user interacts with.
88        #[unsafe(method(sfSymbolsName))]
89        #[unsafe(method_family = none)]
90        unsafe fn sfSymbolsName(&self) -> Option<Retained<NSString>>;
91
92        /// One or more directions associated with the source.
93        #[unsafe(method(direction))]
94        #[unsafe(method_family = none)]
95        unsafe fn direction(&self) -> GCPhysicalInputSourceDirection;
96    }
97);