objc2_game_controller/generated/GCMicroGamepad.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 "C" {
11 /// The primary directional input surface for the directional gamepad
12 ///
13 ///
14 /// Note: Equivalent to microgamepad.dpad
15 ///
16 ///
17 /// Note: For the 1st generation and 2nd generation Siri Remotes, this represents touching anywhere on the entire touch surface.
18 ///
19 /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcinputmicrogamepaddpad?language=objc)
20 pub static GCInputMicroGamepadDpad: &'static NSString;
21}
22
23extern "C" {
24 /// The primary button for the microgamepad
25 ///
26 ///
27 /// Note: For the 1st generation and 2nd generation Siri Remotes, this represents pressing anywhere on the touch surface.
28 ///
29 /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcinputmicrogamepadbuttona?language=objc)
30 pub static GCInputMicroGamepadButtonA: &'static NSString;
31}
32
33extern "C" {
34 /// The secondary button for the microgamepad
35 ///
36 ///
37 /// Note: Equivalent to microgamepad.buttonX
38 ///
39 ///
40 /// Note: For the 1st and 2nd generation Siri Remotes, this represents pressing the play/pause button.
41 ///
42 /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcinputmicrogamepadbuttonx?language=objc)
43 pub static GCInputMicroGamepadButtonX: &'static NSString;
44}
45
46extern "C" {
47 /// The primary menu button for the microgamepad
48 ///
49 ///
50 /// Note: Equivalent to microgamepad.buttonMenu
51 ///
52 ///
53 /// Note: For the 1st generation Siri Remote, this represents pressing the play/pause button. For the 2nd generation Siri Remote, this represents pressing the back button.
54 ///
55 ///
56 /// Note: You should avoid polling this button every frame. tvOS will run a gesture recognizer on events before forwarding them to your application that can reduce the window
57 /// to poll button changes. Instead, register a pressedChangedHandler or a valueChangedHandler.
58 ///
59 /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcinputmicrogamepadbuttonmenu?language=objc)
60 pub static GCInputMicroGamepadButtonMenu: &'static NSString;
61}
62
63/// 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
64/// for each element that changed. As elements in a collection, such as the axis in a dpad, tend to change at the same time and thus
65/// will only call this once with the collection as the element.
66///
67///
68/// Parameter `gamepad`: this gamepad that is being used to map the raw input data into logical values on controller elements such as the dpad or the buttons.
69///
70/// Parameter `element`: the element that has been modified.
71///
72/// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcmicrogamepadvaluechangedhandler?language=objc)
73#[cfg(all(
74 feature = "GCControllerElement",
75 feature = "GCPhysicalInputProfile",
76 feature = "block2"
77))]
78pub type GCMicroGamepadValueChangedHandler =
79 *mut block2::DynBlock<dyn Fn(NonNull<GCMicroGamepad>, NonNull<GCControllerElement>)>;
80
81extern_class!(
82 /// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcmicrogamepad?language=objc)
83 #[unsafe(super(GCPhysicalInputProfile, NSObject))]
84 #[derive(Debug, PartialEq, Eq, Hash)]
85 #[cfg(feature = "GCPhysicalInputProfile")]
86 pub struct GCMicroGamepad;
87);
88
89#[cfg(feature = "GCPhysicalInputProfile")]
90extern_conformance!(
91 unsafe impl NSObjectProtocol for GCMicroGamepad {}
92);
93
94#[cfg(feature = "GCPhysicalInputProfile")]
95impl GCMicroGamepad {
96 extern_methods!(
97 #[cfg(feature = "GCController")]
98 /// A profile keeps a reference to the controller that this profile is mapping input from.
99 #[unsafe(method(controller))]
100 #[unsafe(method_family = none)]
101 pub unsafe fn controller(&self) -> Option<Retained<GCController>>;
102
103 #[cfg(all(feature = "GCControllerElement", feature = "block2"))]
104 /// # Safety
105 ///
106 /// - The returned block's argument 1 must be a valid pointer.
107 /// - The returned block's argument 2 must be a valid pointer.
108 #[unsafe(method(valueChangedHandler))]
109 #[unsafe(method_family = none)]
110 pub unsafe fn valueChangedHandler(&self) -> GCMicroGamepadValueChangedHandler;
111
112 #[cfg(all(feature = "GCControllerElement", feature = "block2"))]
113 /// Setter for [`valueChangedHandler`][Self::valueChangedHandler].
114 ///
115 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
116 ///
117 /// # Safety
118 ///
119 /// `value_changed_handler` must be a valid pointer or null.
120 #[unsafe(method(setValueChangedHandler:))]
121 #[unsafe(method_family = none)]
122 pub unsafe fn setValueChangedHandler(
123 &self,
124 value_changed_handler: GCMicroGamepadValueChangedHandler,
125 );
126
127 #[cfg(feature = "GCMicroGamepadSnapshot")]
128 /// Polls the state vector of the controller and saves it to a snapshot. The snapshot is stored in a device independent
129 /// format that can be serialized and used at a later date. This is useful for features such as quality assurance,
130 /// save game or replay functionality among many.
131 ///
132 /// If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as
133 /// a snapshot will not change based on user input once it is taken.
134 ///
135 ///
136 /// See: GCMicroGamepadSnapshot
137 #[deprecated = "Use the -[GCController capture] method instead"]
138 #[unsafe(method(saveSnapshot))]
139 #[unsafe(method_family = none)]
140 pub unsafe fn saveSnapshot(&self) -> Retained<GCMicroGamepadSnapshot>;
141
142 #[cfg(all(feature = "GCControllerDirectionPad", feature = "GCControllerElement"))]
143 /// Optionally analog in the Micro profile. All the elements of this directional input are either analog or digital.
144 #[unsafe(method(dpad))]
145 #[unsafe(method_family = none)]
146 pub unsafe fn dpad(&self) -> Retained<GCControllerDirectionPad>;
147
148 #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
149 /// The Micro profile has two buttons that are optionally analog in the Micro profile.
150 /// Button A is the primary action button, it indicates affirmative action and should be used to advance in menus
151 /// or perform the primary action in gameplay.
152 #[unsafe(method(buttonA))]
153 #[unsafe(method_family = none)]
154 pub unsafe fn buttonA(&self) -> Retained<GCControllerButtonInput>;
155
156 #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
157 /// Button X is the secondary action button, it indicates an alternate affirmative action and should be used to perform
158 /// a secondary action. If there is no secondary action it should be used as equivalent to buttonA.
159 ///
160 /// Unlike on other profiles there is no negative button on this profile. Instead the menu button should be
161 /// used to present menu content or to retreat in a menu flow.
162 ///
163 /// See: buttonA
164 #[unsafe(method(buttonX))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn buttonX(&self) -> Retained<GCControllerButtonInput>;
167
168 #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
169 /// Button menu is the primary menu button, and should be used to enter the main menu and pause the game.
170 #[unsafe(method(buttonMenu))]
171 #[unsafe(method_family = none)]
172 pub unsafe fn buttonMenu(&self) -> Retained<GCControllerButtonInput>;
173
174 /// The Micro profile can use the raw position values of the touchpad on the remote as D-pad values, or it can create a virtual dpad centered around the first contact point with the surface.
175 ///
176 /// If NO; a smaller sliding window is created around the initial touch point and subsequent movement is relative to that center. Movement outside the window will slide the window with it to re-center it. This is great for surfaces where there is no clear sense of a middle and drift over time is an issue.
177 ///
178 /// If YES; the absolute values are used and any drift will have to managed manually either through user traning or by a developer using the dpad.
179 ///
180 /// The default value for this property is NO, meaning a sliding window is used for the dpad.
181 #[unsafe(method(reportsAbsoluteDpadValues))]
182 #[unsafe(method_family = none)]
183 pub unsafe fn reportsAbsoluteDpadValues(&self) -> bool;
184
185 /// Setter for [`reportsAbsoluteDpadValues`][Self::reportsAbsoluteDpadValues].
186 #[unsafe(method(setReportsAbsoluteDpadValues:))]
187 #[unsafe(method_family = none)]
188 pub unsafe fn setReportsAbsoluteDpadValues(&self, reports_absolute_dpad_values: bool);
189
190 /// Allows the Micro profile to monitor the orientation of the controller, if the controller is positioned in landscape orientation, D-pad input values will be transposed 90 degrees to match the new orientation.
191 ///
192 /// The default value for this property is NO.
193 #[unsafe(method(allowsRotation))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn allowsRotation(&self) -> bool;
196
197 /// Setter for [`allowsRotation`][Self::allowsRotation].
198 #[unsafe(method(setAllowsRotation:))]
199 #[unsafe(method_family = none)]
200 pub unsafe fn setAllowsRotation(&self, allows_rotation: bool);
201
202 /// Sets the state vector of the micro gamepad to a copy of the input micro gamepad's state vector.
203 ///
204 ///
205 /// Note: If the controller's snapshot flag is set to NO, this method has no effect.
206 ///
207 /// See: GCController.snapshot
208 #[unsafe(method(setStateFromMicroGamepad:))]
209 #[unsafe(method_family = none)]
210 pub unsafe fn setStateFromMicroGamepad(&self, micro_gamepad: &GCMicroGamepad);
211 );
212}
213
214/// Methods declared on superclass `NSObject`.
215#[cfg(feature = "GCPhysicalInputProfile")]
216impl GCMicroGamepad {
217 extern_methods!(
218 #[unsafe(method(init))]
219 #[unsafe(method_family = init)]
220 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
221
222 #[unsafe(method(new))]
223 #[unsafe(method_family = new)]
224 pub unsafe fn new() -> Retained<Self>;
225 );
226}