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        #[deprecated]
53        #[unsafe(method(valueChangedHandler))]
54        #[unsafe(method_family = none)]
55        pub unsafe fn valueChangedHandler(&self) -> GCGamepadValueChangedHandler;
56
57        #[cfg(all(feature = "GCControllerElement", feature = "block2"))]
58        /// Setter for [`valueChangedHandler`][Self::valueChangedHandler].
59        #[deprecated]
60        #[unsafe(method(setValueChangedHandler:))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn setValueChangedHandler(
63            &self,
64            value_changed_handler: GCGamepadValueChangedHandler,
65        );
66
67        #[cfg(feature = "GCGamepadSnapshot")]
68        /// Polls the state vector of the controller and saves it to a snapshot. The snapshot is stored in a device independent
69        /// format that can be serialized and used at a later date. This is useful for features such as quality assurance,
70        /// save game or replay functionality among many.
71        ///
72        /// If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as
73        /// a snapshot will not change based on user input once it is taken.
74        #[deprecated]
75        #[unsafe(method(saveSnapshot))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn saveSnapshot(&self) -> Retained<GCGamepadSnapshot>;
78
79        #[cfg(all(feature = "GCControllerDirectionPad", feature = "GCControllerElement"))]
80        /// Required to be analog in the Standard profile. All the elements of this directional input are thus analog.
81        #[deprecated]
82        #[unsafe(method(dpad))]
83        #[unsafe(method_family = none)]
84        pub unsafe fn dpad(&self) -> Retained<GCControllerDirectionPad>;
85
86        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
87        /// All face buttons are required to be analog in the Standard profile. These must be arranged
88        /// in the diamond pattern given below:
89        ///
90        /// Y
91        /// /
92        /// \
93        /// X   B
94        /// \
95        /// /
96        /// A
97        #[deprecated]
98        #[unsafe(method(buttonA))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn buttonA(&self) -> Retained<GCControllerButtonInput>;
101
102        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
103        #[deprecated]
104        #[unsafe(method(buttonB))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn buttonB(&self) -> Retained<GCControllerButtonInput>;
107
108        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
109        #[deprecated]
110        #[unsafe(method(buttonX))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn buttonX(&self) -> Retained<GCControllerButtonInput>;
113
114        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
115        #[deprecated]
116        #[unsafe(method(buttonY))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn buttonY(&self) -> Retained<GCControllerButtonInput>;
119
120        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
121        /// Shoulder buttons are required to be analog inputs.
122        #[deprecated]
123        #[unsafe(method(leftShoulder))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn leftShoulder(&self) -> Retained<GCControllerButtonInput>;
126
127        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
128        /// Shoulder buttons are required to be analog inputs.
129        #[deprecated]
130        #[unsafe(method(rightShoulder))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn rightShoulder(&self) -> Retained<GCControllerButtonInput>;
133    );
134}
135
136/// Methods declared on superclass `NSObject`.
137#[cfg(feature = "GCPhysicalInputProfile")]
138impl GCGamepad {
139    extern_methods!(
140        #[unsafe(method(init))]
141        #[unsafe(method_family = init)]
142        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
143
144        #[unsafe(method(new))]
145        #[unsafe(method_family = new)]
146        pub unsafe fn new() -> Retained<Self>;
147    );
148}