objc2_game_controller/generated/
GCRelativeInput.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    /// `GCRelativeInput`represents an input that reports
13    /// its change in position along an axis (delta) since the previous event.
14    /// Relative inputs have no fixed origin from which a coordinate syatem can be
15    /// defined.
16    ///
17    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcrelativeinput?language=objc)
18    pub unsafe trait GCRelativeInput: NSObjectProtocol {
19        #[cfg(all(feature = "GCPhysicalInputElement", feature = "block2"))]
20        /// Set this block to be notified when the delta of the input changes.
21        ///
22        ///
23        /// Parameter `delta`: The amount that the input has changed since the last time
24        /// `deltaDidChangeHandler`fired.
25        ///
26        /// # Safety
27        ///
28        /// - The returned block's argument 1 must be a valid pointer.
29        /// - The returned block's argument 2 must be a valid pointer.
30        #[unsafe(method(deltaDidChangeHandler))]
31        #[unsafe(method_family = none)]
32        unsafe fn deltaDidChangeHandler(
33            &self,
34        ) -> *mut block2::DynBlock<
35            dyn Fn(
36                NonNull<ProtocolObject<dyn GCPhysicalInputElement>>,
37                NonNull<ProtocolObject<dyn GCRelativeInput>>,
38                c_float,
39            ),
40        >;
41
42        #[cfg(all(feature = "GCPhysicalInputElement", feature = "block2"))]
43        /// Setter for [`deltaDidChangeHandler`][Self::deltaDidChangeHandler].
44        ///
45        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
46        #[unsafe(method(setDeltaDidChangeHandler:))]
47        #[unsafe(method_family = none)]
48        unsafe fn setDeltaDidChangeHandler(
49            &self,
50            delta_did_change_handler: Option<
51                &block2::DynBlock<
52                    dyn Fn(
53                        NonNull<ProtocolObject<dyn GCPhysicalInputElement>>,
54                        NonNull<ProtocolObject<dyn GCRelativeInput>>,
55                        c_float,
56                    ),
57                >,
58            >,
59        );
60
61        /// The last reported delta for the input.
62        #[unsafe(method(delta))]
63        #[unsafe(method_family = none)]
64        unsafe fn delta(&self) -> c_float;
65
66        /// Check if the input can support more than just digital values.
67        ///
68        /// Defaults to
69        /// `YES`for most relative inputs.
70        #[unsafe(method(isAnalog))]
71        #[unsafe(method_family = none)]
72        unsafe fn isAnalog(&self) -> bool;
73
74        /// The timestamp of the last change.
75        ///
76        /// This time interval is not relative to any specific point in time.  You can
77        /// subtract a previous timestamp from the current timestamp to determine the time
78        /// (in seconds) between changes to the value.
79        #[unsafe(method(lastDeltaTimestamp))]
80        #[unsafe(method_family = none)]
81        unsafe fn lastDeltaTimestamp(&self) -> NSTimeInterval;
82
83        /// The interval (in seconds) between the timestamp of the last change and the
84        /// current time.
85        ///
86        /// This should be treated as a lower bound of the event latency.  It may not
87        /// include (wired or wireless) transmission latency, or latency accrued on
88        /// the device before the event was transmitted to the host.
89        #[unsafe(method(lastDeltaLatency))]
90        #[unsafe(method_family = none)]
91        unsafe fn lastDeltaLatency(&self) -> NSTimeInterval;
92
93        #[cfg(feature = "GCPhysicalInputSource")]
94        /// An object describing the physical action(s) the user performs to manipulate
95        /// this input.
96        #[unsafe(method(sources))]
97        #[unsafe(method_family = none)]
98        unsafe fn sources(&self) -> Retained<NSSet<ProtocolObject<dyn GCPhysicalInputSource>>>;
99    }
100);