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