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