objc2_game_controller/generated/
GCExtendedGamepad.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::*;
6
7use crate::*;
8
9/// 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
10/// 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
11/// will only call this once with the collection as the element.
12///
13///
14/// 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.
15///
16/// Parameter `element`: the element that has been modified.
17///
18/// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcextendedgamepadvaluechangedhandler?language=objc)
19#[cfg(all(
20    feature = "GCControllerElement",
21    feature = "GCPhysicalInputProfile",
22    feature = "block2"
23))]
24pub type GCExtendedGamepadValueChangedHandler =
25    *mut block2::DynBlock<dyn Fn(NonNull<GCExtendedGamepad>, NonNull<GCControllerElement>)>;
26
27extern_class!(
28    /// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcextendedgamepad?language=objc)
29    #[unsafe(super(GCPhysicalInputProfile, NSObject))]
30    #[derive(Debug, PartialEq, Eq, Hash)]
31    #[cfg(feature = "GCPhysicalInputProfile")]
32    pub struct GCExtendedGamepad;
33);
34
35#[cfg(feature = "GCPhysicalInputProfile")]
36extern_conformance!(
37    unsafe impl NSObjectProtocol for GCExtendedGamepad {}
38);
39
40#[cfg(feature = "GCPhysicalInputProfile")]
41impl GCExtendedGamepad {
42    extern_methods!(
43        #[cfg(feature = "GCController")]
44        /// A profile keeps a reference to the controller that this profile is mapping input from.
45        #[unsafe(method(controller))]
46        #[unsafe(method_family = none)]
47        pub unsafe fn controller(&self) -> Option<Retained<GCController>>;
48
49        #[cfg(all(feature = "GCControllerElement", feature = "block2"))]
50        /// # Safety
51        ///
52        /// - The returned block's argument 1 must be a valid pointer.
53        /// - The returned block's argument 2 must be a valid pointer.
54        #[unsafe(method(valueChangedHandler))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn valueChangedHandler(&self) -> GCExtendedGamepadValueChangedHandler;
57
58        #[cfg(all(feature = "GCControllerElement", feature = "block2"))]
59        /// Setter for [`valueChangedHandler`][Self::valueChangedHandler].
60        ///
61        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
62        ///
63        /// # Safety
64        ///
65        /// `value_changed_handler` must be a valid pointer or null.
66        #[unsafe(method(setValueChangedHandler:))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn setValueChangedHandler(
69            &self,
70            value_changed_handler: GCExtendedGamepadValueChangedHandler,
71        );
72
73        #[cfg(feature = "GCExtendedGamepadSnapshot")]
74        /// Polls the state vector of the controller and saves it to a snapshot. The snapshot is stored in a device independent
75        /// format that can be serialized and used at a later date. This is useful for features such as quality assurance,
76        /// save game or replay functionality among many.
77        ///
78        /// If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as
79        /// a snapshot will not change based on user input once it is taken.
80        #[deprecated = "Use the -[GCController capture] method instead"]
81        #[unsafe(method(saveSnapshot))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn saveSnapshot(&self) -> Retained<GCExtendedGamepadSnapshot>;
84
85        #[cfg(all(feature = "GCControllerDirectionPad", feature = "GCControllerElement"))]
86        /// Required to be analog in the Extended profile. All the elements of this directional input are thus analog.
87        #[unsafe(method(dpad))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn dpad(&self) -> Retained<GCControllerDirectionPad>;
90
91        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
92        /// All face buttons are required to be analog in the Extended profile. These must be arranged
93        /// in the diamond pattern given below:
94        ///
95        /// Y
96        /// /
97        /// \
98        /// X   B
99        /// \
100        /// /
101        /// A
102        #[unsafe(method(buttonA))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn buttonA(&self) -> Retained<GCControllerButtonInput>;
105
106        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
107        #[unsafe(method(buttonB))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn buttonB(&self) -> Retained<GCControllerButtonInput>;
110
111        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
112        #[unsafe(method(buttonX))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn buttonX(&self) -> Retained<GCControllerButtonInput>;
115
116        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
117        #[unsafe(method(buttonY))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn buttonY(&self) -> Retained<GCControllerButtonInput>;
120
121        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
122        /// Button menu is the primary menu button, and should be used to enter the main menu and pause the game.
123        #[unsafe(method(buttonMenu))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn buttonMenu(&self) -> Retained<GCControllerButtonInput>;
126
127        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
128        /// Button options is the secondary menu button. It should be used to enter a secondary menu, such as graphics and sound configuration, and pause the game.
129        #[unsafe(method(buttonOptions))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn buttonOptions(&self) -> Option<Retained<GCControllerButtonInput>>;
132
133        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
134        /// Button home is a special menu button. If the system does not consume button home events, they will be passed to your application and should be used to enter a secondary menu, and pause the game.
135        #[unsafe(method(buttonHome))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn buttonHome(&self) -> Option<Retained<GCControllerButtonInput>>;
138
139        #[cfg(all(feature = "GCControllerDirectionPad", feature = "GCControllerElement"))]
140        /// A thumbstick is a 2-axis control that is physically required to be analog. All the elements of this directional input are thus analog.
141        #[unsafe(method(leftThumbstick))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn leftThumbstick(&self) -> Retained<GCControllerDirectionPad>;
144
145        #[cfg(all(feature = "GCControllerDirectionPad", feature = "GCControllerElement"))]
146        /// A thumbstick is a 2-axis control that is physically required to be analog. All the elements of this directional input are thus analog.
147        #[unsafe(method(rightThumbstick))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn rightThumbstick(&self) -> Retained<GCControllerDirectionPad>;
150
151        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
152        /// Shoulder buttons are required to be analog inputs.
153        #[unsafe(method(leftShoulder))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn leftShoulder(&self) -> Retained<GCControllerButtonInput>;
156
157        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
158        /// Shoulder buttons are required to be analog inputs.
159        #[unsafe(method(rightShoulder))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn rightShoulder(&self) -> Retained<GCControllerButtonInput>;
162
163        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
164        /// Triggers are required to be analog inputs. Common uses would be acceleration and decelleration in a driving game for example.
165        #[unsafe(method(leftTrigger))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn leftTrigger(&self) -> Retained<GCControllerButtonInput>;
168
169        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
170        #[unsafe(method(rightTrigger))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn rightTrigger(&self) -> Retained<GCControllerButtonInput>;
173
174        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
175        /// A thumbstick may also have a clickable component, which is treated as a non-analog button.
176        #[unsafe(method(leftThumbstickButton))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn leftThumbstickButton(&self) -> Option<Retained<GCControllerButtonInput>>;
179
180        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
181        #[unsafe(method(rightThumbstickButton))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn rightThumbstickButton(&self) -> Option<Retained<GCControllerButtonInput>>;
184
185        /// Sets the state vector of the extended gamepad to a copy of the input extended gamepad's state vector.
186        ///
187        ///
188        /// Note: If the controller's snapshot flag is set to NO, this method has no effect.
189        ///
190        /// See: GCController.snapshot
191        #[unsafe(method(setStateFromExtendedGamepad:))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn setStateFromExtendedGamepad(&self, extended_gamepad: &GCExtendedGamepad);
194    );
195}
196
197/// Methods declared on superclass `NSObject`.
198#[cfg(feature = "GCPhysicalInputProfile")]
199impl GCExtendedGamepad {
200    extern_methods!(
201        #[unsafe(method(init))]
202        #[unsafe(method_family = init)]
203        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
204
205        #[unsafe(method(new))]
206        #[unsafe(method_family = new)]
207        pub unsafe fn new() -> Retained<Self>;
208    );
209}