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