objc2_game_controller/generated/
GCPressedStateInput.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    /// `GCPressedStateInput`represents the pressed state of
13    /// an element, typically a button.
14    ///
15    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcpressedstateinput?language=objc)
16    pub unsafe trait GCPressedStateInput: NSObjectProtocol {
17        #[cfg(all(feature = "GCPhysicalInputElement", feature = "block2"))]
18        /// Set this block if you want to be notified when the pressed state changes.
19        ///
20        /// # Safety
21        ///
22        /// - The returned block's argument 1 must be a valid pointer.
23        /// - The returned block's argument 2 must be a valid pointer.
24        #[unsafe(method(pressedDidChangeHandler))]
25        #[unsafe(method_family = none)]
26        unsafe fn pressedDidChangeHandler(
27            &self,
28        ) -> *mut block2::DynBlock<
29            dyn Fn(
30                NonNull<ProtocolObject<dyn GCPhysicalInputElement>>,
31                NonNull<ProtocolObject<dyn GCPressedStateInput>>,
32                Bool,
33            ),
34        >;
35
36        #[cfg(all(feature = "GCPhysicalInputElement", feature = "block2"))]
37        /// Setter for [`pressedDidChangeHandler`][Self::pressedDidChangeHandler].
38        ///
39        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
40        #[unsafe(method(setPressedDidChangeHandler:))]
41        #[unsafe(method_family = none)]
42        unsafe fn setPressedDidChangeHandler(
43            &self,
44            pressed_did_change_handler: Option<
45                &block2::DynBlock<
46                    dyn Fn(
47                        NonNull<ProtocolObject<dyn GCPhysicalInputElement>>,
48                        NonNull<ProtocolObject<dyn GCPressedStateInput>>,
49                        Bool,
50                    ),
51                >,
52            >,
53        );
54
55        /// Buttons are mostly used in a digital sense, thus we have a recommended method
56        /// for checking for pressed state instead of interpreting the value.
57        ///
58        /// As a general guideline a button is pressed if the value exceeds 0. However
59        /// there may be hysteresis applied to counter noisy input values, thus incidental
60        /// values around the threshold value may not trigger a change in pressed state.
61        ///
62        /// Other buttons may support two-stage actuation, where the button reports a
63        /// value between 0 and 1 but is only considered pressed when its value is greater
64        /// than some threshold other than 0.
65        ///
66        ///
67        /// See: pressedDidChangeHandler
68        #[unsafe(method(isPressed))]
69        #[unsafe(method_family = none)]
70        unsafe fn isPressed(&self) -> bool;
71
72        /// The timestamp of the last pressed state change.
73        ///
74        /// This time interval is not relative to any specific point in time.  You can
75        /// subtract a previous timestamp from the current timestamp to determine the time
76        /// (in seconds) between changes to the value.
77        #[unsafe(method(lastPressedStateTimestamp))]
78        #[unsafe(method_family = none)]
79        unsafe fn lastPressedStateTimestamp(&self) -> NSTimeInterval;
80
81        /// The interval (in seconds) between the timestamp of the last pressed state
82        /// change and the current time.
83        ///
84        /// This should be treated as a lower bound of the event latency.  It may not
85        /// include (wired or wireless) transmission latency, or latency accrued on
86        /// the device before the event was transmitted to the host.
87        #[unsafe(method(lastPressedStateLatency))]
88        #[unsafe(method_family = none)]
89        unsafe fn lastPressedStateLatency(&self) -> NSTimeInterval;
90
91        #[cfg(feature = "GCPhysicalInputSource")]
92        /// An object describing the physical action(s) the user performs to manipulate
93        /// this input.
94        #[unsafe(method(sources))]
95        #[unsafe(method_family = none)]
96        unsafe fn sources(&self) -> Retained<NSSet<ProtocolObject<dyn GCPhysicalInputSource>>>;
97    }
98);