diff --git a/kodi/devicepluginkodi.cpp b/kodi/devicepluginkodi.cpp index 6799ff93..9d8f4b3d 100644 --- a/kodi/devicepluginkodi.cpp +++ b/kodi/devicepluginkodi.cpp @@ -242,24 +242,24 @@ Device::DeviceError DevicePluginKodi::executeAction(Device *device, const Action commandId = kodi->setVolume(action.param(kodiVolumeActionVolumeParamTypeId).value().toInt()); } else if (action.actionTypeId() == kodiMuteActionTypeId) { commandId = kodi->setMuted(action.param(kodiMuteActionMuteParamTypeId).value().toBool()); - } else if (action.actionTypeId() == kodiPressButtonActionTypeId) { - commandId = kodi->pressButton(action.param(kodiPressButtonActionButtonParamTypeId).value().toString()); + } else if (action.actionTypeId() == kodiNavigateActionTypeId) { + commandId = kodi->navigate(action.param(kodiNavigateActionToParamTypeId).value().toString()); } else if (action.actionTypeId() == kodiSystemActionTypeId) { commandId = kodi->systemCommand(action.param(kodiSystemActionSystemCommandParamTypeId).value().toString()); } else if(action.actionTypeId() == kodiSkipBackActionTypeId) { - commandId = kodi->pressButton("skipprevious"); + commandId = kodi->navigate("skipprevious"); } else if(action.actionTypeId() == kodiFastRewindActionTypeId) { - commandId = kodi->pressButton("rewind"); + commandId = kodi->navigate("rewind"); } else if(action.actionTypeId() == kodiStopActionTypeId) { - commandId = kodi->pressButton("stop"); + commandId = kodi->navigate("stop"); } else if(action.actionTypeId() == kodiPlayActionTypeId) { - commandId = kodi->pressButton("play"); + commandId = kodi->navigate("play"); } else if(action.actionTypeId() == kodiPauseActionTypeId) { - commandId = kodi->pressButton("pause"); + commandId = kodi->navigate("pause"); } else if(action.actionTypeId() == kodiFastForwardActionTypeId) { - commandId = kodi->pressButton("fastforward"); + commandId = kodi->navigate("fastforward"); } else if(action.actionTypeId() == kodiSkipNextActionTypeId) { - commandId = kodi->pressButton("skipnext"); + commandId = kodi->navigate("skipnext"); } else if (action.actionTypeId() == kodiShuffleActionTypeId) { commandId = kodi->setShuffle(action.param(kodiShuffleActionShuffleParamTypeId).value().toBool()); } else if (action.actionTypeId() == kodiRepeatActionTypeId) { diff --git a/kodi/devicepluginkodi.json b/kodi/devicepluginkodi.json index 06ab1f25..241eeb1a 100644 --- a/kodi/devicepluginkodi.json +++ b/kodi/devicepluginkodi.json @@ -12,7 +12,7 @@ "id": "d09953e3-c5bd-415b-973b-0d0bf2be3f69", "name": "kodi", "displayName": "Kodi", - "interfaces": ["mediaplayer", "extendedmediacontroller", "extendedvolumecontroller", "mediametadataprovider", "shufflerepeat", "notifications", "connectable"], + "interfaces": ["mediaplayer", "extendedmediacontroller", "extendedvolumecontroller", "mediametadataprovider", "shufflerepeat", "notifications", "extendednavigationpad", "connectable"], "createMethods": ["user", "discovery"], "browsable": true, "paramTypes": [ @@ -237,45 +237,24 @@ }, { "id": "28060803-aa85-44a4-9dec-ee669dfb629f", - "name": "pressButton", - "displayName": "press button", + "name": "navigate", + "displayName": "Navigate", "paramTypes": [ { "id": "93861dac-0c24-4a3b-903d-d1be44eae611", - "name": "button", - "displayName": "button", + "name": "to", + "displayName": "to", "type": "QString", "allowedValues": [ - "left", - "right", "up", "down", - "pageup", - "pagedown", - "select", + "left", + "right", + "enter", "back", + "menu", "info", - "pause", - "stop", - "skipnext", - "skipprevious", - "stepforward", - "stepback", - "osd", - "play", - "playpause", - "fastforward", - "rewind", - "fullscreen", - "mute", - "volumeup", - "volumedown", - "channelup", - "channeldown", - "red", - "green", - "yellow", - "blue" + "home" ] } ] diff --git a/kodi/kodi.cpp b/kodi/kodi.cpp index ac5d2ad4..03a2a0c8 100644 --- a/kodi/kodi.cpp +++ b/kodi/kodi.cpp @@ -236,10 +236,19 @@ int Kodi::showNotification(const QString &title, const QString &message, const i return m_jsonHandler->sendData("GUI.ShowNotification", params); } -int Kodi::pressButton(const QString &button) +int Kodi::navigate(const QString &to) { + qCDebug(dcKodi()) << "Navigate:" << to; + if (to == "home") { + return m_jsonHandler->sendData("Input.Home", QVariantMap()); + } + QVariantMap params; - params.insert("action", button); + QString mappedTo = to; + if (to == "enter") { + mappedTo = "select"; + } + params.insert("action", mappedTo); return m_jsonHandler->sendData("Input.ExecuteAction", params); } @@ -949,7 +958,7 @@ void Kodi::processResponse(int id, const QString &method, const QVariantMap &res return; } - if (method == "GUI.ShowNotification") { + if (method == "GUI.ShowNotification" || method == "Input.ExecuteAction") { emit actionExecuted(id, !response.contains("error")); return; } diff --git a/kodi/kodi.h b/kodi/kodi.h index 830dcb2e..7de08831 100644 --- a/kodi/kodi.h +++ b/kodi/kodi.h @@ -57,7 +57,7 @@ public: // actions int showNotification(const QString &title, const QString &message, const int &displayTime, const QString ¬ificationType); - int pressButton(const QString &button); + int navigate(const QString &to); int systemCommand(const QString &command); void update();