objc2_game_controller/generated/
GCExtendedGamepadSnapshot.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11 #[unsafe(super(GCExtendedGamepad, GCPhysicalInputProfile, NSObject))]
24 #[derive(Debug, PartialEq, Eq, Hash)]
25 #[cfg(all(feature = "GCExtendedGamepad", feature = "GCPhysicalInputProfile"))]
26 #[deprecated = "Use the -[GCController controllerWithExtendedGamepad] method instead"]
27 pub struct GCExtendedGamepadSnapshot;
28);
29
30#[cfg(all(feature = "GCExtendedGamepad", feature = "GCPhysicalInputProfile"))]
31extern_conformance!(
32 unsafe impl NSObjectProtocol for GCExtendedGamepadSnapshot {}
33);
34
35#[cfg(all(feature = "GCExtendedGamepad", feature = "GCPhysicalInputProfile"))]
36impl GCExtendedGamepadSnapshot {
37 extern_methods!(
38 #[deprecated = "Use the -[GCController controllerWithExtendedGamepad] method instead"]
39 #[unsafe(method(snapshotData))]
40 #[unsafe(method_family = none)]
41 pub unsafe fn snapshotData(&self) -> Retained<NSData>;
42
43 #[deprecated = "Use the -[GCController controllerWithExtendedGamepad] method instead"]
47 #[unsafe(method(setSnapshotData:))]
48 #[unsafe(method_family = none)]
49 pub unsafe fn setSnapshotData(&self, snapshot_data: &NSData);
50
51 #[deprecated = "Use the -[GCController controllerWithExtendedGamepad] method instead"]
52 #[unsafe(method(initWithSnapshotData:))]
53 #[unsafe(method_family = init)]
54 pub unsafe fn initWithSnapshotData(this: Allocated<Self>, data: &NSData) -> Retained<Self>;
55
56 #[cfg(feature = "GCController")]
57 #[deprecated = "Use the -[GCController controllerWithExtendedGamepad] method instead"]
58 #[unsafe(method(initWithController:snapshotData:))]
59 #[unsafe(method_family = init)]
60 pub unsafe fn initWithController_snapshotData(
61 this: Allocated<Self>,
62 controller: &GCController,
63 data: &NSData,
64 ) -> Retained<Self>;
65 );
66}
67
68#[cfg(all(feature = "GCExtendedGamepad", feature = "GCPhysicalInputProfile"))]
70impl GCExtendedGamepadSnapshot {
71 extern_methods!(
72 #[unsafe(method(init))]
73 #[unsafe(method_family = init)]
74 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
75
76 #[unsafe(method(new))]
77 #[unsafe(method_family = new)]
78 pub unsafe fn new() -> Retained<Self>;
79 );
80}
81
82#[deprecated = "Use the -[GCController controllerWithExtendedGamepad] method instead"]
85#[repr(transparent)]
86#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
87pub struct GCExtendedGamepadSnapshotDataVersion(pub NSInteger);
88impl GCExtendedGamepadSnapshotDataVersion {
89 #[doc(alias = "GCExtendedGamepadSnapshotDataVersion1")]
90 #[deprecated = "Use the -[GCController controllerWithExtendedGamepad] method instead"]
91 pub const Version1: Self = Self(0x0100);
92 #[doc(alias = "GCExtendedGamepadSnapshotDataVersion2")]
93 #[deprecated = "Use the -[GCController controllerWithExtendedGamepad] method instead"]
94 pub const Version2: Self = Self(0x0101);
95}
96
97unsafe impl Encode for GCExtendedGamepadSnapshotDataVersion {
98 const ENCODING: Encoding = NSInteger::ENCODING;
99}
100
101unsafe impl RefEncode for GCExtendedGamepadSnapshotDataVersion {
102 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
103}
104
105extern "C" {
106 #[deprecated = "Use the -[GCController controllerWithExtendedGamepad] method instead"]
108 pub static GCCurrentExtendedGamepadSnapshotDataVersion: GCExtendedGamepadSnapshotDataVersion;
109}
110
111#[repr(C, packed)]
113#[derive(Clone, Copy, Debug, PartialEq)]
114pub struct GCExtendedGamepadSnapshotData {
115 pub version: u16,
116 pub size: u16,
117 pub dpadX: c_float,
118 pub dpadY: c_float,
119 pub buttonA: c_float,
120 pub buttonB: c_float,
121 pub buttonX: c_float,
122 pub buttonY: c_float,
123 pub leftShoulder: c_float,
124 pub rightShoulder: c_float,
125 pub leftThumbstickX: c_float,
126 pub leftThumbstickY: c_float,
127 pub rightThumbstickX: c_float,
128 pub rightThumbstickY: c_float,
129 pub leftTrigger: c_float,
130 pub rightTrigger: c_float,
131 pub supportsClickableThumbsticks: Bool,
132 pub leftThumbstickButton: Bool,
133 pub rightThumbstickButton: Bool,
134}
135
136unsafe impl Encode for GCExtendedGamepadSnapshotData {
137 const ENCODING: Encoding = Encoding::Struct(
138 "?",
139 &[
140 <u16>::ENCODING,
141 <u16>::ENCODING,
142 <c_float>::ENCODING,
143 <c_float>::ENCODING,
144 <c_float>::ENCODING,
145 <c_float>::ENCODING,
146 <c_float>::ENCODING,
147 <c_float>::ENCODING,
148 <c_float>::ENCODING,
149 <c_float>::ENCODING,
150 <c_float>::ENCODING,
151 <c_float>::ENCODING,
152 <c_float>::ENCODING,
153 <c_float>::ENCODING,
154 <c_float>::ENCODING,
155 <c_float>::ENCODING,
156 <Bool>::ENCODING,
157 <Bool>::ENCODING,
158 <Bool>::ENCODING,
159 ],
160 );
161}
162
163unsafe impl RefEncode for GCExtendedGamepadSnapshotData {
164 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
165}
166
167impl GCExtendedGamepadSnapshotData {
168 #[doc(alias = "GCExtendedGamepadSnapshotDataFromNSData")]
177 #[deprecated = "Use the -[GCController controllerWithExtendedGamepad] method instead"]
178 #[inline]
179 pub unsafe fn from_ns_data(
180 snapshot_data: *mut GCExtendedGamepadSnapshotData,
181 data: Option<&NSData>,
182 ) -> bool {
183 extern "C-unwind" {
184 fn GCExtendedGamepadSnapshotDataFromNSData(
185 snapshot_data: *mut GCExtendedGamepadSnapshotData,
186 data: Option<&NSData>,
187 ) -> Bool;
188 }
189 unsafe { GCExtendedGamepadSnapshotDataFromNSData(snapshot_data, data) }.as_bool()
190 }
191}
192
193#[deprecated = "Use the -[GCController controllerWithExtendedGamepad] method instead"]
203#[inline]
204pub unsafe extern "C-unwind" fn NSDataFromGCExtendedGamepadSnapshotData(
205 snapshot_data: *mut GCExtendedGamepadSnapshotData,
206) -> Option<Retained<NSData>> {
207 extern "C-unwind" {
208 fn NSDataFromGCExtendedGamepadSnapshotData(
209 snapshot_data: *mut GCExtendedGamepadSnapshotData,
210 ) -> *mut NSData;
211 }
212 let ret = unsafe { NSDataFromGCExtendedGamepadSnapshotData(snapshot_data) };
213 unsafe { Retained::retain_autoreleased(ret) }
214}
215
216#[repr(C)]
218#[derive(Clone, Copy, Debug, PartialEq)]
219pub struct GCExtendedGamepadSnapShotDataV100 {
220 pub version: u16,
221 pub size: u16,
222 pub dpadX: c_float,
223 pub dpadY: c_float,
224 pub buttonA: c_float,
225 pub buttonB: c_float,
226 pub buttonX: c_float,
227 pub buttonY: c_float,
228 pub leftShoulder: c_float,
229 pub rightShoulder: c_float,
230 pub leftThumbstickX: c_float,
231 pub leftThumbstickY: c_float,
232 pub rightThumbstickX: c_float,
233 pub rightThumbstickY: c_float,
234 pub leftTrigger: c_float,
235 pub rightTrigger: c_float,
236}
237
238unsafe impl Encode for GCExtendedGamepadSnapShotDataV100 {
239 const ENCODING: Encoding = Encoding::Struct(
240 "?",
241 &[
242 <u16>::ENCODING,
243 <u16>::ENCODING,
244 <c_float>::ENCODING,
245 <c_float>::ENCODING,
246 <c_float>::ENCODING,
247 <c_float>::ENCODING,
248 <c_float>::ENCODING,
249 <c_float>::ENCODING,
250 <c_float>::ENCODING,
251 <c_float>::ENCODING,
252 <c_float>::ENCODING,
253 <c_float>::ENCODING,
254 <c_float>::ENCODING,
255 <c_float>::ENCODING,
256 <c_float>::ENCODING,
257 <c_float>::ENCODING,
258 ],
259 );
260}
261
262unsafe impl RefEncode for GCExtendedGamepadSnapShotDataV100 {
263 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
264}
265
266impl GCExtendedGamepadSnapShotDataV100 {
267 #[doc(alias = "GCExtendedGamepadSnapShotDataV100FromNSData")]
276 #[deprecated = "Use the -[GCController controllerWithExtendedGamepad] method instead"]
277 #[inline]
278 pub unsafe fn from_ns_data(
279 snapshot_data: *mut GCExtendedGamepadSnapShotDataV100,
280 data: Option<&NSData>,
281 ) -> bool {
282 extern "C-unwind" {
283 fn GCExtendedGamepadSnapShotDataV100FromNSData(
284 snapshot_data: *mut GCExtendedGamepadSnapShotDataV100,
285 data: Option<&NSData>,
286 ) -> Bool;
287 }
288 unsafe { GCExtendedGamepadSnapShotDataV100FromNSData(snapshot_data, data) }.as_bool()
289 }
290}
291
292#[deprecated = "Use the -[GCController controllerWithExtendedGamepad] method instead"]
302#[inline]
303pub unsafe extern "C-unwind" fn NSDataFromGCExtendedGamepadSnapShotDataV100(
304 snapshot_data: *mut GCExtendedGamepadSnapShotDataV100,
305) -> Option<Retained<NSData>> {
306 extern "C-unwind" {
307 fn NSDataFromGCExtendedGamepadSnapShotDataV100(
308 snapshot_data: *mut GCExtendedGamepadSnapShotDataV100,
309 ) -> *mut NSData;
310 }
311 let ret = unsafe { NSDataFromGCExtendedGamepadSnapShotDataV100(snapshot_data) };
312 unsafe { Retained::retain_autoreleased(ret) }
313}
314
315#[deprecated = "renamed to `GCExtendedGamepadSnapshotData::from_ns_data`"]
316#[inline]
317pub unsafe extern "C-unwind" fn GCExtendedGamepadSnapshotDataFromNSData(
318 snapshot_data: *mut GCExtendedGamepadSnapshotData,
319 data: Option<&NSData>,
320) -> bool {
321 extern "C-unwind" {
322 fn GCExtendedGamepadSnapshotDataFromNSData(
323 snapshot_data: *mut GCExtendedGamepadSnapshotData,
324 data: Option<&NSData>,
325 ) -> Bool;
326 }
327 unsafe { GCExtendedGamepadSnapshotDataFromNSData(snapshot_data, data) }.as_bool()
328}
329
330#[deprecated = "renamed to `GCExtendedGamepadSnapShotDataV100::from_ns_data`"]
331#[inline]
332pub unsafe extern "C-unwind" fn GCExtendedGamepadSnapShotDataV100FromNSData(
333 snapshot_data: *mut GCExtendedGamepadSnapShotDataV100,
334 data: Option<&NSData>,
335) -> bool {
336 extern "C-unwind" {
337 fn GCExtendedGamepadSnapShotDataV100FromNSData(
338 snapshot_data: *mut GCExtendedGamepadSnapShotDataV100,
339 data: Option<&NSData>,
340 ) -> Bool;
341 }
342 unsafe { GCExtendedGamepadSnapShotDataV100FromNSData(snapshot_data, data) }.as_bool()
343}