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
//! 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 axis changes.
///
///
/// Parameter `dpad`: the direction pad collection whose axis have been modified.
///
/// Parameter `xValue`: the value the x axis was set to at the time the valueChangedHandler fired.
///
/// Parameter `yValue`: the value the y axis was set to at the time the valueChangedHandler fired.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gccontrollerdirectionpadvaluechangedhandler?language=objc)
#[cfg(all(feature = "GCControllerElement", feature = "block2"))]
pub type GCControllerDirectionPadValueChangedHandler =
*mut block2::DynBlock<dyn Fn(NonNull<GCControllerDirectionPad>, c_float, c_float)>;
extern_class!(
/// A direction pad is a common grouping of 2 axis inputs where the input can also be interpreted as 2 sets of mutually exclusive button pairs.
/// Only one button in each pair, {up, down} and {left, right}, can be pressed at any one time.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gccontrollerdirectionpad?language=objc)
#[unsafe(super(GCControllerElement, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "GCControllerElement")]
pub struct GCControllerDirectionPad;
);
#[cfg(feature = "GCControllerElement")]
extern_conformance!(
unsafe impl NSObjectProtocol for GCControllerDirectionPad {}
);
#[cfg(feature = "GCControllerElement")]
impl GCControllerDirectionPad {
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) -> GCControllerDirectionPadValueChangedHandler;
#[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: GCControllerDirectionPadValueChangedHandler,
);
#[cfg(feature = "GCControllerAxisInput")]
#[unsafe(method(xAxis))]
#[unsafe(method_family = none)]
pub unsafe fn xAxis(&self) -> Retained<GCControllerAxisInput>;
#[cfg(feature = "GCControllerAxisInput")]
#[unsafe(method(yAxis))]
#[unsafe(method_family = none)]
pub unsafe fn yAxis(&self) -> Retained<GCControllerAxisInput>;
#[cfg(feature = "GCControllerButtonInput")]
#[unsafe(method(up))]
#[unsafe(method_family = none)]
pub unsafe fn up(&self) -> Retained<GCControllerButtonInput>;
#[cfg(feature = "GCControllerButtonInput")]
#[unsafe(method(down))]
#[unsafe(method_family = none)]
pub unsafe fn down(&self) -> Retained<GCControllerButtonInput>;
#[cfg(feature = "GCControllerButtonInput")]
#[unsafe(method(left))]
#[unsafe(method_family = none)]
pub unsafe fn left(&self) -> Retained<GCControllerButtonInput>;
#[cfg(feature = "GCControllerButtonInput")]
#[unsafe(method(right))]
#[unsafe(method_family = none)]
pub unsafe fn right(&self) -> Retained<GCControllerButtonInput>;
/// Sets the normalized value for the direction pad's axis inputs. Will update the states of the direction pad's button inputs as well.
///
///
/// Parameter `xAxis`: the value to set the xAxis of the touchpad to.
///
/// Parameter `yAxis`: the value to set the yAxis of the touchpad to.
///
/// Note: If the controller's snapshot flag is set to NO, this method has no effect.
///
/// See: value
///
/// See: pressed
#[unsafe(method(setValueForXAxis:yAxis:))]
#[unsafe(method_family = none)]
pub unsafe fn setValueForXAxis_yAxis(&self, x_axis: c_float, y_axis: c_float);
);
}
/// Methods declared on superclass `NSObject`.
#[cfg(feature = "GCControllerElement")]
impl GCControllerDirectionPad {
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>;
);
}