1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
use crate::{
c_char, c_float, c_int, c_void, joystick::*, rwops::*, sensor::*, stdinc::*,
};
#[allow(unused)]
use crate::events::*;
#[allow(unused)]
use crate::hints::*;
#[allow(unused)]
use crate::platform::*;
#[allow(unused)]
use crate::*;
#[repr(transparent)]
pub struct SDL_GameController(c_void);
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct SDL_GameControllerType(pub i32);
#[allow(missing_docs)]
pub const SDL_CONTROLLER_TYPE_UNKNOWN: SDL_GameControllerType =
SDL_GameControllerType(0);
#[allow(missing_docs)]
pub const SDL_CONTROLLER_TYPE_XBOX360: SDL_GameControllerType =
SDL_GameControllerType(1);
#[allow(missing_docs)]
pub const SDL_CONTROLLER_TYPE_XBOXONE: SDL_GameControllerType =
SDL_GameControllerType(2);
#[allow(missing_docs)]
pub const SDL_CONTROLLER_TYPE_PS3: SDL_GameControllerType =
SDL_GameControllerType(3);
#[allow(missing_docs)]
pub const SDL_CONTROLLER_TYPE_PS4: SDL_GameControllerType =
SDL_GameControllerType(4);
#[allow(missing_docs)]
pub const SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO: SDL_GameControllerType =
SDL_GameControllerType(5);
#[allow(missing_docs)]
pub const SDL_CONTROLLER_TYPE_VIRTUAL: SDL_GameControllerType =
SDL_GameControllerType(6);
#[allow(missing_docs)]
pub const SDL_CONTROLLER_TYPE_PS5: SDL_GameControllerType =
SDL_GameControllerType(7);
#[allow(missing_docs)]
pub const SDL_CONTROLLER_TYPE_AMAZON_LUNA: SDL_GameControllerType =
SDL_GameControllerType(8);
#[allow(missing_docs)]
pub const SDL_CONTROLLER_TYPE_GOOGLE_STADIA: SDL_GameControllerType =
SDL_GameControllerType(9);
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct SDL_GameControllerBindType(pub i32);
#[allow(missing_docs)]
pub const SDL_CONTROLLER_BINDTYPE_NONE: SDL_GameControllerBindType =
SDL_GameControllerBindType(0);
#[allow(missing_docs)]
pub const SDL_CONTROLLER_BINDTYPE_BUTTON: SDL_GameControllerBindType =
SDL_GameControllerBindType(1);
#[allow(missing_docs)]
pub const SDL_CONTROLLER_BINDTYPE_AXIS: SDL_GameControllerBindType =
SDL_GameControllerBindType(2);
#[allow(missing_docs)]
pub const SDL_CONTROLLER_BINDTYPE_HAT: SDL_GameControllerBindType =
SDL_GameControllerBindType(3);
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_GameControllerButtonBind_hat_data {
pub hat: c_int,
pub hat_mask: c_int,
}
#[derive(Clone, Copy)]
#[repr(C, align(4))] #[allow(missing_docs)]
pub union SDL_GameControllerButtonBind_value_data {
pub button: c_int,
pub axis: c_int,
pub hat: SDL_GameControllerButtonBind_hat_data,
}
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_GameControllerButtonBind {
pub bindType: SDL_GameControllerBindType,
pub value: SDL_GameControllerButtonBind_value_data,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct SDL_GameControllerAxis(pub i32);
pub const SDL_CONTROLLER_AXIS_INVALID: SDL_GameControllerAxis =
SDL_GameControllerAxis(-1);
pub const SDL_CONTROLLER_AXIS_LEFTX: SDL_GameControllerAxis =
SDL_GameControllerAxis(0);
pub const SDL_CONTROLLER_AXIS_LEFTY: SDL_GameControllerAxis =
SDL_GameControllerAxis(1);
pub const SDL_CONTROLLER_AXIS_RIGHTX: SDL_GameControllerAxis =
SDL_GameControllerAxis(2);
pub const SDL_CONTROLLER_AXIS_RIGHTY: SDL_GameControllerAxis =
SDL_GameControllerAxis(3);
pub const SDL_CONTROLLER_AXIS_TRIGGERLEFT: SDL_GameControllerAxis =
SDL_GameControllerAxis(4);
pub const SDL_CONTROLLER_AXIS_TRIGGERRIGHT: SDL_GameControllerAxis =
SDL_GameControllerAxis(5);
pub const SDL_CONTROLLER_AXIS_MAX: usize = 6;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct SDL_GameControllerButton(pub i32);
pub const SDL_CONTROLLER_BUTTON_INVALID: SDL_GameControllerButton =
SDL_GameControllerButton(-1);
pub const SDL_CONTROLLER_BUTTON_A: SDL_GameControllerButton =
SDL_GameControllerButton(0);
pub const SDL_CONTROLLER_BUTTON_B: SDL_GameControllerButton =
SDL_GameControllerButton(1);
pub const SDL_CONTROLLER_BUTTON_X: SDL_GameControllerButton =
SDL_GameControllerButton(2);
pub const SDL_CONTROLLER_BUTTON_Y: SDL_GameControllerButton =
SDL_GameControllerButton(3);
pub const SDL_CONTROLLER_BUTTON_BACK: SDL_GameControllerButton =
SDL_GameControllerButton(4);
pub const SDL_CONTROLLER_BUTTON_GUIDE: SDL_GameControllerButton =
SDL_GameControllerButton(5);
pub const SDL_CONTROLLER_BUTTON_START: SDL_GameControllerButton =
SDL_GameControllerButton(6);
pub const SDL_CONTROLLER_BUTTON_LEFTSTICK: SDL_GameControllerButton =
SDL_GameControllerButton(7);
pub const SDL_CONTROLLER_BUTTON_RIGHTSTICK: SDL_GameControllerButton =
SDL_GameControllerButton(8);
pub const SDL_CONTROLLER_BUTTON_LEFTSHOULDER: SDL_GameControllerButton =
SDL_GameControllerButton(9);
pub const SDL_CONTROLLER_BUTTON_RIGHTSHOULDER: SDL_GameControllerButton =
SDL_GameControllerButton(10);
pub const SDL_CONTROLLER_BUTTON_DPAD_UP: SDL_GameControllerButton =
SDL_GameControllerButton(11);
pub const SDL_CONTROLLER_BUTTON_DPAD_DOWN: SDL_GameControllerButton =
SDL_GameControllerButton(12);
pub const SDL_CONTROLLER_BUTTON_DPAD_LEFT: SDL_GameControllerButton =
SDL_GameControllerButton(13);
pub const SDL_CONTROLLER_BUTTON_DPAD_RIGHT: SDL_GameControllerButton =
SDL_GameControllerButton(14);
pub const SDL_CONTROLLER_BUTTON_MISC1: SDL_GameControllerButton =
SDL_GameControllerButton(15);
pub const SDL_CONTROLLER_BUTTON_PADDLE1: SDL_GameControllerButton =
SDL_GameControllerButton(16);
pub const SDL_CONTROLLER_BUTTON_PADDLE2: SDL_GameControllerButton =
SDL_GameControllerButton(17);
pub const SDL_CONTROLLER_BUTTON_PADDLE3: SDL_GameControllerButton =
SDL_GameControllerButton(18);
pub const SDL_CONTROLLER_BUTTON_PADDLE4: SDL_GameControllerButton =
SDL_GameControllerButton(19);
pub const SDL_CONTROLLER_BUTTON_TOUCHPAD: SDL_GameControllerButton =
SDL_GameControllerButton(20);
pub const SDL_CONTROLLER_BUTTON_MAX: usize = 21;
pub unsafe fn SDL_GameControllerAddMappingsFromFile(
file: *const c_char,
) -> c_int {
SDL_GameControllerAddMappingsFromRW(
SDL_RWFromFile(file, b"rb\0".as_ptr().cast()),
1,
)
}
extern "C" {
pub fn SDL_GameControllerAddMappingsFromRW(
rw: *mut SDL_RWops, freerw: c_int,
) -> c_int;
pub fn SDL_GameControllerAddMapping(mappingString: *const c_char) -> c_int;
pub fn SDL_GameControllerNumMappings() -> c_int;
pub fn SDL_GameControllerMappingForIndex(mapping_index: c_int)
-> *mut c_char;
pub fn SDL_GameControllerMappingForGUID(
guid: SDL_JoystickGUID,
) -> *mut c_char;
pub fn SDL_GameControllerMapping(
gamecontroller: *mut SDL_GameController,
) -> *mut c_char;
pub fn SDL_IsGameController(joystick_index: c_int) -> SDL_bool;
pub fn SDL_GameControllerNameForIndex(joystick_index: c_int)
-> *const c_char;
pub fn SDL_GameControllerTypeForIndex(
joystick_index: c_int,
) -> SDL_GameControllerType;
pub fn SDL_GameControllerMappingForDeviceIndex(
joystick_index: c_int,
) -> *mut c_char;
pub fn SDL_GameControllerOpen(
joystick_index: c_int,
) -> *mut SDL_GameController;
pub fn SDL_GameControllerFromInstanceID(
joyid: SDL_JoystickID,
) -> *mut SDL_GameController;
pub fn SDL_GameControllerFromPlayerIndex(
player_index: c_int,
) -> *mut SDL_GameController;
pub fn SDL_GameControllerName(
gamecontroller: *mut SDL_GameController,
) -> *const c_char;
pub fn SDL_GameControllerGetType(
gamecontroller: *mut SDL_GameController,
) -> SDL_GameControllerType;
pub fn SDL_GameControllerGetPlayerIndex(
gamecontroller: *mut SDL_GameController,
) -> c_int;
pub fn SDL_GameControllerSetPlayerIndex(
gamecontroller: *mut SDL_GameController, player_index: c_int,
);
pub fn SDL_GameControllerGetVendor(
gamecontroller: *mut SDL_GameController,
) -> Uint16;
pub fn SDL_GameControllerGetProduct(
gamecontroller: *mut SDL_GameController,
) -> Uint16;
pub fn SDL_GameControllerGetProductVersion(
gamecontroller: *mut SDL_GameController,
) -> Uint16;
pub fn SDL_GameControllerGetSerial(
gamecontroller: *mut SDL_GameController,
) -> *const c_char;
pub fn SDL_GameControllerGetAttached(
gamecontroller: *mut SDL_GameController,
) -> SDL_bool;
pub fn SDL_GameControllerGetJoystick(
gamecontroller: *mut SDL_GameController,
) -> *mut SDL_Joystick;
pub fn SDL_GameControllerEventState(state: c_int) -> c_int;
pub fn SDL_GameControllerUpdate();
pub fn SDL_GameControllerGetAxisFromString(
pchString: *const c_char,
) -> SDL_GameControllerAxis;
pub fn SDL_GameControllerGetStringForAxis(
axis: SDL_GameControllerAxis,
) -> *const c_char;
pub fn SDL_GameControllerGetBindForAxis(
gamecontroller: *mut SDL_GameController, axis: SDL_GameControllerAxis,
) -> SDL_GameControllerButtonBind;
pub fn SDL_GameControllerHasAxis(
gamecontroller: *mut SDL_GameController, axis: SDL_GameControllerAxis,
) -> SDL_bool;
pub fn SDL_GameControllerGetAxis(
gamecontroller: *mut SDL_GameController, axis: SDL_GameControllerAxis,
) -> Sint16;
pub fn SDL_GameControllerGetButtonFromString(
pchString: *const c_char,
) -> SDL_GameControllerButton;
pub fn SDL_GameControllerGetStringForButton(
button: SDL_GameControllerButton,
) -> *const c_char;
pub fn SDL_GameControllerGetBindForButton(
gamecontroller: *mut SDL_GameController, button: SDL_GameControllerButton,
) -> SDL_GameControllerButtonBind;
pub fn SDL_GameControllerHasButton(
gamecontroller: *mut SDL_GameController, button: SDL_GameControllerButton,
) -> SDL_bool;
pub fn SDL_GameControllerGetButton(
gamecontroller: *mut SDL_GameController, button: SDL_GameControllerButton,
) -> Uint8;
pub fn SDL_GameControllerGetNumTouchpads(
gamecontroller: *mut SDL_GameController,
) -> c_int;
pub fn SDL_GameControllerGetNumTouchpadFingers(
gamecontroller: *mut SDL_GameController, touchpad: c_int,
) -> c_int;
pub fn SDL_GameControllerGetTouchpadFinger(
gamecontroller: *mut SDL_GameController, touchpad: c_int, finger: c_int,
state: *mut Uint8, x: *mut c_float, y: *mut c_float,
pressure: *mut c_float,
) -> c_int;
pub fn SDL_GameControllerHasSensor(
gamecontroller: *mut SDL_GameController, type_: SDL_SensorType,
) -> SDL_bool;
pub fn SDL_GameControllerSetSensorEnabled(
gamecontroller: *mut SDL_GameController, type_: SDL_SensorType,
enabled: SDL_bool,
) -> c_int;
pub fn SDL_GameControllerIsSensorEnabled(
gamecontroller: *mut SDL_GameController, type_: SDL_SensorType,
) -> SDL_bool;
pub fn SDL_GameControllerGetSensorData(
gamecontroller: *mut SDL_GameController, type_: SDL_SensorType,
data: *mut c_float, num_values: c_int,
) -> c_int;
pub fn SDL_GameControllerRumble(
gamecontroller: *mut SDL_GameController, low_frequency_rumble: Uint16,
high_frequency_rumble: Uint16, duration_ms: Uint32,
) -> c_int;
pub fn SDL_GameControllerRumbleTriggers(
gamecontroller: *mut SDL_GameController, left_rumble: Uint16,
right_rumble: Uint16, duration_ms: Uint32,
) -> c_int;
pub fn SDL_GameControllerHasLED(
gamecontroller: *mut SDL_GameController,
) -> SDL_bool;
pub fn SDL_GameControllerSetLED(
gamecontroller: *mut SDL_GameController, red: Uint8, green: Uint8,
blue: Uint8,
) -> c_int;
pub fn SDL_GameControllerClose(gamecontroller: *mut SDL_GameController);
pub fn SDL_GameControllerSendEffect(
gamecontroller: *mut SDL_GameController, data: *const c_void, size: c_int,
) -> c_int;
pub fn SDL_GameControllerGetSensorDataRate(
gamecontroller: *mut SDL_GameController, type_: SDL_SensorType,
) -> c_float;
}