objc2_game_controller/generated/
GCControllerElement.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// Elements on a GCDevice can be used for system gestures. The system gesture state represents how input is handled in the app
11/// for a controller element that is bound to a system gesture.
12///
13///
14/// the control of the app. If a user presses the Options button, the system gesture recognizer will run by default. If a long press is detected,
15/// input will not be forwarded to your app (your application won't see the Options button was pressed at all). If a long press is not detected,
16/// input will be forwared to your app, with a delay.
17///
18/// If you do not want any delay in receiving input for this element, you have two options
19/// - Set the preferred state of the element to GCSystemGestureStateAlwaysReceive. The system gesture recognize will run
20/// concurrently with input being sent to your app. This removes input delay, but can lead to system gestures being triggered
21/// simulatenously with in-app actions.
22/// - Set the preferred state of the element to GCSystemGestureStateDisabled. This will disable the system gesture recognizer - your app
23/// will receive full control of the input for this element.
24///
25///
26/// See: GCControllerElement.boundToSystemGesture
27///
28/// See: GCControllerElement.preferredSystemGestureState
29///
30/// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcsystemgesturestate?language=objc)
31// NS_ENUM
32#[repr(transparent)]
33#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
34pub struct GCSystemGestureState(pub NSInteger);
35impl GCSystemGestureState {
36    /// System gesture recognizers will run before input is sent to app, this is the default state
37    #[doc(alias = "GCSystemGestureStateEnabled")]
38    pub const Enabled: Self = Self(0);
39    /// Input is sent to app and processed by system gesture recognizers simultaneously
40    #[doc(alias = "GCSystemGestureStateAlwaysReceive")]
41    pub const AlwaysReceive: Self = Self(1);
42    /// System gesture recognizers will not run at all. Input is passed directly to app
43    #[doc(alias = "GCSystemGestureStateDisabled")]
44    pub const Disabled: Self = Self(2);
45}
46
47unsafe impl Encode for GCSystemGestureState {
48    const ENCODING: Encoding = NSInteger::ENCODING;
49}
50
51unsafe impl RefEncode for GCSystemGestureState {
52    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
53}
54
55extern_class!(
56    /// Every controller element knows which collection it belongs to and whether its input value is analog or digital.
57    ///
58    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gccontrollerelement?language=objc)
59    #[unsafe(super(NSObject))]
60    #[derive(Debug, PartialEq, Eq, Hash)]
61    pub struct GCControllerElement;
62);
63
64unsafe impl NSObjectProtocol for GCControllerElement {}
65
66impl GCControllerElement {
67    extern_methods!(
68        /// Each element can be part of a wider collection of inputs that map to a single logical element. A directional pad (dpad)
69        /// is a logical collection of two axis inputs and thus each axis belongs to the same collection element - the dpad.
70        #[unsafe(method(collection))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn collection(&self) -> Option<Retained<GCControllerElement>>;
73
74        /// Check if the element can support more than just digital values, such as decimal ranges between 0 and 1.
75        /// Defaults to YES for most elements.
76        #[unsafe(method(isAnalog))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn isAnalog(&self) -> bool;
79
80        /// Check if the element is bound to a system gesture.
81        /// Defaults to NO for most elements.
82        ///
83        ///
84        /// See: preferredSystemGestureState
85        ///
86        /// See: GCSystemGestureState
87        #[unsafe(method(isBoundToSystemGesture))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn isBoundToSystemGesture(&self) -> bool;
90
91        /// The preferred system gesture state for this element.
92        /// Defaults to GCSystemGestureStateEnabled for most elements
93        ///
94        ///
95        /// Note: This is merely the preferred system gesture state - it is not guaranteed to be respected by the system.
96        ///
97        /// Note: It is highly recommended to leave this set to the default value, however there may be situations (for example, game
98        /// streaming apps) where it is preferrable to disable system gestures.
99        ///
100        /// See: boundToSystemGesture
101        #[unsafe(method(preferredSystemGestureState))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn preferredSystemGestureState(&self) -> GCSystemGestureState;
104
105        /// Setter for [`preferredSystemGestureState`][Self::preferredSystemGestureState].
106        #[unsafe(method(setPreferredSystemGestureState:))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn setPreferredSystemGestureState(
109            &self,
110            preferred_system_gesture_state: GCSystemGestureState,
111        );
112
113        /// The element's SF Symbols name, taking input remapping into account.
114        ///
115        ///
116        /// Note: In almost all instances, you should use this over unmappedSfSymbolsName in your UI.
117        #[unsafe(method(sfSymbolsName))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn sfSymbolsName(&self) -> Option<Retained<NSString>>;
120
121        /// Setter for [`sfSymbolsName`][Self::sfSymbolsName].
122        #[unsafe(method(setSfSymbolsName:))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn setSfSymbolsName(&self, sf_symbols_name: Option<&NSString>);
125
126        /// The element's localized name, taking input remapping into account.
127        ///
128        ///
129        /// Note: In almost all instances, you should use this over unmappedLocalizedName in your UI.
130        #[unsafe(method(localizedName))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn localizedName(&self) -> Option<Retained<NSString>>;
133
134        /// Setter for [`localizedName`][Self::localizedName].
135        #[unsafe(method(setLocalizedName:))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn setLocalizedName(&self, localized_name: Option<&NSString>);
138
139        /// The element's SF Symbols name, not taking any input remapping into account.
140        ///
141        ///
142        /// Note: Use this in your games own remapping UI, or when you need to prompt a user that a given button has no mapping (sfSymbolsName is nil).
143        #[unsafe(method(unmappedSfSymbolsName))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn unmappedSfSymbolsName(&self) -> Option<Retained<NSString>>;
146
147        /// Setter for [`unmappedSfSymbolsName`][Self::unmappedSfSymbolsName].
148        #[unsafe(method(setUnmappedSfSymbolsName:))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn setUnmappedSfSymbolsName(&self, unmapped_sf_symbols_name: Option<&NSString>);
151
152        /// The element's localized name, not taking any input remapping into account.
153        ///
154        ///
155        /// Note: Use this in your games own remapping UI, or when you need to prompt a user that a given button has no mapping (localizedName is nil).
156        #[unsafe(method(unmappedLocalizedName))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn unmappedLocalizedName(&self) -> Option<Retained<NSString>>;
159
160        /// Setter for [`unmappedLocalizedName`][Self::unmappedLocalizedName].
161        #[unsafe(method(setUnmappedLocalizedName:))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn setUnmappedLocalizedName(&self, unmapped_localized_name: Option<&NSString>);
164
165        /// A set of aliases that can be used to access this element with keyed subscript notation.
166        #[unsafe(method(aliases))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn aliases(&self) -> Retained<NSSet<NSString>>;
169    );
170}
171
172/// Methods declared on superclass `NSObject`.
173impl GCControllerElement {
174    extern_methods!(
175        #[unsafe(method(init))]
176        #[unsafe(method_family = init)]
177        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
178
179        #[unsafe(method(new))]
180        #[unsafe(method_family = new)]
181        pub unsafe fn new() -> Retained<Self>;
182    );
183}