Allow to leave a control unused (no key binding)
authorWuzzy <Wuzzy2@mail.ru>
Wed, 09 Jan 2019 22:09:27 +0100
changeset 14532 e1ae6d8e84b0
parent 14531 e0af4ce7d8bc
child 14533 1b97bc7de936
Allow to leave a control unused (no key binding)
QTfrontend/sdlkeys.cpp
QTfrontend/sdlkeys.h
QTfrontend/util/DataManager.cpp
QTfrontend/util/SDLInteraction.cpp
--- a/QTfrontend/sdlkeys.cpp	Wed Jan 09 16:27:57 2019 -0500
+++ b/QTfrontend/sdlkeys.cpp	Wed Jan 09 22:09:27 2019 +0100
@@ -197,3 +197,6 @@
 char controllerleft[128] = QT_TRANSLATE_NOOP("binds (keys)", "Left");
 char controllerright[128] = QT_TRANSLATE_NOOP("binds (keys)", "Right");
 
+//: When a control has no key binding
+char unboundcontrol[128] = QT_TRANSLATE_NOOP("binds (keys)", "(Unused)");
+
--- a/QTfrontend/sdlkeys.h	Wed Jan 09 16:27:57 2019 -0500
+++ b/QTfrontend/sdlkeys.h	Wed Jan 09 22:09:27 2019 +0100
@@ -30,5 +30,6 @@
 extern char controllerdown[128];
 extern char controllerleft[128];
 extern char controllerright[128];
+extern char unboundcontrol[128];
 
 #endif
--- a/QTfrontend/util/DataManager.cpp	Wed Jan 09 16:27:57 2019 -0500
+++ b/QTfrontend/util/DataManager.cpp	Wed Jan 09 22:09:27 2019 +0100
@@ -159,7 +159,9 @@
         for(int j = 0; sdlkeys[j][1][0] != '\0'; j++)
         {
             QStandardItem * item = new QStandardItem();
-            item->setData(HWApplication::translate("binds (keys)", sdlkeys[j][1]).contains(": ") ? HWApplication::translate("binds (keys)", sdlkeys[j][1]) : HWApplication::translate("binds (keys)", "Keyboard") + QString(": ") + HWApplication::translate("binds (keys)", sdlkeys[j][1]), Qt::DisplayRole);
+            QString keyId = QString(sdlkeys[j][0]);
+            QString keyTr = HWApplication::translate("binds (keys)", sdlkeys[j][1]);
+            item->setData((keyId == "none" || keyTr.contains(": ")) ? keyTr : HWApplication::translate("binds (keys)", "Keyboard") + QString(": ") + keyTr, Qt::DisplayRole);
             item->setData(sdlkeys[j][0], Qt::UserRole + 1);
             m_bindsModel->appendRow(item);
         }
--- a/QTfrontend/util/SDLInteraction.cpp	Wed Jan 09 16:27:57 2019 -0500
+++ b/QTfrontend/util/SDLInteraction.cpp	Wed Jan 09 22:09:27 2019 +0100
@@ -52,6 +52,13 @@
     lastchannel = 0;
     if(SDL_NumJoysticks())
         addGameControllerKeys();
+
+    int i = 0;
+    while(i < 1024 && sdlkeys[i][1][0] != '\0')
+        i++;
+    sprintf(sdlkeys[i][0], "none");
+    sprintf(sdlkeys[i++][1], "%s", HWApplication::translate("binds (keys)", unboundcontrol).toUtf8().constData());
+
     SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
 
     m_soundMap = new QMap<QString,Mix_Chunk*>();