[ create a new paste ] login | about

Link: http://codepad.org/qh7jclpD    [ raw code | output | fork ]

C, pasted on May 6:
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
#define _GNU_SOURCE

#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>

typedef uint16_t u16;
typedef uint8_t u8;

#define MAP_DPAD_TO_BUTTONS		(1 << 0)
#define MAP_TRIGGERS_TO_BUTTONS		(1 << 1)
#define MAP_STICKS_TO_NULL		(1 << 2)
#define DANCEPAD_MAP_CONFIG	(MAP_DPAD_TO_BUTTONS |			\
				MAP_TRIGGERS_TO_BUTTONS | MAP_STICKS_TO_NULL)

#define XTYPE_XBOX        0
#define XTYPE_XBOX360     1
#define XTYPE_XBOX360W    2
#define XTYPE_XBOXONE     3
#define XTYPE_UNKNOWN     4

static const struct xpad_device {
	u16 idVendor;
	u16 idProduct;
	char *name;
	u8 mapping;
	u8 xtype;
} xpad_device[] = {
	{ 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
	{ 0x044f, 0xb326, "Thrustmaster Gamepad GP XID", 0, XTYPE_XBOX360 },
	{ 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", 0, XTYPE_XBOX },
	{ 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX },
	{ 0x045e, 0x0287, "Microsoft Xbox Controller S", 0, XTYPE_XBOX },
	{ 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", 0, XTYPE_XBOX },
	{ 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 },
	{ 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
	{ 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE },
	{ 0x045e, 0x02dd, "Microsoft X-Box One pad (Firmware 2015)", 0, XTYPE_XBOXONE },
	{ 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", 0, XTYPE_XBOXONE },
	{ 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE },
	{ 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
	{ 0x046d, 0xc21d, "Logitech Gamepad F310", 0, XTYPE_XBOX360 },
	{ 0x046d, 0xc21e, "Logitech Gamepad F510", 0, XTYPE_XBOX360 },
	{ 0x046d, 0xc21f, "Logitech Gamepad F710", 0, XTYPE_XBOX360 },
	{ 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 },
	{ 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX },
	{ 0x046d, 0xca88, "Logitech Compact Controller for Xbox", 0, XTYPE_XBOX },
	{ 0x056e, 0x2004, "Elecom JC-U3613M", 0, XTYPE_XBOX360 },
	{ 0x05fd, 0x1007, "Mad Catz Controller (unverified)", 0, XTYPE_XBOX },
	{ 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", 0, XTYPE_XBOX },
	{ 0x0738, 0x4516, "Mad Catz Control Pad", 0, XTYPE_XBOX },
	{ 0x0738, 0x4522, "Mad Catz LumiCON", 0, XTYPE_XBOX },
	{ 0x0738, 0x4526, "Mad Catz Control Pad Pro", 0, XTYPE_XBOX },
	{ 0x0738, 0x4536, "Mad Catz MicroCON", 0, XTYPE_XBOX },
	{ 0x0738, 0x4540, "Mad Catz Beat Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
	{ 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", 0, XTYPE_XBOX },
	{ 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
	{ 0x0738, 0x4718, "Mad Catz Street Fighter IV FightStick SE", 0, XTYPE_XBOX360 },
	{ 0x0738, 0x4726, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 },
	{ 0x0738, 0x4728, "Mad Catz Street Fighter IV FightPad", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x0738, 0x4740, "Mad Catz Beat Pad", 0, XTYPE_XBOX360 },
	{ 0x0738, 0x4a01, "Mad Catz FightStick TE 2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
	{ 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
	{ 0x0738, 0xb726, "Mad Catz Xbox controller - MW2", 0, XTYPE_XBOX360 },
	{ 0x0738, 0xbeef, "Mad Catz JOYTECH NEO SE Advanced GamePad", XTYPE_XBOX360 },
	{ 0x0738, 0xcb02, "Saitek Cyborg Rumble Pad - PC/Xbox 360", 0, XTYPE_XBOX360 },
	{ 0x0738, 0xcb03, "Saitek P3200 Rumble Pad - PC/Xbox 360", 0, XTYPE_XBOX360 },
	{ 0x0738, 0xf738, "Super SFIV FightStick TE S", 0, XTYPE_XBOX360 },
	{ 0x0c12, 0x8802, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
	{ 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", DANCEPAD_MAP_CONFIG, XTYPE_XBOX },
	{ 0x0c12, 0x880a, "Pelican Eclipse PL-2023", 0, XTYPE_XBOX },
	{ 0x0c12, 0x8810, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
	{ 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", 0, XTYPE_XBOX },
	{ 0x0d2f, 0x0002, "Andamiro Pump It Up pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
	{ 0x0e4c, 0x1097, "Radica Gamester Controller", 0, XTYPE_XBOX },
	{ 0x0e4c, 0x2390, "Radica Games Jtech Controller", 0, XTYPE_XBOX },
	{ 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", 0, XTYPE_XBOX },
	{ 0x0e6f, 0x0005, "Eclipse wireless Controller", 0, XTYPE_XBOX },
	{ 0x0e6f, 0x0006, "Edge wireless Controller", 0, XTYPE_XBOX },
	{ 0x0e6f, 0x0105, "HSM3 Xbox360 dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x0e6f, 0x0113, "Afterglow AX.1 Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
	{ 0x0e6f, 0x011f, "Rock Candy Gamepad Wired Controller", 0, XTYPE_XBOX360 },
	{ 0x0e6f, 0x0139, "Afterglow Prismatic Wired Controller", 0, XTYPE_XBOXONE },
	{ 0x0e6f, 0x0146, "Rock Candy Wired Controller for Xbox One", 0, XTYPE_XBOXONE },
	{ 0x0e6f, 0x0201, "Pelican PL-3601 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
	{ 0x0e6f, 0x0213, "Afterglow Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
	{ 0x0e6f, 0x021f, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
	{ 0x0e6f, 0x0301, "Logic3 Controller", 0, XTYPE_XBOX360 },
	{ 0x0e6f, 0x0401, "Logic3 Controller", 0, XTYPE_XBOX360 },
	{ 0x0e6f, 0x0413, "Afterglow AX.1 Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
	{ 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", 0, XTYPE_XBOX },
	{ 0x0e8f, 0x3008, "Generic xbox control (dealextreme)", 0, XTYPE_XBOX },
	{ 0x0f0d, 0x000a, "Hori Co. DOA4 FightStick", 0, XTYPE_XBOX360 },
	{ 0x0f0d, 0x000d, "Hori Fighting Stick EX2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x0f0d, 0x0067, "HORIPAD ONE", 0, XTYPE_XBOXONE },
	{ 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX },
	{ 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX },
	{ 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", 0, XTYPE_XBOX },
	{ 0x12ab, 0x0004, "Honey Bee Xbox360 dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x12ab, 0x0301, "PDP AFTERGLOW AX.1", 0, XTYPE_XBOX360 },
	{ 0x12ab, 0x8809, "Xbox DDR dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
	{ 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", 0, XTYPE_XBOX360 },
	{ 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
	{ 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 },
	{ 0x1532, 0x0037, "Razer Sabertooth", 0, XTYPE_XBOX360 },
	{ 0x1532, 0x0a03, "Razer Wildcat", 0, XTYPE_XBOXONE },
	{ 0x15e4, 0x3f00, "Power A Mini Pro Elite", 0, XTYPE_XBOX360 },
	{ 0x15e4, 0x3f0a, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 },
	{ 0x15e4, 0x3f10, "Batarang Xbox 360 controller", 0, XTYPE_XBOX360 },
	{ 0x162e, 0xbeef, "Joytech Neo-Se Take2", 0, XTYPE_XBOX360 },
	{ 0x1689, 0xfd00, "Razer Onza Tournament Edition", 0, XTYPE_XBOX360 },
	{ 0x1689, 0xfd01, "Razer Onza Classic Edition", 0, XTYPE_XBOX360 },
	{ 0x1689, 0xfe00, "Razer Sabertooth", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x1bad, 0xf016, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf018, "Mad Catz Street Fighter IV SE Fighting Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x1bad, 0xf019, "Mad Catz Brawlstick for Xbox 360", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x1bad, 0xf021, "Mad Cats Ghost Recon FS GamePad", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf023, "MLG Pro Circuit Controller (Xbox)", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf028, "Street Fighter IV FightPad", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf02e, "Mad Catz Fightpad", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x1bad, 0xf038, "Street Fighter IV FightStick TE", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf03a, "Mad Catz SFxT Fightstick Pro", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x1bad, 0xf900, "Harmonix Xbox 360 Controller", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf901, "Gamestop Xbox 360 Controller", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf903, "Tron Xbox 360 controller", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xfa01, "MadCatz GamePad", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0x5000, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x24c6, 0x5300, "PowerA MINI PROEX Controller", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0x5303, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0x531a, "PowerA Pro Ex", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0x5397, "FUS1ON Tournament Controller", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0x541a, "PowerA Xbox One Mini Wired Controller", 0, XTYPE_XBOXONE },
	{ 0x24c6, 0x542a, "Xbox ONE spectra", 0, XTYPE_XBOXONE },
	{ 0x24c6, 0x543a, "PowerA Xbox One wired controller", 0, XTYPE_XBOXONE },
	{ 0x24c6, 0x5500, "Hori XBOX 360 EX 2 with Turbo", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0x5501, "Hori Real Arcade Pro VX-SA", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0x5503, "Hori Fighting Edge", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x24c6, 0x5506, "Hori SOULCALIBUR V Stick", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0x550d, "Hori GEM Xbox controller", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0x5b02, "Thrustmaster, Inc. GPX Controller", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0x5b03, "Thrustmaster Ferrari 458 Racing Wheel", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0x5d04, "Razer Sabertooth", 0, XTYPE_XBOX360 },
	{ 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX },
	{ 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
};

struct XPadDevice
{
  uint8_t     type;
  uint16_t    idVendor;
  uint16_t    idProduct;
  const char* name;
};

#define GAMEPAD_XBOX				XTYPE_XBOX
#define GAMEPAD_XBOX_MAT			XTYPE_XBOX
#define GAMEPAD_XBOX360				XTYPE_XBOX360
#define GAMEPAD_XBOX360_GUITAR		XTYPE_XBOX360
#define GAMEPAD_XBOX360_WIRELESS	XTYPE_XBOX360W
#define GAMEPAD_XBOXONE				XTYPE_XBOXONE

static const struct XPadDevice xpad_devices[] = {
{ GAMEPAD_XBOX360,	0x12ab, 0x0004, "KonamiDancePad" },
{ GAMEPAD_XBOX360,	0x0f0d, 0x001b, "HoriRAPVX" },
{ GAMEPAD_XBOXONE,	0x24c6, 0x541a, "PowerAMiniXboxOne" },
{ GAMEPAD_XBOX360,	0x0738, 0x4738, "SF4StickTE" },
{ GAMEPAD_XBOX360,	0x0e6f, 0x0133, "Controller3" },
{ GAMEPAD_XBOX360,	0x045e, 0x028f, "Controller2" },
{ GAMEPAD_XBOX360,	0x24c6, 0x530a, "Xbox360ProEXController" },
{ GAMEPAD_XBOX360,	0x0e6f, 0xf701, "Controller4" },
{ GAMEPAD_XBOX360,	0x046d, 0xc21d, "LogitechF310" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf016, "MadCatzPad3" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf080, "MadCatzFightStickTE2" },
{ GAMEPAD_XBOX360,	0x0f0d, 0x000a, "HoriFightingStickEX2" },
{ GAMEPAD_XBOX360,	0x0f0d, 0x0016, "RAPEXSE" },
{ GAMEPAD_XBOX360,	0x045e, 0x0288, "MicrosoftXboxControllerS - 2" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf025, "MadCatzCallOfDuty" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf503, "HoriFSVX" },
{ GAMEPAD_XBOX360,	0x1bad, 0x0130, "IonDrumRocker" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf027, "MadCatzFPSPro" },
{ GAMEPAD_XBOX360,	0x24c6, 0xfafe, "RockCandyGamepadForXbox360 - 2" },
{ GAMEPAD_XBOX360,	0x24c6, 0x550d, "GEMPADEX" },
{ GAMEPAD_XBOX360,	0x1430, 0xf801, "RedOctaneController" },
{ GAMEPAD_XBOX360,	0x24c6, 0x5b00, "ThrustMasterFerrari458" },
{ GAMEPAD_XBOX360,	0x0e6f, 0x0131, "PDPEASports" },
{ GAMEPAD_XBOX360,	0x24c6, 0x5000, "RazerAtrox2" },
{ GAMEPAD_XBOX360,	0x045e, 0x0287, "MicrosoftXboxControllerS" },
{ GAMEPAD_XBOX360,	0x1430, 0x4748, "GuitarHero" },
{ GAMEPAD_XBOX360,	0x046d, 0xc261, "LogitechG920" },
{ GAMEPAD_XBOX360,	0x15e4, 0x3f10, "BatarangWired" },
{ GAMEPAD_XBOX360,	0x1689, 0x0001, "StrikeController" },
{ GAMEPAD_XBOX360,	0x0738, 0x4726, "MadCatzProGamepad" },
{ GAMEPAD_XBOX360,	0x24c6, 0x5397, "PowerAFUS1ONTournament" },
{ GAMEPAD_XBOX360,	0x0e6f, 0x0165, "PDPTitanfall2" },
{ GAMEPAD_XBOX360,	0x0738, 0xb738, "MVC2TEStick2" },
{ GAMEPAD_XBOX360,	0x0738, 0x9871, "MadCatzPortableDrum" },
{ GAMEPAD_XBOX360,	0x0738, 0xf738, "SSF4StickTE" },
{ GAMEPAD_XBOX360,	0x0738, 0x4758, "ArcadeGameStick" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf505, "HoriFightingStickEX2B" },
{ GAMEPAD_XBOX360,	0x0f0d, 0x000d, "HoriFightingStickEX2C" },
{ GAMEPAD_XBOX360,	0x24c6, 0x5b02, "ThrustmasterGPXLightback" },
{ GAMEPAD_XBOX360,	0x1689, 0xfd00, "RazerOnzaTE2" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf02e, "MadCatzFightPad" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf03e, "MadCatzMLGFightStickTE" },
{ GAMEPAD_XBOX360,	0x12ab, 0x0302, "GamestopGamepad" },
{ GAMEPAD_XBOX360,	0x0f0d, 0x000d, "HoriEX2" },
{ GAMEPAD_XBOXONE,	0x0e6f, 0x015c, "PDPXboxOneArcadeStick" },
{ GAMEPAD_XBOX360,	0x045e, 0x028e, "Controller" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf906, "XB360MortalKombatFightStick" },
{ GAMEPAD_XBOXONE,	0x0f0d, 0x0063, "HoriRAPHayabusaXboxOne" },
{ GAMEPAD_XBOXONE,	0x045e, 0x02e3, "MicrosoftXboxOneControllerElite" },
{ GAMEPAD_XBOX360,	0x0f0d, 0x000c, "HoriPadEXTurbo" },
{ GAMEPAD_XBOX360,	0x1bad, 0x0003, "RockBandDrums" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf023, "MLGGamePadforXbox360" },
{ GAMEPAD_XBOX360,	0x24c6, 0x5d04, "RazerSabertoothElite2" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf902, "MadCatzGamepad2" },
{ GAMEPAD_XBOX360,	0x046d, 0xf301, "GenericController" },
{ GAMEPAD_XBOX360,	0x0f0d, 0x0090, "HoriPadUltimate" },
{ GAMEPAD_XBOX360,	0x1bad, 0x028e, "HoriUnnamed2" },
{ GAMEPAD_XBOX360,	0x045e, 0x0289, "MicrosoftCorp.XboxControllerS - 2" },
{ GAMEPAD_XBOXONE,	0x24c6, 0x561a, "FUSIONXboxOne" },
{ GAMEPAD_XBOX360,	0x0e6f, 0x0413, "AfterglowGamepadForXbox360" },
{ GAMEPAD_XBOX360,	0x0738, 0xcb02, "SaitekCB360" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf03a, "MadCatzFightStickNeo" },
{ GAMEPAD_XBOXONE,	0x0f0d, 0x0067, "HoriPadOne" },
{ GAMEPAD_XBOX360,	0x24c6, 0x5500, "HoriPadEX2Turbo2" },
{ GAMEPAD_XBOX360,	0x0738, 0xcb29, "SaitekAV8R02" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf501, "HoriPadEX2Turbo1" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf502, "HoriRAPVXSA" },
{ GAMEPAD_XBOX360,	0x045e, 0x0288, "MicrosoftCorp.XboxControllerSHub" },
{ GAMEPAD_XBOX360,	0x11c0, 0x5506, "BETOPGAMEFORWINDOWS" },
{ GAMEPAD_XBOX360,	0x0e6f, 0xf900, "PDPAfterglowAX.1" },
{ GAMEPAD_XBOXONE,	0x24c6, 0x551a, "FUSIONProXboxOne" },
{ GAMEPAD_XBOX360,	0x044f, 0xb326, "ThrustMasterGPXGamepad" },
{ GAMEPAD_XBOX360,	0x146b, 0x0601, "BigBenController" },
{ GAMEPAD_XBOX360,	0x046d, 0xc21e, "LogitechF510" },
{ GAMEPAD_XBOX360,	0x0f0d, 0x000d, "SC4VF5Stick" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf03f, "MadCatzFightStickSoulCaliber" },
{ GAMEPAD_XBOXONE,	0x0e6f, 0x0161, "PDPXboxOne4" },
{ GAMEPAD_XBOXONE,	0x0e6f, 0x0163, "PDPXboxOne5" },
{ GAMEPAD_XBOX360,	0x1689, 0xfd01, "RazerOnza2" },
{ GAMEPAD_XBOXONE,	0x0e6f, 0x013a, "PDPXboxOne1" },
{ GAMEPAD_XBOXONE,	0x0e6f, 0x0162, "PDPXboxOne2" },
{ GAMEPAD_XBOXONE,	0x24c6, 0x561a, "PDPXboxOne3" },
{ GAMEPAD_XBOX360,	0x24c6, 0xfafd, "AfterglowGamepad3" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf907, "AfterglowGamepad2" },
{ GAMEPAD_XBOX360,	0x24c6, 0xfafc, "AfterglowGamepad1" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf0ca, "MadCatzGamepad3" },
{ GAMEPAD_XBOX360,	0x045e, 0x02e6, "AfterglowGamepad4" },
{ GAMEPAD_XBOXONE,	0x0e6f, 0x0139, "AfterglowPrismaticOne" },
{ GAMEPAD_XBOX360,	0x24c6, 0x531a, "PowerAMiniProEXGreen2" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf042, "MadCatzFightStickTES+" },
{ GAMEPAD_XBOX360,	0x15e4, 0x3f00, "PowerAMiniProEXGreen" },
{ GAMEPAD_XBOX360,	0xffff, 0xffff, "Chinese-madeXboxController" },
{ GAMEPAD_XBOX360,	0x1bad, 0xfd01, "RazerOnza" },
{ GAMEPAD_XBOXONE,	0x0e6f, 0x0346, "RockCandyGamepadforXboxOne2016" },
{ GAMEPAD_XBOXONE,	0x0e6f, 0x0246, "RockCandyGamepadforXboxOne2015" },
{ GAMEPAD_XBOXONE,	0x0e6f, 0x0146, "RockCandyGamepadforXboxOne2013" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf03d, "SSFIVTEChunLi" },
{ GAMEPAD_XBOXONE,	0x045e, 0x02d1, "MicrosoftXboxOneController2013" },
{ GAMEPAD_XBOX360,	0x0e6f, 0x011f, "RockCandy" },
{ GAMEPAD_XBOX360,	0x24c6, 0xfafb, "AplayController" },
{ GAMEPAD_XBOXONE,	0x0f0d, 0x0078, "HoriRAPVKaiXboxOne" },
{ GAMEPAD_XBOX360,	0x045e, 0x02a0, "MicrosoftBigButtonController" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf900, "PDPAfterglow" },
{ GAMEPAD_XBOXONE,	0x0e6f, 0x0164, "PDPBattlefieldOne" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf904, "PDPVersusPad" },
{ GAMEPAD_XBOX360,	0x1bad, 0x5500, "HoriUnnamed" },
{ GAMEPAD_XBOX360,	0x045e, 0x0202, "MicrosoftX-Boxpadv1(US)" },
{ GAMEPAD_XBOX360,	0x0e6f, 0x0201, "TSZPelican" },
{ GAMEPAD_XBOX360,	0x24c6, 0x5300, "PowerAMiniProEXWhite" },
{ GAMEPAD_XBOX360,	0x0738, 0xbeef, "QanBaJoystickPlus" },
{ GAMEPAD_XBOXONE,	0x24c6, 0x543a, "PowerAMiniXboxOne2" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf506, "HORI Real Arcade Pro.EX Premium VLX" },
{ GAMEPAD_XBOX360,	0x0738, 0x4736, "MadCatzMicroGamepad" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf038, "SF4StickTER2" },
{ GAMEPAD_XBOX360,	0x1430, 0x02a0, "RedOctaneControllerAdapter" },
{ GAMEPAD_XBOX360,	0x15e4, 0x3f0a, "PowerAAirflow" },
{ GAMEPAD_XBOX360,	0x24c6, 0x5502, "HoriFSVXAlt" },
{ GAMEPAD_XBOX360,	0x0e6f, 0xf501, "Counterfeit360Controller2" },
{ GAMEPAD_XBOXONE,	0x0e6f, 0x0147, "PDPMarvelXboxOneController" },
{ GAMEPAD_XBOX360,	0x0e6f, 0x02a0, "Counterfeit360Controller1" },
{ GAMEPAD_XBOX360,	0x0e6f, 0x0113, "PDPAfterglowAX1" },
{ GAMEPAD_XBOX360,	0x162e, 0xbeef, "JoytekXbox360" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf019, "MadCatzBrawlStick" },
{ GAMEPAD_XBOX360,	0x0e6f, 0x021f, "RockCandyGamepadForXbox360" },
{ GAMEPAD_XBOX360,	0x1689, 0xfe00, "RazerSabertoothElite" },
{ GAMEPAD_XBOX360,	0x0810, 0x0003, "TrustPredator" },
{ GAMEPAD_XBOX360,	0x046d, 0xcaa3, "LogitechDriveFx" },
{ GAMEPAD_XBOX360,	0x24c6, 0x5b03, "ThrustMasterFerrari458Italia" },
{ GAMEPAD_XBOX360,	0x12ab, 0x0301, "PDPAfterglowV3" },
{ GAMEPAD_XBOX360,	0x0e6f, 0x0213, "PDPAfterglowV2" },
{ GAMEPAD_XBOX360,	0x1bad, 0xfd00, "RazerOnzaTE" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf028, "SF4FightPad" },
{ GAMEPAD_XBOXONE,	0x24c6, 0x542a, "PowerASpectraIlluminatedXboxOne" },
{ GAMEPAD_XBOX360,	0x24c6, 0x550e, "HoriRAPVKai360" },
{ GAMEPAD_XBOX360,	0x11c9, 0x55f0, "NaconGC100XF" },
{ GAMEPAD_XBOX360,	0x12ab, 0x0303, "MKKlassicFightStick" },
{ GAMEPAD_XBOX360,	0x046d, 0xc242, "LogitechChillStream" },
{ GAMEPAD_XBOXONE,	0x24c6, 0x543a, "XboxOneProEXController" },
{ GAMEPAD_XBOXONE,	0x045e, 0x02ea, "MicrosoftXboxOneController2016" },
{ GAMEPAD_XBOX360,	0x1bad, 0xfa01, "HoriUnnamedBlueSolo" },
{ GAMEPAD_XBOXONE,	0x045e, 0x02dd, "MicrosoftXboxOneController2015" },
{ GAMEPAD_XBOX360,	0x0f0d, 0x000a, "DOA4Stick" },
{ GAMEPAD_XBOX360,	0x0e6f, 0x0301, "GameStopGamepad4" },
{ GAMEPAD_XBOX360,	0x1532, 0x0a03, "RazerWildcat" },
{ GAMEPAD_XBOX360,	0x0e6f, 0x0401, "GameStopGamepad3" },
{ GAMEPAD_XBOX360,	0x0738, 0x4728, "SF4FightPad2" },
{ GAMEPAD_XBOX360,	0x046d, 0xc21f, "LogitechF710" },
{ GAMEPAD_XBOX360,	0x0738, 0x4718, "SF4StickSE" },
{ GAMEPAD_XBOX360,	0x1532, 0x0a00, "RazerAtrox" },
{ GAMEPAD_XBOX360,	0x1bad, 0x0002, "RockBandGuitar" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf504, "REALARCADEPROEX" },
{ GAMEPAD_XBOX360,	0x0738, 0x4736, "MadCatzMicroConGamepad" },
{ GAMEPAD_XBOX360,	0x045e, 0x0285, "MicrosoftX-Boxpad(Japan)" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf039, "MVC2TEStick" },
{ GAMEPAD_XBOX360,	0x0e6f, 0x0501, "PDPXbox360" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf901, "GamestopGamepad2" },
{ GAMEPAD_XBOX360,	0x1bad, 0xf903, "PDPTron" },
{ GAMEPAD_XBOX360,	0x0738, 0x4716, "MadCatzGamepad" },
  {NULL}
};

static const char* print_xtype(uint8_t type) {
	switch (type) {
	case XTYPE_XBOX:
		return "XTYPE_XBOX";
	case XTYPE_XBOX360:
		return "XTYPE_XBOX360";
	case XTYPE_XBOX360W:
		return "XTYPE_XBOX360W";
	case XTYPE_XBOXONE:
		return "XTYPE_XBOXONE";
	default:
		return "XTYPE_UNKNOWN";
	}
}

static const char* get_flags(const char* name) {
	if (strcasestr(name, "stick"))
		return "MAP_TRIGGERS_TO_BUTTONS";
	if (strcasestr(name, "Fight"))
		return "MAP_TRIGGERS_TO_BUTTONS";
	return "0";
}

static bool is_in_linux(const struct xpad_device* xpad, const struct XPadDevice* xbxdrv) {
	for (; xpad->idVendor; ++xpad) {
		if (xpad->idVendor == xbxdrv->idVendor && xpad->idProduct == xbxdrv->idProduct)
			return true;
	}

	return false;
}

static bool vendor_is_in_linux(const struct xpad_device* xpad, const struct XPadDevice* xbxdrv) {
	for (; xpad->idVendor; ++xpad) {
		if (xpad->idVendor == xbxdrv->idVendor)
			return true;
	}

	return false;
}

static void compare_linux_xboxdrv(const struct xpad_device* xpad, const struct XPadDevice* xbxdrv) {
	for (; xbxdrv->idVendor; ++xbxdrv) {
		if (!is_in_linux(xpad, xbxdrv))
			printf("\t{ 0x%04x, 0x%04x, \"%s\", %s, %s },\n", xbxdrv->idVendor, xbxdrv->idProduct, xbxdrv->name, get_flags(xbxdrv->name), print_xtype(xbxdrv->type));
	}
}

static char* vendor_macro(uint8_t type) {
	switch (type) {
	case XTYPE_XBOX360:
	case XTYPE_XBOX360W:
		return "XPAD_XBOX360_VENDOR";
	case XTYPE_XBOXONE:
		return "XPAD_XBOXONE_VENDOR";
	default:
		return NULL;
	}
}

static void compare_linux_xboxdrv_vendor(const struct xpad_device* xpad, const struct XPadDevice* xbxdrv) {
	for (; xbxdrv->idVendor; ++xbxdrv) {
		if (!vendor_is_in_linux(xpad, xbxdrv)) {
			printf("\t%s(0x%04x),\t\t /* %s */\n", vendor_macro(xbxdrv->type), xbxdrv->idVendor, xbxdrv->name);
		}
	}
}

int main(void) {
	compare_linux_xboxdrv(&xpad_device, &xpad_devices);
	printf("----------\n");
	compare_linux_xboxdrv_vendor(&xpad_device, &xpad_devices);

	return 0;
}


Output:
	{ 0x0f0d, 0x001b, "HoriRAPVX", 0, XTYPE_XBOX360 },
	{ 0x0e6f, 0x0133, "Controller3", 0, XTYPE_XBOX360 },
	{ 0x045e, 0x028f, "Controller2", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0x530a, "Xbox360ProEXController", 0, XTYPE_XBOX360 },
	{ 0x0e6f, 0xf701, "Controller4", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf080, "MadCatzFightStickTE2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x045e, 0x0288, "MicrosoftXboxControllerS - 2", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf025, "MadCatzCallOfDuty", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf503, "HoriFSVX", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0x0130, "IonDrumRocker", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf027, "MadCatzFPSPro", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0xfafe, "RockCandyGamepadForXbox360 - 2", 0, XTYPE_XBOX360 },
	{ 0x1430, 0xf801, "RedOctaneController", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0x5b00, "ThrustMasterFerrari458", 0, XTYPE_XBOX360 },
	{ 0x0e6f, 0x0131, "PDPEASports", 0, XTYPE_XBOX360 },
	{ 0x046d, 0xc261, "LogitechG920", 0, XTYPE_XBOX360 },
	{ 0x1689, 0x0001, "StrikeController", 0, XTYPE_XBOX360 },
	{ 0x0e6f, 0x0165, "PDPTitanfall2", 0, XTYPE_XBOX360 },
	{ 0x0738, 0xb738, "MVC2TEStick2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x0738, 0x9871, "MadCatzPortableDrum", 0, XTYPE_XBOX360 },
	{ 0x0738, 0x4758, "ArcadeGameStick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x1bad, 0xf505, "HoriFightingStickEX2B", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x1bad, 0xf03e, "MadCatzMLGFightStickTE", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x12ab, 0x0302, "GamestopGamepad", 0, XTYPE_XBOX360 },
	{ 0x0e6f, 0x015c, "PDPXboxOneArcadeStick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
	{ 0x1bad, 0xf906, "XB360MortalKombatFightStick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x0f0d, 0x0063, "HoriRAPHayabusaXboxOne", 0, XTYPE_XBOXONE },
	{ 0x0f0d, 0x000c, "HoriPadEXTurbo", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf902, "MadCatzGamepad2", 0, XTYPE_XBOX360 },
	{ 0x046d, 0xf301, "GenericController", 0, XTYPE_XBOX360 },
	{ 0x0f0d, 0x0090, "HoriPadUltimate", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0x028e, "HoriUnnamed2", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0x561a, "FUSIONXboxOne", 0, XTYPE_XBOXONE },
	{ 0x0738, 0xcb29, "SaitekAV8R02", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf501, "HoriPadEX2Turbo1", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf502, "HoriRAPVXSA", 0, XTYPE_XBOX360 },
	{ 0x045e, 0x0288, "MicrosoftCorp.XboxControllerSHub", 0, XTYPE_XBOX360 },
	{ 0x11c0, 0x5506, "BETOPGAMEFORWINDOWS", 0, XTYPE_XBOX360 },
	{ 0x0e6f, 0xf900, "PDPAfterglowAX.1", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0x551a, "FUSIONProXboxOne", 0, XTYPE_XBOXONE },
	{ 0x1bad, 0xf03f, "MadCatzFightStickSoulCaliber", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x0e6f, 0x0161, "PDPXboxOne4", 0, XTYPE_XBOXONE },
	{ 0x0e6f, 0x0163, "PDPXboxOne5", 0, XTYPE_XBOXONE },
	{ 0x0e6f, 0x013a, "PDPXboxOne1", 0, XTYPE_XBOXONE },
	{ 0x0e6f, 0x0162, "PDPXboxOne2", 0, XTYPE_XBOXONE },
	{ 0x24c6, 0x561a, "PDPXboxOne3", 0, XTYPE_XBOXONE },
	{ 0x24c6, 0xfafd, "AfterglowGamepad3", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf907, "AfterglowGamepad2", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0xfafc, "AfterglowGamepad1", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf0ca, "MadCatzGamepad3", 0, XTYPE_XBOX360 },
	{ 0x045e, 0x02e6, "AfterglowGamepad4", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf042, "MadCatzFightStickTES+", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x1bad, 0xfd01, "RazerOnza", 0, XTYPE_XBOX360 },
	{ 0x0e6f, 0x0346, "RockCandyGamepadforXboxOne2016", 0, XTYPE_XBOXONE },
	{ 0x0e6f, 0x0246, "RockCandyGamepadforXboxOne2015", 0, XTYPE_XBOXONE },
	{ 0x1bad, 0xf03d, "SSFIVTEChunLi", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0xfafb, "AplayController", 0, XTYPE_XBOX360 },
	{ 0x0f0d, 0x0078, "HoriRAPVKaiXboxOne", 0, XTYPE_XBOXONE },
	{ 0x045e, 0x02a0, "MicrosoftBigButtonController", 0, XTYPE_XBOX360 },
	{ 0x0e6f, 0x0164, "PDPBattlefieldOne", 0, XTYPE_XBOXONE },
	{ 0x1bad, 0xf904, "PDPVersusPad", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0x5500, "HoriUnnamed", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf506, "HORI Real Arcade Pro.EX Premium VLX", 0, XTYPE_XBOX360 },
	{ 0x0738, 0x4736, "MadCatzMicroGamepad", 0, XTYPE_XBOX360 },
	{ 0x1430, 0x02a0, "RedOctaneControllerAdapter", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0x5502, "HoriFSVXAlt", 0, XTYPE_XBOX360 },
	{ 0x0e6f, 0xf501, "Counterfeit360Controller2", 0, XTYPE_XBOX360 },
	{ 0x0e6f, 0x0147, "PDPMarvelXboxOneController", 0, XTYPE_XBOXONE },
	{ 0x0e6f, 0x02a0, "Counterfeit360Controller1", 0, XTYPE_XBOX360 },
	{ 0x0810, 0x0003, "TrustPredator", 0, XTYPE_XBOX360 },
	{ 0x046d, 0xcaa3, "LogitechDriveFx", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xfd00, "RazerOnzaTE", 0, XTYPE_XBOX360 },
	{ 0x24c6, 0x550e, "HoriRAPVKai360", 0, XTYPE_XBOX360 },
	{ 0x11c9, 0x55f0, "NaconGC100XF", 0, XTYPE_XBOX360 },
	{ 0x12ab, 0x0303, "MKKlassicFightStick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x1532, 0x0a00, "RazerAtrox", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf504, "REALARCADEPROEX", 0, XTYPE_XBOX360 },
	{ 0x0738, 0x4736, "MadCatzMicroConGamepad", 0, XTYPE_XBOX360 },
	{ 0x1bad, 0xf039, "MVC2TEStick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
	{ 0x0e6f, 0x0501, "PDPXbox360", 0, XTYPE_XBOX360 },
----------
	XPAD_XBOX360_VENDOR(0x11c0),		 /* BETOPGAMEFORWINDOWS */
	XPAD_XBOX360_VENDOR(0x0810),		 /* TrustPredator */
	XPAD_XBOX360_VENDOR(0x11c9),		 /* NaconGC100XF */


Create a new paste based on this one


Comments: