summaryrefslogtreecommitdiff
path: root/emulators
diff options
context:
space:
mode:
Diffstat (limited to 'emulators')
-rw-r--r--emulators/ppsspp-devel/Makefile2
-rw-r--r--emulators/ppsspp-devel/files/extra-patch-old-joy477
-rw-r--r--emulators/ppsspp/Makefile5
-rw-r--r--emulators/ppsspp/distinfo2
-rw-r--r--emulators/ppsspp/files/extra-patch-old-joy88
5 files changed, 56 insertions, 518 deletions
diff --git a/emulators/ppsspp-devel/Makefile b/emulators/ppsspp-devel/Makefile
index b02eb461b0d6..8960cab4881a 100644
--- a/emulators/ppsspp-devel/Makefile
+++ b/emulators/ppsspp-devel/Makefile
@@ -14,6 +14,4 @@ GH_TUPLE= hrydgard:glslang:136b1e2d:glslang/ext/glslang \
MASTERDIR= ${.CURDIR}/../ppsspp
DISTINFO_FILE= ${.CURDIR}/distinfo
-OLDJOY_EXTRA_PATCHES= ${.CURDIR}/files/extra-patch-old-joy
-
.include "${MASTERDIR}/Makefile"
diff --git a/emulators/ppsspp-devel/files/extra-patch-old-joy b/emulators/ppsspp-devel/files/extra-patch-old-joy
deleted file mode 100644
index e70948bb2861..000000000000
--- a/emulators/ppsspp-devel/files/extra-patch-old-joy
+++ /dev/null
@@ -1,477 +0,0 @@
-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());
diff --git a/emulators/ppsspp/Makefile b/emulators/ppsspp/Makefile
index 40c9840c5e33..f04cd2786d14 100644
--- a/emulators/ppsspp/Makefile
+++ b/emulators/ppsspp/Makefile
@@ -3,7 +3,7 @@
PORTNAME= ppsspp
DISTVERSIONPREFIX= v
DISTVERSION?= 1.4.2
-PORTREVISION?= 3
+PORTREVISION?= 4
CATEGORIES= emulators
# XXX Get from Debian once #697821 lands
MASTER_SITES= https://bazaar.launchpad.net/~sergio-br2/${PORTNAME}/debian-sdl/download/5/${PORTNAME}.1-20140802045408-dd26dik367ztj5xg-8/:manpage
@@ -13,6 +13,7 @@ EXTRACT_ONLY= ${DISTFILES:N*\:manpage:C/:.*//}
.if !defined(PKGNAMESUFFIX) || ${PKGNAMESUFFIX:N*-devel}
PATCH_SITES= https://github.com/${GH_ACCOUNT}/${GH_PROJECT}/commit/
PATCHFILES= e33acdc5e922.patch:-p1
+PATCHFILES+= ac0052c6af92.patch:-p1
.endif
MAINTAINER= jbeich@FreeBSD.org
@@ -58,7 +59,7 @@ OPTIONS_SLAVE?= SDL
OPTIONS_EXCLUDE:= ${OPTIONS_SINGLE_GUI}
OLDJOY_DESC= Old joystick support with fixed button mappings (deprecated)
-OLDJOY_EXTRA_PATCHES?= ${PATCHDIR}/extra-patch-old-joy
+OLDJOY_EXTRA_PATCHES= ${PATCHDIR}/extra-patch-old-joy
QT5_USE= QT5=qmake_build,buildtools_build,linguisttools_build,gui,opengl,widgets
QT5_CMAKE_BOOL= USING_QT_UI
QT5_VARS= EXENAME=PPSSPPQt
diff --git a/emulators/ppsspp/distinfo b/emulators/ppsspp/distinfo
index 52c7938dacbc..f01bbf561817 100644
--- a/emulators/ppsspp/distinfo
+++ b/emulators/ppsspp/distinfo
@@ -15,3 +15,5 @@ SHA256 (Kingcom-tinyformat-Release-2.0.1-7-gb7f5a22_GH0.tar.gz) = d86b5b45920472
SIZE (Kingcom-tinyformat-Release-2.0.1-7-gb7f5a22_GH0.tar.gz) = 22286
SHA256 (e33acdc5e922.patch) = 26db4fe256c3947193b379ea7d17b0aae59e4339ae3822b53ef40fd6dca07004
SIZE (e33acdc5e922.patch) = 1819
+SHA256 (ac0052c6af92.patch) = 91beb0f70965a433eddb15e1088ab3091beac99e921944fbf79cee16bbb7ee60
+SIZE (ac0052c6af92.patch) = 3078
diff --git a/emulators/ppsspp/files/extra-patch-old-joy b/emulators/ppsspp/files/extra-patch-old-joy
index f6ff4a8ea9c9..e70948bb2861 100644
--- a/emulators/ppsspp/files/extra-patch-old-joy
+++ b/emulators/ppsspp/files/extra-patch-old-joy
@@ -7,10 +7,11 @@ 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-03-30 12:14:27 UTC
+--- SDL/SDLJoystick.cpp.orig 2017-10-04 19:26:40 UTC
+++ SDL/SDLJoystick.cpp
-@@ -1,12 +1,7 @@
+@@ -1,13 +1,8 @@
#include "SDL/SDLJoystick.h"
#include "Core/Config.h"
-#include "Common/FileUtil.h"
@@ -18,18 +19,20 @@ https://github.com/hrydgard/ppsspp/commit/1b699363ca4d
#include <iostream>
-#include <string>
--
--using namespace std;
+-using namespace std;
+-
static int SDLJoystickEventHandlerWrapper(void* userdata, SDL_Event* event)
{
-@@ -17,65 +12,32 @@ static int SDLJoystickEventHandlerWrappe
+ 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 << ": ";
-
@@ -44,52 +47,63 @@ https://github.com/hrydgard/ppsspp/commit/1b699363ca4d
- 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;
}
+- 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)) {
-- 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;
-- }
+- 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 {
-- SDL_GameControllerClose(controller);
+- cout << "SUCCESS, mapping is:" << endl << mapping << endl;
- }
+- } else {
+- SDL_GameControllerClose(controller);
- }
- }
+ if (g_Config.bPS3Controller)
+ fillMappingPS3();
+ else
+ fillMapping();
-+
-+
}
SDLJoystick::~SDLJoystick() {
@@ -103,7 +117,7 @@ https://github.com/hrydgard/ppsspp/commit/1b699363ca4d
}
}
-@@ -84,107 +46,124 @@ void SDLJoystick::registerEventHandler()
+@@ -98,107 +44,124 @@ void SDLJoystick::registerEventHandler() {
registeredAsEventHandler = true;
}
@@ -281,7 +295,8 @@ https://github.com/hrydgard/ppsspp/commit/1b699363ca4d
+ joys[deviceIndex] = SDL_JoystickOpen(deviceIndex);
+ SDL_JoystickEventState(SDL_ENABLE);
+ break;
-+ }
+ }
+- break;
+
+ case SDL_JOYDEVICEREMOVED:
+ {
@@ -291,8 +306,7 @@ https://github.com/hrydgard/ppsspp/commit/1b699363ca4d
+ joys[deviceIndex] = 0;
+ }
+ break;
- }
-- break;
++ }
}
}
@@ -310,7 +324,7 @@ https://github.com/hrydgard/ppsspp/commit/1b699363ca4d
- return it->second;
+ return -1;
}
---- SDL/SDLJoystick.h.orig 2017-03-30 12:14:27 UTC
+--- SDL/SDLJoystick.h.orig 2017-10-04 19:26:40 UTC
+++ SDL/SDLJoystick.h
@@ -1,9 +1,11 @@
#pragma once
@@ -324,7 +338,7 @@ https://github.com/hrydgard/ppsspp/commit/1b699363ca4d
#include "SDL_thread.h"
#endif
-@@ -21,11 +23,119 @@ public:
+@@ -21,11 +23,119 @@ class SDLJoystick{ (public)
void ProcessInput(SDL_Event &event);
private:
@@ -450,9 +464,9 @@ https://github.com/hrydgard/ppsspp/commit/1b699363ca4d
+
+ int getDeviceIndex(int instanceId);
};
---- ext/native/base/PCMain.cpp.orig 2017-03-30 12:14:27 UTC
+--- ext/native/base/PCMain.cpp.orig 2017-10-04 19:26:40 UTC
+++ ext/native/base/PCMain.cpp
-@@ -399,7 +399,7 @@ int main(int argc, char *argv[]) {
+@@ -428,7 +428,7 @@ int main(int argc, char *argv[]) {
NativeGetAppInfo(&app_name, &app_name_nice, &landscape, &version);
bool joystick_enabled = true;