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::Block<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")]
90unsafe impl NSObjectProtocol for GCMicroGamepad {}
91
92#[cfg(feature = "GCPhysicalInputProfile")]
93impl GCMicroGamepad {
94 extern_methods!(
95 #[cfg(feature = "GCController")]
96 #[unsafe(method(controller))]
97 #[unsafe(method_family = none)]
98 pub unsafe fn controller(&self) -> Option<Retained<GCController>>;
99
100 #[cfg(all(feature = "GCControllerElement", feature = "block2"))]
101 #[unsafe(method(valueChangedHandler))]
102 #[unsafe(method_family = none)]
103 pub unsafe fn valueChangedHandler(&self) -> GCMicroGamepadValueChangedHandler;
104
105 #[cfg(all(feature = "GCControllerElement", feature = "block2"))]
106 /// Setter for [`valueChangedHandler`][Self::valueChangedHandler].
107 #[unsafe(method(setValueChangedHandler:))]
108 #[unsafe(method_family = none)]
109 pub unsafe fn setValueChangedHandler(
110 &self,
111 value_changed_handler: GCMicroGamepadValueChangedHandler,
112 );
113
114 #[cfg(feature = "GCMicroGamepadSnapshot")]
115 /// Polls the state vector of the controller and saves it to a snapshot. The snapshot is stored in a device independent
116 /// format that can be serialized and used at a later date. This is useful for features such as quality assurance,
117 /// save game or replay functionality among many.
118 ///
119 /// If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as
120 /// a snapshot will not change based on user input once it is taken.
121 ///
122 ///
123 /// See: GCMicroGamepadSnapshot
124 #[deprecated = "GCMicroGamepadSnapshot has been deprecated, use [GCController capture] instead"]
125 #[unsafe(method(saveSnapshot))]
126 #[unsafe(method_family = none)]
127 pub unsafe fn saveSnapshot(&self) -> Retained<GCMicroGamepadSnapshot>;
128
129 #[cfg(all(feature = "GCControllerDirectionPad", feature = "GCControllerElement"))]
130 /// Optionally analog in the Micro profile. All the elements of this directional input are either analog or digital.
131 #[unsafe(method(dpad))]
132 #[unsafe(method_family = none)]
133 pub unsafe fn dpad(&self) -> Retained<GCControllerDirectionPad>;
134
135 #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
136 /// The Micro profile has two buttons that are optionally analog in the Micro profile.
137 /// Button A is the primary action button, it indicates affirmative action and should be used to advance in menus
138 /// or perform the primary action in gameplay.
139 #[unsafe(method(buttonA))]
140 #[unsafe(method_family = none)]
141 pub unsafe fn buttonA(&self) -> Retained<GCControllerButtonInput>;
142
143 #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
144 /// Button X is the secondary action button, it indicates an alternate affirmative action and should be used to perform
145 /// a secondary action. If there is no secondary action it should be used as equivalent to buttonA.
146 ///
147 /// Unlike on other profiles there is no negative button on this profile. Instead the menu button should be
148 /// used to present menu content or to retreat in a menu flow.
149 ///
150 /// See: buttonA
151 #[unsafe(method(buttonX))]
152 #[unsafe(method_family = none)]
153 pub unsafe fn buttonX(&self) -> Retained<GCControllerButtonInput>;
154
155 #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
156 /// Button menu is the primary menu button, and should be used to enter the main menu and pause the game.
157 #[unsafe(method(buttonMenu))]
158 #[unsafe(method_family = none)]
159 pub unsafe fn buttonMenu(&self) -> Retained<GCControllerButtonInput>;
160
161 /// 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.
162 ///
163 /// 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.
164 ///
165 /// 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.
166 ///
167 /// The default value for this property is NO, meaning a sliding window is used for the dpad.
168 #[unsafe(method(reportsAbsoluteDpadValues))]
169 #[unsafe(method_family = none)]
170 pub unsafe fn reportsAbsoluteDpadValues(&self) -> bool;
171
172 /// Setter for [`reportsAbsoluteDpadValues`][Self::reportsAbsoluteDpadValues].
173 #[unsafe(method(setReportsAbsoluteDpadValues:))]
174 #[unsafe(method_family = none)]
175 pub unsafe fn setReportsAbsoluteDpadValues(&self, reports_absolute_dpad_values: bool);
176
177 /// 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.
178 ///
179 /// The default value for this property is NO.
180 #[unsafe(method(allowsRotation))]
181 #[unsafe(method_family = none)]
182 pub unsafe fn allowsRotation(&self) -> bool;
183
184 /// Setter for [`allowsRotation`][Self::allowsRotation].
185 #[unsafe(method(setAllowsRotation:))]
186 #[unsafe(method_family = none)]
187 pub unsafe fn setAllowsRotation(&self, allows_rotation: bool);
188
189 /// Sets the state vector of the micro gamepad to a copy of the input micro gamepad's state vector.
190 ///
191 ///
192 /// Note: If the controller's snapshot flag is set to NO, this method has no effect.
193 ///
194 /// See: GCController.snapshot
195 #[unsafe(method(setStateFromMicroGamepad:))]
196 #[unsafe(method_family = none)]
197 pub unsafe fn setStateFromMicroGamepad(&self, micro_gamepad: &GCMicroGamepad);
198 );
199}
200
201/// Methods declared on superclass `NSObject`.
202#[cfg(feature = "GCPhysicalInputProfile")]
203impl GCMicroGamepad {
204 extern_methods!(
205 #[unsafe(method(init))]
206 #[unsafe(method_family = init)]
207 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
208
209 #[unsafe(method(new))]
210 #[unsafe(method_family = new)]
211 pub unsafe fn new() -> Retained<Self>;
212 );
213}