Browse Source

Simplify AppleRemote keymap and InputComponent

Tobias Hieta 9 years ago
parent
commit
e8bf252339
2 changed files with 16 additions and 63 deletions
  1. 14 14
      resources/inputmaps/apple-remote.json
  2. 2 49
      src/input/apple/InputAppleRemote.mm

+ 14 - 14
resources/inputmaps/apple-remote.json

@@ -3,18 +3,18 @@
   "idmatcher": "AppleRemote.*",
   "mapping": 
   {
-      "KEY_LEFT": "left",
-      "KEY_LEFT_LONG": "cycle_subtitles_back",
-      "KEY_RIGHT": "right",
-      "KEY_RIGHT_LONG": "cycle_subtitles",
-      "KEY_UP": "up",
-      "KEY_UP_LONG": "cycle_audio",
-      "KEY_DOWN": "down",
-      "KEY_DOWN_LONG": "cycle_audio_back",
-      "KEY_SELECT": "enter",
-      "KEY_SELECT_LONG": "host:toggleDebug",
-      "KEY_MENU": "back",
-      "KEY_MENU_LONG": "home",
-      "KEY_PLAY": "play_pause"
+      "1": {
+        "short": "up",
+        "long": "cycle_audio"
+      },
+      "2": {
+        "short": "down",
+        "long": "cycle_audio_back"
+      },
+      "3": "left",
+      "4": "right",
+      "5": "enter",
+      "6": "back",
+      "7": "play_pause"
   }
-}
+}

+ 2 - 49
src/input/apple/InputAppleRemote.mm

@@ -31,55 +31,8 @@ void InputAppleRemote::removeRemote(const QString &name)
   QLOG_DEBUG() << "Remove remote:" << name;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-static QString codeToString(HIDRemoteButtonCode code)
-{
-  switch (code)
-  {
-    case kHIDRemoteButtonCodeCenter:
-      return INPUT_KEY_SELECT;
-    case kHIDRemoteButtonCodeCenterHold:
-      return INPUT_KEY_SELECT_LONG;
-    case kHIDRemoteButtonCodeDown:
-      return INPUT_KEY_DOWN;
-    case kHIDRemoteButtonCodeDownHold:
-      return INPUT_KEY_DOWN_LONG;
-    case kHIDRemoteButtonCodeLeft:
-      return INPUT_KEY_LEFT;
-    case kHIDRemoteButtonCodeLeftHold:
-      return INPUT_KEY_LEFT_LONG;
-    case kHIDRemoteButtonCodeRight:
-      return INPUT_KEY_RIGHT;
-    case kHIDRemoteButtonCodeRightHold:
-      return INPUT_KEY_RIGHT_LONG;
-    case kHIDRemoteButtonCodeMenu:
-      return INPUT_KEY_MENU;
-    case kHIDRemoteButtonCodeMenuHold:
-      return INPUT_KEY_MENU_LONG;
-    case kHIDRemoteButtonCodePlay:
-      return INPUT_KEY_PLAY;
-    case kHIDRemoteButtonCodePlayHold:
-      return INPUT_KEY_PLAY_LONG;
-    case kHIDRemoteButtonCodeUp:
-      return INPUT_KEY_UP;
-    case kHIDRemoteButtonCodeUpHold:
-      return INPUT_KEY_UP_LONG;
-    default:
-      QLOG_WARN() << "could not handle key code:" << code;
-  }
-  return "";
-}
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 void InputAppleRemote::remoteButtonEvent(quint8 code, bool pressed, const QString &name)
 {
-  if (pressed)
-  {
-    QString codeStr = codeToString((HIDRemoteButtonCode)code);
-    if (!codeStr.isEmpty())
-    {
-      QLOG_DEBUG() << name << "pressed button:" << codeStr;
-      emit receivedInput("AppleRemote", codeStr);
-    }
-  }
-}
+  emit receivedInput("AppleRemote", QString::number(code), pressed);
+}