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