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