objc2_game_controller/generated/GCPhysicalInputProfile.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
10extern_class!(
11 /// A game controller profile representing physical buttons, thumbsticks, dpads, etc... on a controller.
12 ///
13 /// All controller profiles provide a base level of information about the controller they belong to.
14 ///
15 /// A profile maps the hardware notion of a controller into a logical controller. One that a developer can design for
16 /// and depend on, no matter the underlying hardware.
17 ///
18 /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcphysicalinputprofile?language=objc)
19 #[unsafe(super(NSObject))]
20 #[derive(Debug, PartialEq, Eq, Hash)]
21 pub struct GCPhysicalInputProfile;
22);
23
24extern_conformance!(
25 unsafe impl NSObjectProtocol for GCPhysicalInputProfile {}
26);
27
28impl GCPhysicalInputProfile {
29 extern_methods!(
30 #[cfg(feature = "GCDevice")]
31 /// A profile keeps a reference to the device that this profile is mapping input from
32 #[unsafe(method(device))]
33 #[unsafe(method_family = none)]
34 pub unsafe fn device(&self) -> Option<Retained<ProtocolObject<dyn GCDevice>>>;
35
36 /// The last time elements of this profile were updated.
37 #[unsafe(method(lastEventTimestamp))]
38 #[unsafe(method_family = none)]
39 pub unsafe fn lastEventTimestamp(&self) -> NSTimeInterval;
40
41 /// Whether the user has remapped their physical input controls for this profile at the system level.
42 ///
43 ///
44 /// On iOS and tvOS, users can remap their game controller inputs in Settings.
45 #[unsafe(method(hasRemappedElements))]
46 #[unsafe(method_family = none)]
47 pub unsafe fn hasRemappedElements(&self) -> bool;
48
49 #[cfg(all(feature = "GCControllerElement", feature = "block2"))]
50 /// Set this block if you want to be notified when a value on a element changed. If multiple elements have changed this block will be called
51 /// for each element that changed.
52 ///
53 ///
54 /// Parameter `profile`: this profile that is being used to map the raw input data into logical values on controller elements such as the dpad or the buttons.
55 ///
56 /// Parameter `element`: the element that has been modified.
57 ///
58 /// # Safety
59 ///
60 /// - The returned block's argument 1 must be a valid pointer.
61 /// - The returned block's argument 2 must be a valid pointer.
62 #[unsafe(method(valueDidChangeHandler))]
63 #[unsafe(method_family = none)]
64 pub unsafe fn valueDidChangeHandler(
65 &self,
66 ) -> *mut block2::DynBlock<
67 dyn Fn(NonNull<GCPhysicalInputProfile>, NonNull<GCControllerElement>),
68 >;
69
70 #[cfg(all(feature = "GCControllerElement", feature = "block2"))]
71 /// Setter for [`valueDidChangeHandler`][Self::valueDidChangeHandler].
72 ///
73 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
74 #[unsafe(method(setValueDidChangeHandler:))]
75 #[unsafe(method_family = none)]
76 pub unsafe fn setValueDidChangeHandler(
77 &self,
78 value_did_change_handler: Option<
79 &block2::DynBlock<
80 dyn Fn(NonNull<GCPhysicalInputProfile>, NonNull<GCControllerElement>),
81 >,
82 >,
83 );
84
85 #[cfg(feature = "GCControllerElement")]
86 /// The following properties allow for runtime lookup of any input element on a profile, when provided with a valid alias.
87 #[unsafe(method(elements))]
88 #[unsafe(method_family = none)]
89 pub unsafe fn elements(&self) -> Retained<NSDictionary<NSString, GCControllerElement>>;
90
91 #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
92 #[unsafe(method(buttons))]
93 #[unsafe(method_family = none)]
94 pub unsafe fn buttons(&self) -> Retained<NSDictionary<NSString, GCControllerButtonInput>>;
95
96 #[cfg(all(feature = "GCControllerAxisInput", feature = "GCControllerElement"))]
97 #[unsafe(method(axes))]
98 #[unsafe(method_family = none)]
99 pub unsafe fn axes(&self) -> Retained<NSDictionary<NSString, GCControllerAxisInput>>;
100
101 #[cfg(all(feature = "GCControllerDirectionPad", feature = "GCControllerElement"))]
102 #[unsafe(method(dpads))]
103 #[unsafe(method_family = none)]
104 pub unsafe fn dpads(&self) -> Retained<NSDictionary<NSString, GCControllerDirectionPad>>;
105
106 #[cfg(all(feature = "GCControllerElement", feature = "GCControllerTouchpad"))]
107 #[unsafe(method(touchpads))]
108 #[unsafe(method_family = none)]
109 pub unsafe fn touchpads(&self) -> Retained<NSDictionary<NSString, GCControllerTouchpad>>;
110
111 #[cfg(feature = "GCControllerElement")]
112 /// The following properties allow for dynamic querying of the input elements available on a profile.
113 #[unsafe(method(allElements))]
114 #[unsafe(method_family = none)]
115 pub unsafe fn allElements(&self) -> Retained<NSSet<GCControllerElement>>;
116
117 #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
118 #[unsafe(method(allButtons))]
119 #[unsafe(method_family = none)]
120 pub unsafe fn allButtons(&self) -> Retained<NSSet<GCControllerButtonInput>>;
121
122 #[cfg(all(feature = "GCControllerAxisInput", feature = "GCControllerElement"))]
123 #[unsafe(method(allAxes))]
124 #[unsafe(method_family = none)]
125 pub unsafe fn allAxes(&self) -> Retained<NSSet<GCControllerAxisInput>>;
126
127 #[cfg(all(feature = "GCControllerDirectionPad", feature = "GCControllerElement"))]
128 #[unsafe(method(allDpads))]
129 #[unsafe(method_family = none)]
130 pub unsafe fn allDpads(&self) -> Retained<NSSet<GCControllerDirectionPad>>;
131
132 #[cfg(all(feature = "GCControllerElement", feature = "GCControllerTouchpad"))]
133 #[unsafe(method(allTouchpads))]
134 #[unsafe(method_family = none)]
135 pub unsafe fn allTouchpads(&self) -> Retained<NSSet<GCControllerTouchpad>>;
136
137 #[cfg(feature = "GCControllerElement")]
138 /// Profile elements can be accessed using keyed subscript notation, with a valid alias of its inputs.
139 ///
140 ///
141 ///
142 ///
143 /// Note: Equivalent to -elements
144 #[unsafe(method(objectForKeyedSubscript:))]
145 #[unsafe(method_family = none)]
146 pub unsafe fn objectForKeyedSubscript(
147 &self,
148 key: &NSString,
149 ) -> Option<Retained<GCControllerElement>>;
150
151 /// Polls the state vector of the physical input input and saves it to a new and writable instance of GCPhysicalInputProfile.
152 ///
153 /// If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as
154 /// a snapshot will not change based on user input once it is taken.
155 ///
156 ///
157 /// See: snapshot
158 ///
159 /// Returns: A new physical input profile with the duplicated state vector of the current physical input
160 #[unsafe(method(capture))]
161 #[unsafe(method_family = none)]
162 pub unsafe fn capture(&self) -> Retained<Self>;
163
164 /// Sets the state vector of the physical input profile to a copy of the passed in physical input profile's state vector.
165 ///
166 ///
167 /// Note: If the controller's snapshot flag is set to NO, this method has no effect.
168 ///
169 /// See: GCController.snapshot
170 #[unsafe(method(setStateFromPhysicalInput:))]
171 #[unsafe(method_family = none)]
172 pub unsafe fn setStateFromPhysicalInput(&self, physical_input: &GCPhysicalInputProfile);
173
174 /// Returns the primary alias of the GCControllerElement that a given physical input maps to.
175 ///
176 ///
177 /// If the user were to map a physical press of the A button of their game controller to the B button, then
178 /// -[GCPhysicalInputProfile mappedElementAliasForPhysicalInputName: GCInputButtonA] would return GCInputButtonB.
179 /// Note that mappings can change anytime your app is backgrounded, so make sure you update any relevant visuals when
180 /// returning to foreground.
181 ///
182 ///
183 /// Parameter `inputName`: A GCInput string corresponding to the physical button you want the mapped element alias for.
184 ///
185 ///
186 /// Returns: A GCInput string corresponding to the primary alias of the GCControllerElement that a given physical button maps to, or nil if there is no mapping.
187 #[unsafe(method(mappedElementAliasForPhysicalInputName:))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn mappedElementAliasForPhysicalInputName(
190 &self,
191 input_name: &NSString,
192 ) -> Retained<NSString>;
193
194 /// Returns a set of GCInput strings corresponding to physical inputs that are mapped to a given GCControllerElement.
195 ///
196 ///
197 /// If the user mapped the physical press of the A button, the B button, and the X button to the B button, then
198 /// -[GCPhysicalInputProfile mappedPhysicalInputNamesForElementAlias: GCInputButtonB] would return [GCInputButtonA, GCInputButtonB, GCInputButtonX].
199 /// Note that mappings can change anytime your app is backgrounded, so make sure you update any relevant visuals when
200 /// returning to foreground.
201 ///
202 ///
203 /// Parameter `elementAlias`: A GCInput string corresponding to an alias of the GCControllerElement you want the physical buttons for.
204 ///
205 ///
206 /// Returns: A set of GCInput strings corresponding to physical inputs that are mapped to a given GCControllerElement, or an empty set if there are no mappings.
207 #[unsafe(method(mappedPhysicalInputNamesForElementAlias:))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn mappedPhysicalInputNamesForElementAlias(
210 &self,
211 element_alias: &NSString,
212 ) -> Retained<NSSet<NSString>>;
213 );
214}
215
216/// Methods declared on superclass `NSObject`.
217impl GCPhysicalInputProfile {
218 extern_methods!(
219 #[unsafe(method(init))]
220 #[unsafe(method_family = init)]
221 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
222
223 #[unsafe(method(new))]
224 #[unsafe(method_family = new)]
225 pub unsafe fn new() -> Retained<Self>;
226 );
227}