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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
//! 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 the value on this button changes.
///
///
/// Parameter `button`: the element that has been modified.
///
/// Parameter `value`: the value the button was set to at the time the valueChangedHandler fired.
///
/// Parameter `pressed`: the pressed state of the button at the time the valueChangedHandler fired.
///
/// See: value
///
/// See: pressed
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gccontrollerbuttonvaluechangedhandler?language=objc)
#[cfg(all(feature = "GCControllerElement", feature = "block2"))]
pub type GCControllerButtonValueChangedHandler =
*mut block2::DynBlock<dyn Fn(NonNull<GCControllerButtonInput>, c_float, Bool)>;
/// Set this block if you want to be notified when the touched state on this button changes.
///
///
/// Parameter `button`: the element that has been modified.
///
/// Parameter `value`: the value the button was set to at the time the valueChangedHandler fired.
///
/// Parameter `pressed`: the pressed state of the button at the time the valueChangedHandler fired.
///
/// Parameter `touched`: the touched state of the button at the time the valueChangedHandler fired.
///
/// See: value
///
/// See: pressed
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gccontrollerbuttontouchedchangedhandler?language=objc)
#[cfg(all(feature = "GCControllerElement", feature = "block2"))]
pub type GCControllerButtonTouchedChangedHandler =
*mut block2::DynBlock<dyn Fn(NonNull<GCControllerButtonInput>, c_float, Bool, Bool)>;
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gccontrollerbuttoninput?language=objc)
#[unsafe(super(GCControllerElement, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "GCControllerElement")]
pub struct GCControllerButtonInput;
);
#[cfg(feature = "GCControllerElement")]
extern_conformance!(
unsafe impl NSObjectProtocol for GCControllerButtonInput {}
);
#[cfg(feature = "GCControllerElement")]
impl GCControllerButtonInput {
extern_methods!(
#[cfg(feature = "block2")]
/// # Safety
///
/// The returned block's argument 1 must be a valid pointer.
#[unsafe(method(valueChangedHandler))]
#[unsafe(method_family = none)]
pub unsafe fn valueChangedHandler(&self) -> GCControllerButtonValueChangedHandler;
#[cfg(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.
#[unsafe(method(setValueChangedHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn setValueChangedHandler(
&self,
value_changed_handler: GCControllerButtonValueChangedHandler,
);
#[cfg(feature = "block2")]
/// Set this block if you want to be notified when only the pressed state on this button changes. This
/// will get called less often than the valueChangedHandler with the additional feature of the pressed state
/// being different to the last time it was called.
///
/// # Safety
///
/// The returned block's argument 1 must be a valid pointer.
#[unsafe(method(pressedChangedHandler))]
#[unsafe(method_family = none)]
pub unsafe fn pressedChangedHandler(&self) -> GCControllerButtonValueChangedHandler;
#[cfg(feature = "block2")]
/// Setter for [`pressedChangedHandler`][Self::pressedChangedHandler].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
///
/// # Safety
///
/// `pressed_changed_handler` must be a valid pointer or null.
#[unsafe(method(setPressedChangedHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn setPressedChangedHandler(
&self,
pressed_changed_handler: GCControllerButtonValueChangedHandler,
);
#[cfg(feature = "block2")]
/// # Safety
///
/// The returned block's argument 1 must be a valid pointer.
#[unsafe(method(touchedChangedHandler))]
#[unsafe(method_family = none)]
pub unsafe fn touchedChangedHandler(&self) -> GCControllerButtonTouchedChangedHandler;
#[cfg(feature = "block2")]
/// Setter for [`touchedChangedHandler`][Self::touchedChangedHandler].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
///
/// # Safety
///
/// `touched_changed_handler` must be a valid pointer or null.
#[unsafe(method(setTouchedChangedHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn setTouchedChangedHandler(
&self,
touched_changed_handler: GCControllerButtonTouchedChangedHandler,
);
/// A normalized value for the input. Between 0 and 1 for button inputs. Values are saturated and thus never exceed the range of [0, 1].
///
/// See: valueChangedHandler
///
/// See: pressed
#[unsafe(method(value))]
#[unsafe(method_family = none)]
pub unsafe fn value(&self) -> c_float;
/// Buttons are mostly used in a digital sense, thus we have a recommended method for checking for pressed state instead of
/// interpreting the value.
///
/// As a general guideline a button is pressed if the value exceeds 0. However there may be hysterisis applied
/// to counter noisy input values, thus incidental values around the threshold value may not trigger a change
/// in pressed state.
///
/// Others buttons may support two-stage actuation, where the button reports a value between 0 and 1 but is only considered
/// pressed when its value is greater than some threshold other than 0.
///
/// See: pressedChangedHandler
///
/// See: value
#[unsafe(method(isPressed))]
#[unsafe(method_family = none)]
pub unsafe fn isPressed(&self) -> bool;
/// Some buttons feature capacitive touch capabilities where the user can touch the button
/// without pressing it. In such cases, a button will be touched before it is pressed.
///
/// For buttons without capacitive sensing, the touched state is true if the value exceeds 0.
///
///
/// See: touchChangedHandler
///
/// See: pressed
#[unsafe(method(isTouched))]
#[unsafe(method_family = none)]
pub unsafe fn isTouched(&self) -> bool;
/// Sets the normalized value for the button input. Will update the pressed state of the button.
///
///
/// Parameter `value`: the value to set the input to.
///
/// Note: If the controller's snapshot flag is set to NO, this method has no effect.
///
/// See: value
#[unsafe(method(setValue:))]
#[unsafe(method_family = none)]
pub unsafe fn setValue(&self, value: c_float);
);
}
/// Methods declared on superclass `NSObject`.
#[cfg(feature = "GCControllerElement")]
impl GCControllerButtonInput {
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>;
);
}