diff options
author | eray orçunus <erayorcunus@gmail.com> | 2020-09-30 19:02:47 +0200 |
---|---|---|
committer | eray orçunus <erayorcunus@gmail.com> | 2020-09-30 19:03:01 +0200 |
commit | 595421da3908a2d3e7a1b063605bb3f2a3adb65b (patch) | |
tree | 1fe2f8eb9da450d5f8efdb27f1b9cbd8d541e01c /src/skel/glfw | |
parent | Fix more (diff) | |
download | re3-595421da3908a2d3e7a1b063605bb3f2a3adb65b.tar re3-595421da3908a2d3e7a1b063605bb3f2a3adb65b.tar.gz re3-595421da3908a2d3e7a1b063605bb3f2a3adb65b.tar.bz2 re3-595421da3908a2d3e7a1b063605bb3f2a3adb65b.tar.lz re3-595421da3908a2d3e7a1b063605bb3f2a3adb65b.tar.xz re3-595421da3908a2d3e7a1b063605bb3f2a3adb65b.tar.zst re3-595421da3908a2d3e7a1b063605bb3f2a3adb65b.zip |
Diffstat (limited to 'src/skel/glfw')
-rw-r--r-- | src/skel/glfw/glfw.cpp | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index b9dbf5ac..944e87b5 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -87,6 +87,11 @@ long _dwOperatingSystemVersion; #include <signal.h> #include <errno.h> #endif + +#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS +char gSelectedJoystickName[128] = ""; +#endif + /* ***************************************************************************** */ @@ -822,31 +827,19 @@ void joysChangeCB(int jid, int event); bool IsThisJoystickBlacklisted(int i) { +#ifndef DONT_TRUST_RECOGNIZED_JOYSTICKS + return false; +#else if (glfwJoystickIsGamepad(i)) return false; const char* joyname = glfwGetJoystickName(i); - // this is just a keyboard and mouse - // Microsoft Microsoft® 2.4GHz Transceiver v8.0 Consumer Control - // Microsoft Microsoft® 2.4GHz Transceiver v8.0 System Control - if (strstr(joyname, "2.4GHz Transceiver")) - return true; - // COMPANY USB Device System Control - // COMPANY USB Device Consumer Control - if (strstr(joyname, "COMPANY USB")) - return true; - // i.e. Synaptics TM2438-005 - if (strstr(joyname, "Synaptics ")) - return true; - // i.e. ELAN Touchscreen - if (strstr(joyname, "ELAN ")) - return true; - // i.e. Primax Electronics, Ltd HP Wireless Keyboard Mouse Kit Consumer Control - if (strstr(joyname, "Keyboard")) - return true; + if (strncmp(joyname, gSelectedJoystickName, sizeof(gSelectedJoystickName)) == 0) + return false; - return false; + return true; +#endif } void _InputInitialiseJoys() @@ -865,6 +858,7 @@ void _InputInitialiseJoys() if (PSGLOBAL(joy1id) != -1) { int count; glfwGetJoystickButtons(PSGLOBAL(joy1id), &count); + strcpy(gSelectedJoystickName, glfwGetJoystickName(PSGLOBAL(joy1id))); ControlsManager.InitDefaultControlConfigJoyPad(count); } } @@ -2070,18 +2064,18 @@ void CapturePad(RwInt32 padID) void joysChangeCB(int jid, int event) { - if (event == GLFW_CONNECTED && !IsThisJoystickBlacklisted(jid)) - { - if (PSGLOBAL(joy1id) == -1) + if (event == GLFW_CONNECTED && !IsThisJoystickBlacklisted(jid)) { + if (PSGLOBAL(joy1id) == -1) { PSGLOBAL(joy1id) = jid; - else if (PSGLOBAL(joy2id) == -1) + strcpy(gSelectedJoystickName, glfwGetJoystickName(jid)); + } else if (PSGLOBAL(joy2id) == -1) PSGLOBAL(joy2id) = jid; - } - else if (event == GLFW_DISCONNECTED) - { - if (PSGLOBAL(joy1id) == jid) + + } else if (event == GLFW_DISCONNECTED) { + if (PSGLOBAL(joy1id) == jid) { PSGLOBAL(joy1id) = -1; - else if (PSGLOBAL(joy2id) == jid) + strcpy(gSelectedJoystickName, ""); + } else if (PSGLOBAL(joy2id) == jid) PSGLOBAL(joy2id) = -1; } } |