summaryrefslogtreecommitdiff
path: root/emulators/ppsspp/files/extra-patch-old-joy
blob: 2c21cf9cb720691298ab5f2186b29ad49f4ae009 (plain) (blame)
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
The patch reverts SDL_GameController API usage from:

https://github.com/hrydgard/ppsspp/commit/67425d7d477d
https://github.com/hrydgard/ppsspp/commit/db2cc49e0dd1
https://github.com/hrydgard/ppsspp/commit/e4a0a3cea3bc
https://github.com/hrydgard/ppsspp/commit/182b9e0fdae3
https://github.com/hrydgard/ppsspp/commit/d6b81236626f
https://github.com/hrydgard/ppsspp/commit/b058b987ad0f
https://github.com/hrydgard/ppsspp/commit/1b699363ca4d

--- SDL/SDLJoystick.cpp.orig	2017-03-30 12:14:27 UTC
+++ SDL/SDLJoystick.cpp
@@ -1,12 +1,7 @@
 #include "SDL/SDLJoystick.h"
 #include "Core/Config.h"
-#include "Common/FileUtil.h"
-#include "file/vfs.h"
 
 #include <iostream>
-#include <string>
-
-using namespace std;
 
 static int SDLJoystickEventHandlerWrapper(void* userdata, SDL_Event* event)
 {
@@ -17,65 +12,32 @@ static int SDLJoystickEventHandlerWrappe
 SDLJoystick::SDLJoystick(bool init_SDL ) : registeredAsEventHandler(false) {
 	SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
 	if (init_SDL) {
-		SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER);
-	}
-
-	const char *dbPath = "gamecontrollerdb.txt";
-	cout << "loading control pad mappings from " << dbPath << ": ";
-
-	size_t size;
-	u8 *mappingData = VFSReadFile(dbPath, &size);
-	if (mappingData) {
-		SDL_RWops *rw = SDL_RWFromConstMem(mappingData, size);
-		// 1 to free the rw after use
-		if (SDL_GameControllerAddMappingsFromRW(rw, 1) == -1) {
-			cout << "Failed to read mapping data - corrupt?" << endl;
-		}
-		delete[] mappingData;
-	} else {
-		cout << "gamecontrollerdb.txt missing" << endl;
+		SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO);
 	}
-	cout << "SUCCESS!" << endl;
-	setUpControllers();
-}
 
-void SDLJoystick::setUpControllers() {
 	int numjoys = SDL_NumJoysticks();
+	SDL_JoystickEventState(SDL_ENABLE);
 	for (int i = 0; i < numjoys; i++) {
-		setUpController(i);
-	}
-	if (controllers.size() > 0) {
-		cout << "pad 1 has been assigned to control pad: " << SDL_GameControllerName(controllers.front()) << endl;
+		joys.push_back(SDL_JoystickOpen(i));
+//		printf("Initialized joystick %d: %s",i,SDL_JoystickNameForIndex(i));
+		if(strstr(SDL_JoystickNameForIndex(i),"PLAYSTATION(R)3 Controller"))
+			g_Config.bPS3Controller = true;
 	}
-}
 
-void SDLJoystick::setUpController(int deviceIndex) {
-	if (SDL_IsGameController(deviceIndex)) {
-		SDL_GameController *controller = SDL_GameControllerOpen(deviceIndex);
-		if (controller) {
-			if (SDL_GameControllerGetAttached(controller)) {
-				controllers.push_back(controller);
-				controllerDeviceMap[SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(controller))] = deviceIndex;
-				cout << "found control pad: " << SDL_GameControllerName(controller) << ", loading mapping: ";
-				auto mapping = SDL_GameControllerMapping(controller);
-				if (mapping == NULL) {
-					cout << "FAILED" << endl;
-				} else {
-					cout << "SUCCESS, mapping is:" << endl << mapping << endl;
-				}
-			} else {
-				SDL_GameControllerClose(controller);
-			}
-		}
-	}
+        if (g_Config.bPS3Controller)
+                fillMappingPS3();
+        else
+                fillMapping();
+
+
 }
 
 SDLJoystick::~SDLJoystick() {
 	if (registeredAsEventHandler) {
 		SDL_DelEventWatch(SDLJoystickEventHandlerWrapper, this);
 	}
-	for (auto & controller : controllers) {
-		SDL_GameControllerClose(controller);
+	for (SDL_Joystick *joy : joys) {
+		SDL_JoystickClose(joy);
 	}
 }
 
@@ -84,107 +46,124 @@ void SDLJoystick::registerEventHandler()
 	registeredAsEventHandler = true;
 }
 
