Make frontend detect controllers again
authorWuzzy <Wuzzy2@mail.ru>
Thu, 19 Jul 2018 22:19:44 +0200
changeset 13522 31d0b0911cba
parent 13519 d8462cc9d42d
child 13523 c5365f05d4de
Make frontend detect controllers again
ChangeLog.txt
QTfrontend/util/SDLInteraction.cpp
--- a/ChangeLog.txt	Thu Jul 19 19:35:28 2018 +0200
+++ b/ChangeLog.txt	Thu Jul 19 22:19:44 2018 +0200
@@ -12,6 +12,9 @@
  * Fix cursor teleporting to center after leaving game with a video recording
  * Fix teleport tooltip claiming it doesn't end turn in hog placing phase with inf. attack
 
+Frontend:
+ * Controllers are detected again
+
 Highlander:
  * Fix all hogs getting teleport after hog placement phase
 
--- a/QTfrontend/util/SDLInteraction.cpp	Thu Jul 19 19:35:28 2018 +0200
+++ b/QTfrontend/util/SDLInteraction.cpp	Thu Jul 19 22:19:44 2018 +0200
@@ -105,19 +105,23 @@
     QStringList result;
 
 #if SDL_VERSION_ATLEAST(2, 0, 0)
-// TODO or not TODO?
-#else
     int i = 0;
     while(i < 1024 && sdlkeys[i][1][0] != '\0')
         i++;
 
     // Iterate through all game controllers
+    qDebug("Detecting controllers ...");
     for(int jid = 0; jid < SDL_NumJoysticks(); jid++)
     {
         SDL_Joystick* joy = SDL_JoystickOpen(jid);
 
-        // Retrieve the game controller's name and strip "Controller (...)" that's added by some drivers (English only)
-        QString joyname = QString(SDL_JoystickName(jid)).replace(QRegExp("^Controller \\((.*)\\)$"), "\\1");
+        // Retrieve the game controller's name
+        QString joyname = QString(SDL_JoystickNameForIndex(jid));
+
+        // Strip "Controller (...)" that's added by some drivers (English only)
+        joyname.replace(QRegExp("^Controller \\((.*)\\)$"), "\\1");
+
+        qDebug("- Controller no. %d: %s", jid, qPrintable(joyname));
 
         // Connected Xbox 360 controller? Use specific button names then
         // Might be interesting to add 'named' buttons for the most often used gamepads