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