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
64extern_conformance!(
65    unsafe impl NSObjectProtocol for GCControllerElement {}
66);
67
68impl GCControllerElement {
69    extern_methods!(
70        /// Each element can be part of a wider collection of inputs that map to a single logical element. A directional pad (dpad)
71        /// is a logical collection of two axis inputs and thus each axis belongs to the same collection element - the dpad.
72        #[unsafe(method(collection))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn collection(&self) -> Option<Retained<GCControllerElement>>;
75
76        /// Check if the element can support more than just digital values, such as decimal ranges between 0 and 1.
77        /// Defaults to YES for most elements.
78        #[unsafe(method(isAnalog))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn isAnalog(&self) -> bool;
81
82        /// Check if the element is bound to a system gesture.
83        /// Defaults to NO for most elements.
84        ///
85        ///
86        /// See: preferredSystemGestureState
87        ///
88        /// See: GCSystemGestureState
89        #[unsafe(method(isBoundToSystemGesture))]
90        #[unsafe(method_family = none)]
91        pub unsafe fn isBoundToSystemGesture(&self) -> bool;
92
93        /// The preferred system gesture state for this element.
94        /// Defaults to GCSystemGestureStateEnabled for most elements
95        ///
96        ///
97        /// Note: This is merely the preferred system gesture state - it is not guaranteed to be respected by the system.
98        ///
99        /// Note: It is highly recommended to leave this set to the default value, however there may be situations (for example, game
100        /// streaming apps) where it is preferrable to disable system gestures.
101        ///
102        /// See: boundToSystemGesture
103        #[unsafe(method(preferredSystemGestureState))]
104        #[unsafe(method_family = none)]
105        pub unsafe fn preferredSystemGestureState(&self) -> GCSystemGestureState;
106
107        /// Setter for [`preferredSystemGestureState`][Self::preferredSystemGestureState].
108        #[unsafe(method(setPreferredSystemGestureState:))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn setPreferredSystemGestureState(
111            &self,
112            preferred_system_gesture_state: GCSystemGestureState,
113        );
114
115        /// The element's SF Symbols name, taking input remapping into account.
116        ///
117        ///
118        /// Note: In almost all instances, you should use this over unmappedSfSymbolsName in your UI.
119        #[unsafe(method(sfSymbolsName))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn sfSymbolsName(&self) -> Option<Retained<NSString>>;
122
123        /// Setter for [`sfSymbolsName`][Self::sfSymbolsName].
124        #[unsafe(method(setSfSymbolsName:))]
125        #[unsafe(method_family = none)]
126        pub unsafe fn setSfSymbolsName(&self, sf_symbols_name: Option<&NSString>);
127
128        /// The element's localized name, taking input remapping into account.
129        ///
130        ///
131        /// Note: In almost all instances, you should use this over unmappedLocalizedName in your UI.
132        #[unsafe(method(localizedName))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn localizedName(&self) -> Option<Retained<NSString>>;
135
136        /// Setter for [`localizedName`][Self::localizedName].
137        #[unsafe(method(setLocalizedName:))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn setLocalizedName(&self, localized_name: Option<&NSString>);
140
141        /// The element's SF Symbols name, not taking any input remapping into account.
142        ///
143        ///
144        /// 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).
145        #[unsafe(method(unmappedSfSymbolsName))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn unmappedSfSymbolsName(&self) -> Option<Retained<NSString>>;
148
149        /// Setter for [`unmappedSfSymbolsName`][Self::unmappedSfSymbolsName].
150        #[unsafe(method(setUnmappedSfSymbolsName:))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn setUnmappedSfSymbolsName(&self, unmapped_sf_symbols_name: Option<&NSString>);
153
154        /// The element's localized name, not taking any input remapping into account.
155        ///
156        ///
157        /// 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).
158        #[unsafe(method(unmappedLocalizedName))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn unmappedLocalizedName(&self) -> Option<Retained<NSString>>;
161
162        /// Setter for [`unmappedLocalizedName`][Self::unmappedLocalizedName].
163        #[unsafe(method(setUnmappedLocalizedName:))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn setUnmappedLocalizedName(&self, unmapped_localized_name: Option<&NSString>);
166
167        /// A set of aliases that can be used to access this element with keyed subscript notation.
168        #[unsafe(method(aliases))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn aliases(&self) -> Retained<NSSet<NSString>>;
171    );
172}
173
174/// Methods declared on superclass `NSObject`.
175impl GCControllerElement {
176    extern_methods!(
177        #[unsafe(method(init))]
178        #[unsafe(method_family = init)]
179        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
180
181        #[unsafe(method(new))]
182        #[unsafe(method_family = new)]
183        pub unsafe fn new() -> Retained<Self>;
184    );
185}