objc2_game_controller/generated/
GCPhysicalInputProfile.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_class!(
11    /// A game controller profile representing physical buttons, thumbsticks, dpads, etc... on a controller.
12    ///
13    /// All controller profiles provide a base level of information about the controller they belong to.
14    ///
15    /// A profile maps the hardware notion of a controller into a logical controller. One that a developer can design for
16    /// and depend on, no matter the underlying hardware.
17    ///
18    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcphysicalinputprofile?language=objc)
19    #[unsafe(super(NSObject))]
20    #[derive(Debug, PartialEq, Eq, Hash)]
21    pub struct GCPhysicalInputProfile;
22);
23
24unsafe impl NSObjectProtocol for GCPhysicalInputProfile {}
25
26impl GCPhysicalInputProfile {
27    extern_methods!(
28        #[cfg(feature = "GCDevice")]
29        /// A profile keeps a reference to the device that this profile is mapping input from
30        #[unsafe(method(device))]
31        #[unsafe(method_family = none)]
32        pub unsafe fn device(&self) -> Option<Retained<ProtocolObject<dyn GCDevice>>>;
33
34        /// The last time elements of this profile were updated.
35        #[unsafe(method(lastEventTimestamp))]
36        #[unsafe(method_family = none)]
37        pub unsafe fn lastEventTimestamp(&self) -> NSTimeInterval;
38
39        /// Whether the user has remapped their physical input controls for this profile at the system level.
40        ///
41        ///
42        /// On iOS and tvOS, users can remap their game controller inputs in Settings.
43        #[unsafe(method(hasRemappedElements))]
44        #[unsafe(method_family = none)]
45        pub unsafe fn hasRemappedElements(&self) -> bool;
46
47        #[cfg(all(feature = "GCControllerElement", feature = "block2"))]
48        /// Set this block if you want to be notified when a value on a element changed. If multiple elements have changed this block will be called
49        /// for each element that changed.
50        ///
51        ///
52        /// Parameter `profile`: this profile that is being used to map the raw input data into logical values on controller elements such as the dpad or the buttons.
53        ///
54        /// Parameter `element`: the element that has been modified.
55        #[unsafe(method(valueDidChangeHandler))]
56        #[unsafe(method_family = none)]
57        pub unsafe fn valueDidChangeHandler(
58            &self,
59        ) -> *mut block2::Block<dyn Fn(NonNull<GCPhysicalInputProfile>, NonNull<GCControllerElement>)>;
60
61        #[cfg(all(feature = "GCControllerElement", feature = "block2"))]
62        /// Setter for [`valueDidChangeHandler`][Self::valueDidChangeHandler].
63        #[unsafe(method(setValueDidChangeHandler:))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn setValueDidChangeHandler(
66            &self,
67            value_did_change_handler: Option<
68                &block2::Block<
69                    dyn Fn(NonNull<GCPhysicalInputProfile>, NonNull<GCControllerElement>),
70                >,
71            >,
72        );
73
74        #[cfg(feature = "GCControllerElement")]
75        /// The following properties allow for runtime lookup of any input element on a profile, when provided with a valid alias.
76        #[unsafe(method(elements))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn elements(&self) -> Retained<NSDictionary<NSString, GCControllerElement>>;
79
80        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
81        #[unsafe(method(buttons))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn buttons(&self) -> Retained<NSDictionary<NSString, GCControllerButtonInput>>;
84
85        #[cfg(all(feature = "GCControllerAxisInput", feature = "GCControllerElement"))]
86        #[unsafe(method(axes))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn axes(&self) -> Retained<NSDictionary<NSString, GCControllerAxisInput>>;
89
90        #[cfg(all(feature = "GCControllerDirectionPad", feature = "GCControllerElement"))]
91        #[unsafe(method(dpads))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn dpads(&self) -> Retained<NSDictionary<NSString, GCControllerDirectionPad>>;
94
95        #[cfg(all(feature = "GCControllerElement", feature = "GCControllerTouchpad"))]
96        #[unsafe(method(touchpads))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn touchpads(&self) -> Retained<NSDictionary<NSString, GCControllerTouchpad>>;
99
100        #[cfg(feature = "GCControllerElement")]
101        /// The following properties allow for dynamic querying of the input elements available on a profile.
102        #[unsafe(method(allElements))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn allElements(&self) -> Retained<NSSet<GCControllerElement>>;
105
106        #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
107        #[unsafe(method(allButtons))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn allButtons(&self) -> Retained<NSSet<GCControllerButtonInput>>;
110
111        #[cfg(all(feature = "GCControllerAxisInput", feature = "GCControllerElement"))]
112        #[unsafe(method(allAxes))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn allAxes(&self) -> Retained<NSSet<GCControllerAxisInput>>;
115
116        #[cfg(all(feature = "GCControllerDirectionPad", feature = "GCControllerElement"))]
117        #[unsafe(method(allDpads))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn allDpads(&self) -> Retained<NSSet<GCControllerDirectionPad>>;
120
121        #[cfg(all(feature = "GCControllerElement", feature = "GCControllerTouchpad"))]
122        #[unsafe(method(allTouchpads))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn allTouchpads(&self) -> Retained<NSSet<GCControllerTouchpad>>;
125
126        #[cfg(feature = "GCControllerElement")]
127        /// Profile elements can be accessed using keyed subscript notation, with a valid alias of its inputs.
128        ///
129        ///
130        ///
131        ///
132        /// Note: Equivalent to -elements
133        #[unsafe(method(objectForKeyedSubscript:))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn objectForKeyedSubscript(
136            &self,
137            key: &NSString,
138        ) -> Option<Retained<GCControllerElement>>;
139
140        /// Polls the state vector of the physical input input and saves it to a new and writable instance of GCPhysicalInputProfile.
141        ///
142        /// If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as
143        /// a snapshot will not change based on user input once it is taken.
144        ///
145        ///
146        /// See: snapshot
147        ///
148        /// Returns: A new physical input profile with the duplicated state vector of the current physical input
149        #[unsafe(method(capture))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn capture(&self) -> Retained<Self>;
152
153        /// Sets the state vector of the physical input profile to a copy of the passed in physical input profile's state vector.
154        ///
155        ///
156        /// Note: If the controller's snapshot flag is set to NO, this method has no effect.
157        ///
158        /// See: GCController.snapshot
159        #[unsafe(method(setStateFromPhysicalInput:))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn setStateFromPhysicalInput(&self, physical_input: &GCPhysicalInputProfile);
162
163        /// Returns the primary alias of the GCControllerElement that a given physical input maps to.
164        ///
165        ///
166        /// If the user were to map a physical press of the A button of their game controller to the B button, then
167        /// -[GCPhysicalInputProfile  mappedElementAliasForPhysicalInputName: GCInputButtonA] would return GCInputButtonB.
168        /// Note that mappings can change anytime your app is backgrounded, so make sure you update any relevant visuals when
169        /// returning to foreground.
170        ///
171        ///
172        /// Parameter `inputName`: A GCInput string corresponding to the physical button you want the mapped element alias for.
173        ///
174        ///
175        /// Returns: A GCInput string corresponding to the primary alias of the GCControllerElement that a given physical button maps to, or nil if there is no mapping.
176        #[unsafe(method(mappedElementAliasForPhysicalInputName:))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn mappedElementAliasForPhysicalInputName(
179            &self,
180            input_name: &NSString,
181        ) -> Retained<NSString>;
182
183        /// Returns a set of GCInput strings corresponding to physical inputs that are mapped to a given GCControllerElement.
184        ///
185        ///
186        /// If the user mapped the physical press of the A button, the B button, and the X button to the B button, then
187        /// -[GCPhysicalInputProfile mappedPhysicalInputNamesForElementAlias: GCInputButtonB] would return  [GCInputButtonA, GCInputButtonB, GCInputButtonX].
188        /// Note that mappings can change anytime your app is backgrounded, so make sure you update any relevant visuals when
189        /// returning to foreground.
190        ///
191        ///
192        /// Parameter `elementAlias`: A GCInput string corresponding to an alias of the GCControllerElement you want the physical buttons for.
193        ///
194        ///
195        /// Returns: A set of GCInput strings corresponding to physical inputs that are mapped to a given GCControllerElement, or an empty set if there are no mappings.
196        #[unsafe(method(mappedPhysicalInputNamesForElementAlias:))]
197        #[unsafe(method_family = none)]
198        pub unsafe fn mappedPhysicalInputNamesForElementAlias(
199            &self,
200            element_alias: &NSString,
201        ) -> Retained<NSSet<NSString>>;
202    );
203}
204
205/// Methods declared on superclass `NSObject`.
206impl GCPhysicalInputProfile {
207    extern_methods!(
208        #[unsafe(method(init))]
209        #[unsafe(method_family = init)]
210        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
211
212        #[unsafe(method(new))]
213        #[unsafe(method_family = new)]
214        pub unsafe fn new() -> Retained<Self>;
215    );
216}