objc2_game_controller/generated/GCAxis2DInput.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_protocol!(
11 /// An object conforming to
12 /// `GCAxis2DInput`represents an input that produces a
13 /// pair of normalized values - between [-1, 1] - along two axes with fixed origin.
14 /// The origin - a value of 0 - corresponds the neutral state of the input.
15 ///
16 /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcaxis2dinput?language=objc)
17 pub unsafe trait GCAxis2DInput: NSObjectProtocol {
18 #[cfg(all(
19 feature = "GCPhysicalInputElement",
20 feature = "GCTypes",
21 feature = "block2"
22 ))]
23 /// Set this block to be notified when the value of the axis input changes.
24 ///
25 ///
26 /// Parameter `element`: the element that has been modified.
27 ///
28 /// Parameter `input`: the input that has been modified.
29 ///
30 /// Parameter `value`: the value the axis was set to at the time the valueChangedHandler fired.
31 ///
32 /// # Safety
33 ///
34 /// - The returned block's argument 1 must be a valid pointer.
35 /// - The returned block's argument 2 must be a valid pointer.
36 #[unsafe(method(valueDidChangeHandler))]
37 #[unsafe(method_family = none)]
38 unsafe fn valueDidChangeHandler(
39 &self,
40 ) -> *mut block2::DynBlock<
41 dyn Fn(
42 NonNull<ProtocolObject<dyn GCPhysicalInputElement>>,
43 NonNull<ProtocolObject<dyn GCAxis2DInput>>,
44 GCPoint2,
45 ),
46 >;
47
48 #[cfg(all(
49 feature = "GCPhysicalInputElement",
50 feature = "GCTypes",
51 feature = "block2"
52 ))]
53 /// Setter for [`valueDidChangeHandler`][Self::valueDidChangeHandler].
54 ///
55 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
56 #[unsafe(method(setValueDidChangeHandler:))]
57 #[unsafe(method_family = none)]
58 unsafe fn setValueDidChangeHandler(
59 &self,
60 value_did_change_handler: Option<
61 &block2::DynBlock<
62 dyn Fn(
63 NonNull<ProtocolObject<dyn GCPhysicalInputElement>>,
64 NonNull<ProtocolObject<dyn GCAxis2DInput>>,
65 GCPoint2,
66 ),
67 >,
68 >,
69 );
70
71 #[cfg(feature = "GCTypes")]
72 /// A pair of x,y normalized values for the axis input, each between -1 and 1
73 /// (inclusive). The values are deadzoned and saturated before they are returned
74 /// so there is no value outside the range. Deadzoning does not remove values
75 /// from the range; the full 0 to 1 magnitude of values are possible from the input.
76 ///
77 /// As an axis is often used in a digital sense, you can rely on a value of 0
78 /// meaning the axis is inside the deadzone. Any value greater than or less than
79 /// zero is not in the deadzone.
80 #[unsafe(method(value))]
81 #[unsafe(method_family = none)]
82 unsafe fn value(&self) -> GCPoint2;
83
84 /// Check if the axis can support more than just digital values.
85 ///
86 /// Defaults to
87 /// `YES`for most axis inputs.
88 #[unsafe(method(isAnalog))]
89 #[unsafe(method_family = none)]
90 unsafe fn isAnalog(&self) -> bool;
91
92 /// Check if the axis input value "rolls over" when reaching either the extreme
93 /// high or low value. For example, some dials can be rotated past the position
94 /// that represents their maximum value causing the reported value to roll over.
95 ///
96 /// Defaults to
97 /// `NO`for most axis elements.
98 #[unsafe(method(canWrap))]
99 #[unsafe(method_family = none)]
100 unsafe fn canWrap(&self) -> bool;
101
102 /// The timestamp of the last value.
103 ///
104 /// This time interval is not relative to any specific point in time. You can
105 /// subtract a previous timestamp from the current timestamp to determine the time
106 /// (in seconds) between changes to the value.
107 #[unsafe(method(lastValueTimestamp))]
108 #[unsafe(method_family = none)]
109 unsafe fn lastValueTimestamp(&self) -> NSTimeInterval;
110
111 /// The interval (in seconds) between the timestamp of the last event and the
112 /// current time.
113 ///
114 /// This should be treated as a lower bound of the event latency. It may not
115 /// include (wired or wireless) transmission latency, or latency accrued on
116 /// the device before the event was transmitted to the host.
117 #[unsafe(method(lastValueLatency))]
118 #[unsafe(method_family = none)]
119 unsafe fn lastValueLatency(&self) -> NSTimeInterval;
120
121 #[cfg(feature = "GCPhysicalInputSource")]
122 /// An object describing the physical action(s) the user performs to manipulate
123 /// this input.
124 #[unsafe(method(sources))]
125 #[unsafe(method_family = none)]
126 unsafe fn sources(&self) -> Retained<NSSet<ProtocolObject<dyn GCPhysicalInputSource>>>;
127 }
128);