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