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