Browse Source

Allow keyinput to be mapped to a list of actions.

Since the whole mapping is a JSON object there was no way to map a single key to multiple actions
since one would always be overwritten (keys are unique) this commit adds the possibility to map a
single key to multiple actions by allowing the value of the mapping to be a list of strings. This
can't be used for more complex long/short mappings just a single action list.
Tobias Hieta 9 years ago
parent
commit
6e62e5a88a
2 changed files with 5 additions and 2 deletions
  1. 1 2
      resources/inputmaps/keyboard.json
  2. 4 0
      src/input/InputComponent.cpp

+ 1 - 2
resources/inputmaps/keyboard.json

@@ -19,7 +19,7 @@
 
     // map X and Shift+X to X for letters, space to space. This allows normal text input
     "(?:Shift\\+)?([A-Z])": "%1",
-    "Space": "space",
+    "Space": ["space", "play_pause"],
 
     // map some other normal buttons that might be useful
     "(?:Shift\\+)?(\\.|\\:|\\_)": "%1",
@@ -27,7 +27,6 @@
     // map Shift+Letter to action jump+letter
     "Shift\\+([A-Z])": "jump+%1",
 
-    "Space": "play_pause",
     "P": "play_pause",
     "Ctrl\\+P": "pause",
     "X": "stop",

+ 4 - 0
src/input/InputComponent.cpp

@@ -204,6 +204,10 @@ void InputComponent::remapInput(const QString &source, const QString &keycode, I
         queuedActions.append(map.value("short").toString());
       }
     }
+    else if (action.type() == QVariant::List)
+    {
+      queuedActions.append(action.toStringList());
+    }
   }
 
   if (!m_autoRepeatActions.isEmpty() && keyState != InputBase::KeyPressed)