diff --git a/config/hyperion.config.json.default b/config/hyperion.config.json.default index 1fb46c93..16beefb3 100644 --- a/config/hyperion.config.json.default +++ b/config/hyperion.config.json.default @@ -21,7 +21,21 @@ "enableAttempts": 6, "enableAttemptsInterval": 15 }, - + + "cecEvents": { + "actions": [ + { + "action": "Suspend", + "cec_event": "standby" + }, + { + "action": "Resume", + "cec_event": "set stream path" + } + ], + "enable": false + }, + "color": { "imageToLedMappingType": "multicolor_mean", "channelAdjustment": [ diff --git a/libsrc/hyperion/SettingsManager.cpp b/libsrc/hyperion/SettingsManager.cpp index 3fe7e367..1fcd8c6c 100644 --- a/libsrc/hyperion/SettingsManager.cpp +++ b/libsrc/hyperion/SettingsManager.cpp @@ -894,6 +894,44 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config) Debug(_log, "LED-Device records migrated"); } } + + if (config.contains("cecEvents")) + { + bool isCECEnabled {false}; + if (config.contains("grabberV4L2")) + { + QJsonObject newGrabberV4L2Config = config["grabberV4L2"].toObject(); + if (newGrabberV4L2Config.contains("cecDetection")) + { + isCECEnabled = newGrabberV4L2Config.value("cecDetection").toBool(false); + newGrabberV4L2Config.remove("cecDetection"); + config["grabberV4L2"] = newGrabberV4L2Config; + + QJsonObject newGCecEventsConfig = config["cecEvents"].toObject(); + newGCecEventsConfig["enable"] = isCECEnabled; + if (!newGCecEventsConfig.contains("actions")) + { + QJsonObject action1 + { + {"action", "Suspend"}, + {"cec_event", "standby"} + }; + QJsonObject action2 + { + {"action", "Resume"}, + {"cec_event", "set stream path"} + }; + + QJsonArray actions { action1, action2 }; + newGCecEventsConfig.insert("actions",actions); + } + config["cecEvents"] = newGCecEventsConfig; + + migrated = true; + Debug(_log, "CEC configuration records migrated"); + } + } + } } } }