8e42bc6858
Changes: https://github.com/hrydgard/ppsspp/commit/ac0052c6af92 MFH: 2017Q4 (requires r451582)
477 lines
17 KiB
Text
477 lines
17 KiB
Text
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
|
|
https://github.com/hrydgard/ppsspp/commit/ac0052c6af92
|
|
|
|
--- SDL/SDLJoystick.cpp.orig 2017-10-04 19:26:40 UTC
|
|
+++ SDL/SDLJoystick.cpp
|
|
@@ -1,13 +1,8 @@
|
|
#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)
|
|
{
|
|
static_cast<SDLJoystick *>(userdata)->ProcessInput(*event);
|
|
@@ -17,79 +12,30 @@ static int SDLJoystickEventHandlerWrapper(void* userda
|
|
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);
|
|
+ SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO);
|
|
}
|
|
|
|
- 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;
|
|
- }
|
|
- cout << "SUCCESS!" << endl;
|
|
- setUpControllers();
|
|
-}
|
|
-
|
|
-void SDLJoystick::setUpControllers() {
|
|
int numjoys = SDL_NumJoysticks();
|
|
+ SDL_JoystickEventState(SDL_ENABLE);
|
|
for (int i = 0; i < numjoys; i++) {
|
|
- setUpController(i);
|
|
+ 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;
|
|
}
|
|
- if (controllers.size() > 0) {
|
|
- cout << "pad 1 has been assigned to control pad: " << SDL_GameControllerName(controllers.front()) << endl;
|
|
- }
|
|
-}
|
|
|
|
-void SDLJoystick::setUpController(int deviceIndex) {
|
|
- if (!SDL_IsGameController(deviceIndex)) {
|
|
- cout << "Control pad device " << deviceIndex << " not supported by SDL game controller database, attempting to create default mapping..." << endl;
|
|
- int cbGUID = 33;
|
|
- char pszGUID[cbGUID];
|
|
- SDL_Joystick* joystick = SDL_JoystickOpen(deviceIndex);
|
|
- SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), pszGUID, cbGUID);
|
|
- // create default mapping - this is the PS3 dual shock mapping
|
|
- std::string mapping = string(pszGUID) + "," + string(SDL_JoystickName(joystick)) + ",x:b3,a:b0,b:b1,y:b2,back:b8,guide:b10,start:b9,dpleft:b15,dpdown:b14,dpright:b16,dpup:b13,leftshoulder:b4,lefttrigger:a2,rightshoulder:b6,rightshoulder:b5,righttrigger:a5,leftstick:b7,leftstick:b11,rightstick:b12,leftx:a0,lefty:a1,rightx:a3,righty:a4";
|
|
- if (SDL_GameControllerAddMapping(mapping.c_str()) == 1){
|
|
- cout << "Added default mapping ok" << endl;
|
|
- } else {
|
|
- cout << "Failed to add default mapping" << endl;
|
|
- }
|
|
- SDL_JoystickClose(joystick);
|
|
- }
|
|
- 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;
|
|
- cout << "Could not find mapping in SDL2 controller database" << 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);
|
|
}
|
|
}
|
|
|
|
@@ -98,107 +44,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 * g_Config.fXInputAnalogSensitivity / 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 * g_Config.fXInputAnalogSensitivity / 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;
|
|
}
|
|
- break;
|
|
+
|
|
+ case SDL_JOYDEVICEREMOVED:
|
|
+ {
|
|
+ int deviceIndex = getDeviceIndex(event.jdevice.which);
|
|
+ if (deviceIndex >= 0) {
|
|
+ SDL_JoystickClose(joys[deviceIndex]);
|
|
+ joys[deviceIndex] = 0;
|
|
+ }
|
|
+ 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-10-04 19:26:40 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 @@ class SDLJoystick{ (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-10-04 19:26:40 UTC
|
|
+++ ext/native/base/PCMain.cpp
|
|
@@ -428,7 +428,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());
|