objc2_game_controller/generated/
GCGamepad.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/gcgamepadvaluechangedhandler?language=objc)
19#[cfg(all(
20    feature = "GCControllerElement",
21    feature = "GCPhysicalInputProfile",
22    feature = "block2"
23))]
24pub type GCGamepadValueChangedHandler =
25    *mut block2::DynBlock<dyn Fn(NonNull<GCGamepad>, NonNull<GCControllerElement>)>;
26
27extern_class!(
28    /// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcgamepad?language=objc)
29    #[unsafe(super(GCPhysicalInputProfile, NSObject))]
30    #[derive(Debug, PartialEq, Eq, Hash)]
31    #[cfg(feature = "GCPhysicalInputProfile")]
32    #[deprecated]
33    pub struct GCGamepad;
34);
35
36#[cfg(feature = "GCPhysicalInputProfile")]
37extern_conformance!(
38    unsafe impl NSObjectProtocol for GCGamepad {}
39);
40
41#[cfg(feature = "GCPhysicalInputProfile")]
42impl GCGamepad {
43    extern_methods!(
44        #[cfg(feature = "GCController")]
45        /// A profile keeps a reference to the controller that this profile is mapping input from.
46        #[deprecated]
47        #[unsafe(method(controller))]
48        #[unsafe(method_family = none)]
49        pub unsafe fn controller(&self) -> Option<Retained<GCController>>;
50
51        #[cfg(all(feature = "GCControllerElement", feature = "block2"))]
52        /// # Safety
53        ///
54        /// - The returned block's argument 1 must be a valid pointer.
55        /// - The returned block's argument 2 must be a valid pointer.
56        #[deprecated]
57        #[unsafe(method(valueChangedHandler))]
58        #[unsafe(method_family = none)]
59        pub unsafe fn valueChangedHandler(&self) -> GCGamepadValueChangedHandler;
60
61        #[cfg(all(feature = "GCControllerElement", feature = "block2"))]
62        /// Setter for [`valueChangedHandler`][Self::valueChangedHandler].
63        ///
64        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
65        ///
66        /// # Safety
67        ///
68        /// `value_changed_handler` must be a valid pointer or null.
69        #[deprecated]
70        #[unsafe(method(setValueChangedHandler:))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn setValueChangedHandler(
73            &self,
74            value_changed_handler: GCGamepadValueChangedHandler,
75        );
76
77        #[cfg(feature = "GCGamepadSnapshot")]
78        /// Polls the state vector of the controller and saves it to a snapshot. The snapshot is stored in a device independent
79        /// format that can be serialized and used at a later date. This is useful for features such as quality assurance,
80        /// save game or replay functionality among many.
81        ///
82        /// If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as
83        /// a snapshot will not change based on user input once it is taken.
84        #[deprecated]
85        #[unsafe(method(saveSnapshot))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn saveSnapshot(&self) -> Retained<GCGamepadSnapshot>;
88
89        #[cfg(all(feature = "GCControllerDirectionPad", feature = "GCControllerElement"))]
90        /// Required to be analog in the Standard profile. All the elements of this directional input are thus analog.
91        #[deprecated]
92        #[unsafe(method(dpad))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn dpad(&self) -> Retained<GCControllerDirectionPad>;
95
96        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
97        /// All face buttons are required to be analog in the Standard profile. These must be arranged
98        /// in the diamond pattern given below:
99        ///
100        /// Y
101        /// /
102        /// \
103        /// X   B
104        /// \
105        /// /
106        /// A
107        #[deprecated]
108        #[unsafe(method(buttonA))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn buttonA(&self) -> Retained<GCControllerButtonInput>;
111
112        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
113        #[deprecated]
114        #[unsafe(method(buttonB))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn buttonB(&self) -> Retained<GCControllerButtonInput>;
117
118        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
119        #[deprecated]
120        #[unsafe(method(buttonX))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn buttonX(&self) -> Retained<GCControllerButtonInput>;
123
124        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
125        #[deprecated]
126        #[unsafe(method(buttonY))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn buttonY(&self) -> Retained<GCControllerButtonInput>;
129
130        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
131        /// Shoulder buttons are required to be analog inputs.
132        #[deprecated]
133        #[unsafe(method(leftShoulder))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn leftShoulder(&self) -> Retained<GCControllerButtonInput>;
136
137        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
138        /// Shoulder buttons are required to be analog inputs.
139        #[deprecated]
140        #[unsafe(method(rightShoulder))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn rightShoulder(&self) -> Retained<GCControllerButtonInput>;
143    );
144}
145
146/// Methods declared on superclass `NSObject`.
147#[cfg(feature = "GCPhysicalInputProfile")]
148impl GCGamepad {
149    extern_methods!(
150        #[unsafe(method(init))]
151        #[unsafe(method_family = init)]
152        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
153
154        #[unsafe(method(new))]
155        #[unsafe(method_family = new)]
156        pub unsafe fn new() -> Retained<Self>;
157    );
158}