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
//! 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 `axis`: the element that has been modified.
///
/// Parameter `value`: the value the axis was set to at the time the valueChangedHandler fired.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gccontrolleraxisvaluechangedhandler?language=objc)
#[cfg(all(feature = "GCControllerElement", feature = "block2"))]
pub type GCControllerAxisValueChangedHandler =
*mut block2::DynBlock<dyn Fn(NonNull<GCControllerAxisInput>, c_float)>;
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gccontrolleraxisinput?language=objc)
#[unsafe(super(GCControllerElement, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "GCControllerElement")]
pub struct GCControllerAxisInput;
);
#[cfg(feature = "GCControllerElement")]
extern_conformance!(
unsafe impl NSObjectProtocol for GCControllerAxisInput {}
);
#[cfg(feature = "GCControllerElement")]
impl GCControllerAxisInput {
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) -> GCControllerAxisValueChangedHandler;
#[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: GCControllerAxisValueChangedHandler,
);
/// A normalized value for the input, between -1 and 1 for axis inputs. The values are deadzoned and saturated before they are returned
/// so there is no value ouside the range. Deadzoning does not remove values from the range, the full 0 to 1 magnitude of values
/// are possible from the input.
///
/// As an axis is often used in a digital sense, you can rely on a value of 0 meaning the axis is inside the deadzone.
/// Any value greater than or less than zero is not in the deadzone.
#[unsafe(method(value))]
#[unsafe(method_family = none)]
pub unsafe fn value(&self) -> c_float;
/// Sets the normalized value for the input.
///
///
/// 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 GCControllerAxisInput {
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>;
);
}