-keycode_t SDLJoystick::getKeycodeForButton(SDL_GameControllerButton button) {
-	switch (button) {
-	case SDL_CONTROLLER_BUTTON_DPAD_UP:
-		return NKCODE_DPAD_UP;
-	case SDL_CONTROLLER_BUTTON_DPAD_DOWN:
-		return NKCODE_DPAD_DOWN;
-	case SDL_CONTROLLER_BUTTON_DPAD_LEFT:
-		return NKCODE_DPAD_LEFT;
-	case SDL_CONTROLLER_BUTTON_DPAD_RIGHT:
-		return NKCODE_DPAD_RIGHT;
-	case SDL_CONTROLLER_BUTTON_A:
-		return NKCODE_BUTTON_2;
-	case SDL_CONTROLLER_BUTTON_B:
-		return NKCODE_BUTTON_3;
-	case SDL_CONTROLLER_BUTTON_X:
-		return NKCODE_BUTTON_4;
-	case SDL_CONTROLLER_BUTTON_Y:
-		return NKCODE_BUTTON_1;
-	case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER:
-		return NKCODE_BUTTON_5;
-	case SDL_CONTROLLER_BUTTON_LEFTSHOULDER:
-		return NKCODE_BUTTON_6;
-	case SDL_CONTROLLER_BUTTON_START:
-		return NKCODE_BUTTON_10;
-	case SDL_CONTROLLER_BUTTON_BACK:
-		return NKCODE_BUTTON_9; // select button
-	case SDL_CONTROLLER_BUTTON_GUIDE:
-		return NKCODE_BACK; // pause menu
-	case SDL_CONTROLLER_BUTTON_LEFTSTICK:
-		return NKCODE_BUTTON_THUMBL;
-	case SDL_CONTROLLER_BUTTON_RIGHTSTICK:
-		return NKCODE_BUTTON_THUMBR;
-	case SDL_CONTROLLER_BUTTON_INVALID:
-	default:
-		return NKCODE_UNKNOWN;
-	}
-}
-
 void SDLJoystick::ProcessInput(SDL_Event &event){
 	switch (event.type) {
-	case SDL_CONTROLLERBUTTONDOWN:
-		if (event.cbutton.state == SDL_PRESSED) {
-			auto code = getKeycodeForButton((SDL_GameControllerButton)event.cbutton.button);
-			if (code != NKCODE_UNKNOWN) {
+	case SDL_JOYAXISMOTION:
+		{
+			std::map<int, int>::const_iterator i = SDLJoyAxisMap.find(event.jaxis.axis);
+			int deviceIndex = getDeviceIndex(event.jaxis.which);
+			if (i != SDLJoyAxisMap.end() && deviceIndex >= 0) {
+				AxisInput axis;
+				axis.axisId = i->second;
+				// 1.2 to try to approximate the PSP's clamped rectangular range.
+				axis.value = 1.2 * event.jaxis.value / 32767.0f;
+				if (axis.value > 1.0f) axis.value = 1.0f;
+				if (axis.value < -1.0f) axis.value = -1.0f;
+				axis.deviceId = DEVICE_ID_PAD_0 + deviceIndex;
+				axis.flags = 0;
+				NativeAxis(axis);
+			}
+			break;
+		}
+
+	case SDL_JOYBUTTONDOWN:
+		{
+			std::map<int, int>::const_iterator i = SDLJoyButtonMap.find(event.jbutton.button);
+			int deviceIndex = getDeviceIndex(event.jbutton.which);
+			if (i != SDLJoyButtonMap.end() && deviceIndex >= 0) {
 				KeyInput key;
 				key.flags = KEY_DOWN;
-				key.keyCode = code;
-				key.deviceId = DEVICE_ID_PAD_0 + getDeviceIndex(event.cbutton.which);
+				key.keyCode = i->second;
+				key.deviceId = DEVICE_ID_PAD_0 + deviceIndex;
 				NativeKey(key);
 			}
+			break;
 		}
-		break;
-	case SDL_CONTROLLERBUTTONUP:
-		if (event.cbutton.state == SDL_RELEASED) {
-			auto code = getKeycodeForButton((SDL_GameControllerButton)event.cbutton.button);
-			if (code != NKCODE_UNKNOWN) {
+
+	case SDL_JOYBUTTONUP:
+		{
+			std::map<int, int>::const_iterator i = SDLJoyButtonMap.find(event.jbutton.button);
+			int deviceIndex = getDeviceIndex(event.jbutton.which);
+			if (i != SDLJoyButtonMap.end() && deviceIndex >= 0) {
 				KeyInput key;
 				key.flags = KEY_UP;
-				key.keyCode = code;
-				key.deviceId = DEVICE_ID_PAD_0 + getDeviceIndex(event.cbutton.which);
+				key.keyCode = i->second;
+				key.deviceId = DEVICE_ID_PAD_0 + deviceIndex;
 				NativeKey(key);
 			}
+			break;
 		}
-		break;
-	case SDL_CONTROLLERAXISMOTION:
-		AxisInput axis;
-		axis.axisId = event.caxis.axis;
-		// 1.2 to try to approximate the PSP's clamped rectangular range.
-		axis.value = 1.2 * event.caxis.value / 32767.0f;
-		if (axis.value > 1.0f) axis.value = 1.0f;
-		if (axis.value < -1.0f) axis.value = -1.0f;
-		axis.deviceId = DEVICE_ID_PAD_0 + getDeviceIndex(event.caxis.which);
-		axis.flags = 0;
-		NativeAxis(axis);
-		break;
-	case SDL_CONTROLLERDEVICEREMOVED:
-		// for removal events, "which" is the instance ID for SDL_CONTROLLERDEVICEREMOVED		
-		for (auto it = controllers.begin(); it != controllers.end(); ++it) {
-			if (SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(*it)) == event.cdevice.which) {
-				SDL_GameControllerClose(*it);
-				controllers.erase(it);
+
+	case SDL_JOYHATMOTION:
+		{
+			int deviceIndex = getDeviceIndex(event.jhat.which);
+			if (deviceIndex < 0) {
 				break;
 			}
+#ifdef _WIN32
+			KeyInput key;
+			key.deviceId = DEVICE_ID_PAD_0 + deviceIndex;
+
+			key.flags = (event.jhat.value & SDL_HAT_UP)?KEY_DOWN:KEY_UP;
+			key.keyCode = NKCODE_DPAD_UP;
+			NativeKey(key);
+			key.flags = (event.jhat.value & SDL_HAT_LEFT)?KEY_DOWN:KEY_UP;
+			key.keyCode = NKCODE_DPAD_LEFT;
+			NativeKey(key);
+			key.flags = (event.jhat.value & SDL_HAT_DOWN)?KEY_DOWN:KEY_UP;
+			key.keyCode = NKCODE_DPAD_DOWN;
+			NativeKey(key);
+			key.flags = (event.jhat.value & SDL_HAT_RIGHT)?KEY_DOWN:KEY_UP;
+			key.keyCode = NKCODE_DPAD_RIGHT;
+			NativeKey(key);
+#else
+			AxisInput axisX;
+			AxisInput axisY;
+			axisX.axisId = JOYSTICK_AXIS_HAT_X;
+			axisY.axisId = JOYSTICK_AXIS_HAT_Y;
+			axisX.deviceId = DEVICE_ID_PAD_0 + deviceIndex;
+			axisY.deviceId = DEVICE_ID_PAD_0 + deviceIndex;
+			axisX.value = 0.0f;
+			axisY.value = 0.0f;
+			if (event.jhat.value & SDL_HAT_LEFT) axisX.value = -1.0f;
+			if (event.jhat.value & SDL_HAT_RIGHT) axisX.value = 1.0f;
+			if (event.jhat.value & SDL_HAT_DOWN) axisY.value = 1.0f;
+			if (event.jhat.value & SDL_HAT_UP) axisY.value = -1.0f;
+			NativeAxis(axisX);
+			NativeAxis(axisY);
+#endif
+			break;
 		}
-		break;
-	case SDL_CONTROLLERDEVICEADDED:
-		// for add events, "which" is the device index!
-		int prevNumControllers = controllers.size();
-		setUpController(event.cdevice.which);
-		if (prevNumControllers == 0 && controllers.size() > 0) {
-			cout << "pad 1 has been assigned to control pad: " << SDL_GameControllerName(controllers.front()) << endl;
+
+	case SDL_JOYDEVICEADDED:
+		{
+			int deviceIndex = event.jdevice.which;
+			if (deviceIndex >= joys.size()) {
+				joys.resize(deviceIndex+1);
+			}
+			joys[deviceIndex] = SDL_JoystickOpen(deviceIndex);
+			SDL_JoystickEventState(SDL_ENABLE);
+			break;
+		}
+
+	case SDL_JOYDEVICEREMOVED:
+		{
+			int deviceIndex = getDeviceIndex(event.jdevice.which);
+			if (deviceIndex >= 0) {
+				SDL_JoystickClose(joys[deviceIndex]);
+				joys[deviceIndex] = 0;
+			}
+			break;
 		}
-		break;
 	}
 }
 
 int SDLJoystick::getDeviceIndex(int instanceId) {
-	auto it = controllerDeviceMap.find(instanceId);
-	if (it == controllerDeviceMap.end()) {
-			// could not find device
-			return -1;
+	for (int i = 0; i < joys.size(); i++) {
+		SDL_Joystick *joy = joys[i];
+		if (SDL_JoystickInstanceID(joy) == instanceId) {
+			return i;
+		}
 	}
-	return it->second;
+	return -1;
 }
--- SDL/SDLJoystick.h.orig	2017-03-30 12:14:27 UTC
+++ SDL/SDLJoystick.h
@@ -1,9 +1,11 @@
 #pragma once
 #ifdef _WIN32
 #include "SDL/SDL.h"
+#include "SDL/SDL_joystick.h"
 #include "SDL/SDL_thread.h"
 #else
 #include "SDL.h"
+#include "SDL_joystick.h"
 #include "SDL_thread.h"
 #endif
 
@@ -21,11 +23,119 @@ public:
 	void ProcessInput(SDL_Event &event);
 
 private:
-	void setUpController(int deviceIndex);
-	void setUpControllers();
-	keycode_t getKeycodeForButton(SDL_GameControllerButton button);
-	int getDeviceIndex(int instanceId);
+	void fillMappingPS3()
+	{
+                SDLJoyButtonMap[14] = NKCODE_BUTTON_1;   // Cross
+                SDLJoyButtonMap[13] = NKCODE_BUTTON_2;   // Circle
+                SDLJoyButtonMap[15] = NKCODE_BUTTON_3;   // Sqlare
+                SDLJoyButtonMap[12] = NKCODE_BUTTON_4;   // Triangle
+                SDLJoyButtonMap[10] = NKCODE_BUTTON_5;   // L1
+                SDLJoyButtonMap[11] = NKCODE_BUTTON_6;   // R1
+                SDLJoyButtonMap[8] = NKCODE_BUTTON_7;   // L2
+                SDLJoyButtonMap[9] = NKCODE_BUTTON_8;   // R2
+                SDLJoyButtonMap[0] = NKCODE_BUTTON_9;   // Select
+                SDLJoyButtonMap[3] = NKCODE_BUTTON_10;  // Start
+                SDLJoyButtonMap[1] = NKCODE_BUTTON_11; // L3
+                SDLJoyButtonMap[2] = NKCODE_BUTTON_12; // R3
+                SDLJoyButtonMap[16] = NKCODE_BUTTON_13; // PS
+                SDLJoyButtonMap[4] = NKCODE_DPAD_UP;
+                SDLJoyButtonMap[6] = NKCODE_DPAD_DOWN;
+                SDLJoyButtonMap[7] = NKCODE_DPAD_LEFT;
+                SDLJoyButtonMap[5] = NKCODE_DPAD_RIGHT;
+                SDLJoyAxisMap[0] = JOYSTICK_AXIS_X;
+                SDLJoyAxisMap[1] = JOYSTICK_AXIS_Y;
+                SDLJoyAxisMap[2] = JOYSTICK_AXIS_Z;
+                SDLJoyAxisMap[3] = JOYSTICK_AXIS_RZ;
+	}
+	void fillMapping()
+	{
+		//TODO: C++11 aggregate initialization
+		//would remove runtime overhead completely
+
+		// Mapping on Windows
+#ifdef _WIN32
+		SDLJoyButtonMap[0] = NKCODE_BUTTON_2;
+		SDLJoyButtonMap[1] = NKCODE_BUTTON_3;
+		SDLJoyButtonMap[2] = NKCODE_BUTTON_4;
+		SDLJoyButtonMap[3] = NKCODE_BUTTON_1;
+		SDLJoyButtonMap[4] = NKCODE_BUTTON_7;
+		SDLJoyButtonMap[5] = NKCODE_BUTTON_8;
+		SDLJoyButtonMap[6] = NKCODE_BUTTON_9;
+		SDLJoyButtonMap[7] = NKCODE_BUTTON_10;
+		SDLJoyButtonMap[8] = NKCODE_BUTTON_11;
+		SDLJoyButtonMap[9] = NKCODE_BUTTON_12;
+		SDLJoyButtonMap[10] = NKCODE_BUTTON_5;
+		SDLJoyButtonMap[11] = NKCODE_BUTTON_6;
+		SDLJoyButtonMap[12] = NKCODE_BUTTON_7;
+		SDLJoyButtonMap[13] = NKCODE_BUTTON_8;
+		SDLJoyButtonMap[14] = NKCODE_BUTTON_9;
+
+		SDLJoyAxisMap[0] = JOYSTICK_AXIS_X;
+		SDLJoyAxisMap[1] = JOYSTICK_AXIS_Y;
+		SDLJoyAxisMap[2] = JOYSTICK_AXIS_Z;
+		SDLJoyAxisMap[3] = JOYSTICK_AXIS_RZ;
+		SDLJoyAxisMap[4] = JOYSTICK_AXIS_LTRIGGER;
+		SDLJoyAxisMap[5] = JOYSTICK_AXIS_RTRIGGER;
+		// Mapping on MacOSX to match X360 controller
+#elif __APPLE__
+		SDLJoyButtonMap[0] = NKCODE_DPAD_UP;
+		SDLJoyButtonMap[1] = NKCODE_DPAD_DOWN;
+		SDLJoyButtonMap[2] = NKCODE_DPAD_LEFT;
+		SDLJoyButtonMap[3] = NKCODE_DPAD_RIGHT;
+		SDLJoyButtonMap[4] = NKCODE_BUTTON_10;
+		SDLJoyButtonMap[5] = NKCODE_BUTTON_9;
+		SDLJoyButtonMap[6] = NKCODE_BUTTON_5;
+		SDLJoyButtonMap[7] = NKCODE_BUTTON_6;
+		SDLJoyButtonMap[8] = NKCODE_BUTTON_7;
+		SDLJoyButtonMap[9] = NKCODE_BUTTON_8;
+		SDLJoyButtonMap[10] = NKCODE_BUTTON_SELECT;
+		SDLJoyButtonMap[11] = NKCODE_BUTTON_2;
+		SDLJoyButtonMap[12] = NKCODE_BUTTON_3;
+		SDLJoyButtonMap[13] = NKCODE_BUTTON_4;
+		SDLJoyButtonMap[14] = NKCODE_BUTTON_1;
+		SDLJoyButtonMap[15] = NKCODE_BUTTON_11;
+		SDLJoyButtonMap[16] = NKCODE_BUTTON_12;
+
+		SDLJoyAxisMap[0] = JOYSTICK_AXIS_X;
+		SDLJoyAxisMap[1] = JOYSTICK_AXIS_Y;
+		SDLJoyAxisMap[2] = JOYSTICK_AXIS_Z;
+		SDLJoyAxisMap[3] = JOYSTICK_AXIS_RZ;
+		SDLJoyAxisMap[4] = JOYSTICK_AXIS_LTRIGGER;
+		SDLJoyAxisMap[5] = JOYSTICK_AXIS_RTRIGGER;
+		// Mapping on Linux/Android/Other to match X360 and wii-u pro controller
+#else
+		SDLJoyButtonMap[0] = NKCODE_BUTTON_1;
+		SDLJoyButtonMap[1] = NKCODE_BUTTON_2;
+		SDLJoyButtonMap[2] = NKCODE_BUTTON_3;
+		SDLJoyButtonMap[3] = NKCODE_BUTTON_4;
+		SDLJoyButtonMap[4] = NKCODE_BUTTON_5;
+		SDLJoyButtonMap[5] = NKCODE_BUTTON_6;
+		SDLJoyButtonMap[6] = NKCODE_BUTTON_7;
+		SDLJoyButtonMap[7] = NKCODE_BUTTON_8;
+		SDLJoyButtonMap[8] = NKCODE_BUTTON_9;
+		SDLJoyButtonMap[9] = NKCODE_BUTTON_10;
+		SDLJoyButtonMap[10] = NKCODE_BUTTON_11;
+		SDLJoyButtonMap[11] = NKCODE_BUTTON_12;
+		SDLJoyButtonMap[12] = NKCODE_BUTTON_13;
+		SDLJoyButtonMap[13] = NKCODE_DPAD_UP;
+		SDLJoyButtonMap[14] = NKCODE_DPAD_DOWN;
+		SDLJoyButtonMap[15] = NKCODE_DPAD_LEFT;
+		SDLJoyButtonMap[16] = NKCODE_DPAD_RIGHT;
+	
+		SDLJoyAxisMap[0] = JOYSTICK_AXIS_X;
+		SDLJoyAxisMap[1] = JOYSTICK_AXIS_Y;
+		SDLJoyAxisMap[2] = JOYSTICK_AXIS_Z;
+		SDLJoyAxisMap[3] = JOYSTICK_AXIS_RZ;
+		SDLJoyAxisMap[4] = JOYSTICK_AXIS_LTRIGGER;
+		SDLJoyAxisMap[5] = JOYSTICK_AXIS_RTRIGGER;
+
+#endif
+	}
+	std::map<int, int> SDLJoyButtonMap;
+	std::map<int, int> SDLJoyAxisMap;
+
+	std::vector<SDL_Joystick *> joys;
 	bool registeredAsEventHandler;
-	std::vector<SDL_GameController *> controllers;
-	std::map<int, int> controllerDeviceMap;
+
+	int getDeviceIndex(int instanceId);
 };
--- ext/native/base/PCMain.cpp.orig	2017-03-30 12:14:27 UTC
+++ ext/native/base/PCMain.cpp
@@ -399,7 +399,7 @@ int main(int argc, char *argv[]) {
 	NativeGetAppInfo(&app_name, &app_name_nice, &landscape, &version);
 
 	bool joystick_enabled = true;
-	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER | SDL_INIT_AUDIO) < 0) {
+	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) < 0) {
 		joystick_enabled = false;
 		if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
 			fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());