mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Introduce Event Services (#1653)
* Allow to enable/disable suspend & lock event handling * Fix Windows * Refactor event handling incl.CEC * Revert "Auxiliary commit to revert individual files from 0d9a8b8a3a4a09609a339f54c7d8a9384c561282" This reverts commit 80737d926ad151a07b2493dd1685ed502975cb2e. * Support Events for Grabbers generically * Have CECEvent to actions configurable, further clean-ups * Remove handleEvent from V4L2grabber, as grabber will be stopped on suspend * Validate that one CEC Event can only trigger one action * MacOS lock/unlock added * fast windows fix * Corrections * Fix CodeQL findings * add macos lock/unlock handler * Migration of CEC-config and have default actions * Correct target_link_libraries * Include Foundation * macOS include AppKit * Support Scheduled Events, cleanups. * Fix destructing * Fix coredump during free * Consider additional error sceanrio * Fix missing code * install desktop icons * correct bash logic --------- Co-authored-by: Paulchen-Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
@@ -49,6 +49,7 @@ add_library(hyperion
|
||||
|
||||
target_link_libraries(hyperion
|
||||
blackborder
|
||||
events
|
||||
hyperion-utils
|
||||
leddevice
|
||||
database
|
||||
|
@@ -5,6 +5,7 @@
|
||||
|
||||
// utils includes
|
||||
#include <utils/GlobalSignals.h>
|
||||
#include <events/EventHandler.h>
|
||||
|
||||
// qt
|
||||
#include <QTimer>
|
||||
@@ -49,6 +50,8 @@ GrabberWrapper::GrabberWrapper(const QString& grabberName, Grabber * ggrabber, i
|
||||
|
||||
// listen for source requests
|
||||
connect(GlobalSignals::getInstance(), &GlobalSignals::requestSource, this, &GrabberWrapper::handleSourceRequest);
|
||||
|
||||
QObject::connect(EventHandler::getInstance(), &EventHandler::signalEvent, this, &GrabberWrapper::handleEvent);
|
||||
}
|
||||
|
||||
GrabberWrapper::~GrabberWrapper()
|
||||
@@ -83,6 +86,11 @@ void GrabberWrapper::stop()
|
||||
}
|
||||
}
|
||||
|
||||
void GrabberWrapper::handleEvent(Event event)
|
||||
{
|
||||
_ggrabber->handleEvent(event);
|
||||
}
|
||||
|
||||
bool GrabberWrapper::isActive() const
|
||||
{
|
||||
return _timer->isActive();
|
||||
|
@@ -63,23 +63,38 @@ void HyperionIManager::stopAll()
|
||||
}
|
||||
}
|
||||
|
||||
void HyperionIManager::suspend()
|
||||
void HyperionIManager::handleEvent(Event event)
|
||||
{
|
||||
Info(_log,"Suspend all instances and enabled components");
|
||||
QMap<quint8, Hyperion*> instCopy = _runningInstances;
|
||||
for(const auto instance : instCopy)
|
||||
{
|
||||
emit instance->suspendRequest(true);
|
||||
Debug(_log,"%s Event [%d] received", eventToString(event), event);
|
||||
switch (event) {
|
||||
case Event::Suspend:
|
||||
toggleSuspend(true);
|
||||
break;
|
||||
|
||||
case Event::Resume:
|
||||
toggleSuspend(false);
|
||||
break;
|
||||
|
||||
case Event::Idle:
|
||||
toggleIdle(true);
|
||||
break;
|
||||
|
||||
case Event::ResumeIdle:
|
||||
toggleIdle(false);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void HyperionIManager::resume()
|
||||
void HyperionIManager::toggleSuspend(bool isSuspend)
|
||||
{
|
||||
Info(_log,"Resume all instances and enabled components");
|
||||
Info(_log,"Put all instances in %s state", isSuspend ? "suspend" : "working");
|
||||
QMap<quint8, Hyperion*> instCopy = _runningInstances;
|
||||
for(const auto instance : instCopy)
|
||||
{
|
||||
emit instance->suspendRequest(false);
|
||||
emit instance->suspendRequest(isSuspend);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
{"event", "standby"}
|
||||
};
|
||||
QJsonObject action2
|
||||
{
|
||||
{"action", "Resume"},
|
||||
{"event", "set stream path"}
|
||||
};
|
||||
|
||||
QJsonArray actions { action1, action2 };
|
||||
newGCecEventsConfig.insert("actions",actions);
|
||||
}
|
||||
config["cecEvents"] = newGCecEventsConfig;
|
||||
|
||||
migrated = true;
|
||||
Debug(_log, "CEC configuration records migrated");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -90,6 +90,18 @@
|
||||
"leds":
|
||||
{
|
||||
"$ref": "schema-leds.json"
|
||||
},
|
||||
"osEvents":
|
||||
{
|
||||
"$ref": "schema-osEvents.json"
|
||||
},
|
||||
"cecEvents":
|
||||
{
|
||||
"$ref": "schema-cecEvents.json"
|
||||
},
|
||||
"schedEvents":
|
||||
{
|
||||
"$ref": "schema-schedEvents.json"
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
|
@@ -23,5 +23,9 @@
|
||||
<file alias="schema-leds.json">schema/schema-leds.json</file>
|
||||
<file alias="schema-instCapture.json">schema/schema-instCapture.json</file>
|
||||
<file alias="schema-network.json">schema/schema-network.json</file>
|
||||
<file alias="schema-eventActions.json">schema/schema-eventActions.json</file>
|
||||
<file alias="schema-schedEvents.json">schema/schema-schedEvents.json</file>
|
||||
<file alias="schema-osEvents.json">schema/schema-osEvents.json</file>
|
||||
<file alias="schema-cecEvents.json">schema/schema-cecEvents.json</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
95
libsrc/hyperion/schema/schema-cecEvents.json
Normal file
95
libsrc/hyperion/schema/schema-cecEvents.json
Normal file
@@ -0,0 +1,95 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": true,
|
||||
"properties": {
|
||||
"enable": {
|
||||
"type": "boolean",
|
||||
"required": true,
|
||||
"title": "edt_conf_general_enable_title",
|
||||
"default": false,
|
||||
"propertyOrder": 1
|
||||
},
|
||||
"buttonReleaseDelayMs": {
|
||||
"type": "integer",
|
||||
"format": "stepper",
|
||||
"title": "edt_conf_cec_button_release_delay_ms_title",
|
||||
"append": "edt_append_ms",
|
||||
"minimum": 0,
|
||||
"maximum": 500,
|
||||
"step": 50,
|
||||
"default": 0,
|
||||
"required": false,
|
||||
"access": "expert",
|
||||
"propertyOrder": 2
|
||||
},
|
||||
"buttonRepeatRateMs": {
|
||||
"type": "integer",
|
||||
"format": "stepper",
|
||||
"title": "edt_conf_cec_button_repeat_rate_ms_title",
|
||||
"append": "edt_append_ms",
|
||||
"minimum": 0,
|
||||
"maximum": 250,
|
||||
"step": 10,
|
||||
"default": 0,
|
||||
"required": false,
|
||||
"access": "expert",
|
||||
"propertyOrder": 3
|
||||
},
|
||||
"doubleTapTimeoutMs": {
|
||||
"type": "integer",
|
||||
"format": "stepper",
|
||||
"title": "edt_conf_cec_double_tap_timeout_ms_title",
|
||||
"append": "edt_append_ms",
|
||||
"minimum": 50,
|
||||
"maximum": 1000,
|
||||
"step": 50,
|
||||
"default": 200,
|
||||
"required": false,
|
||||
"access": "expert",
|
||||
"propertyOrder": 4
|
||||
},
|
||||
"actions": {
|
||||
"type": "array",
|
||||
"title": "edt_conf_cec_actions_header_title",
|
||||
"minItems": 0,
|
||||
"required": false,
|
||||
"propertyOrder": 5,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": true,
|
||||
"title": "edt_conf_cec_actions_header_item_title",
|
||||
"properties": {
|
||||
"event": {
|
||||
"type": "string",
|
||||
"title": "edt_conf_cec_event_title",
|
||||
"enum": [
|
||||
"standby",
|
||||
"set stream path",
|
||||
"F1(blue)",
|
||||
"F2 (red)",
|
||||
"F3 (green)",
|
||||
"F4 (yellow)"
|
||||
],
|
||||
"options": {
|
||||
"enum_titles": [
|
||||
"edt_conf_enum_cec_opcode_standby",
|
||||
"edt_conf_enum_cec_opcode_set stream path",
|
||||
"edt_conf_enum_cec_key_f1_blue",
|
||||
"edt_conf_enum_cec_key_f2_red",
|
||||
"edt_conf_enum_cec_key_f3_green",
|
||||
"edt_conf_enum_cec_key_f4_yellow"
|
||||
]
|
||||
},
|
||||
"propertyOrder": 1
|
||||
},
|
||||
"action": {
|
||||
"$ref": "schema-eventActions.json"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
|
25
libsrc/hyperion/schema/schema-eventActions.json
Normal file
25
libsrc/hyperion/schema/schema-eventActions.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"type": "string",
|
||||
"title": "edt_conf_action_title",
|
||||
"enum": [
|
||||
"Suspend",
|
||||
"Resume",
|
||||
"ToggleSuspend",
|
||||
"Idle",
|
||||
"ResumeIdle",
|
||||
"ToggleIdle",
|
||||
"Restart"
|
||||
],
|
||||
"options": {
|
||||
"enum_titles": [
|
||||
"edt_conf_enum_action_suspend",
|
||||
"edt_conf_enum_action_resume",
|
||||
"edt_conf_enum_action_toggleSuspend",
|
||||
"edt_conf_enum_action_idle",
|
||||
"edt_conf_enum_action_resumeIdle",
|
||||
"edt_conf_enum_action_toggleIdle",
|
||||
"edt_conf_enum_action_restart"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@@ -212,21 +212,13 @@
|
||||
"required": true,
|
||||
"propertyOrder": 23
|
||||
},
|
||||
"cecDetection": {
|
||||
"type": "boolean",
|
||||
"title": "edt_conf_v4l2_cecDetection_title",
|
||||
"default": false,
|
||||
"required": true,
|
||||
"access": "advanced",
|
||||
"propertyOrder": 24
|
||||
},
|
||||
"signalDetection": {
|
||||
"type": "boolean",
|
||||
"title": "edt_conf_v4l2_signalDetection_title",
|
||||
"default": false,
|
||||
"required": true,
|
||||
"access": "expert",
|
||||
"propertyOrder": 25
|
||||
"propertyOrder": 24
|
||||
},
|
||||
"redSignalThreshold": {
|
||||
"type": "integer",
|
||||
@@ -242,7 +234,7 @@
|
||||
},
|
||||
"access": "expert",
|
||||
"required": true,
|
||||
"propertyOrder": 26
|
||||
"propertyOrder": 25
|
||||
},
|
||||
"greenSignalThreshold": {
|
||||
"type": "integer",
|
||||
@@ -258,7 +250,7 @@
|
||||
},
|
||||
"required": true,
|
||||
"access": "expert",
|
||||
"propertyOrder": 27
|
||||
"propertyOrder": 26
|
||||
},
|
||||
"blueSignalThreshold": {
|
||||
"type": "integer",
|
||||
@@ -274,7 +266,7 @@
|
||||
},
|
||||
"required": true,
|
||||
"access": "expert",
|
||||
"propertyOrder": 28
|
||||
"propertyOrder": 27
|
||||
},
|
||||
"noSignalCounterThreshold": {
|
||||
"type": "integer",
|
||||
@@ -289,7 +281,7 @@
|
||||
},
|
||||
"required": true,
|
||||
"access": "expert",
|
||||
"propertyOrder": 29
|
||||
"propertyOrder": 28
|
||||
},
|
||||
"sDVOffsetMin": {
|
||||
"type": "number",
|
||||
@@ -305,7 +297,7 @@
|
||||
},
|
||||
"required": true,
|
||||
"access": "expert",
|
||||
"propertyOrder": 30
|
||||
"propertyOrder": 29
|
||||
},
|
||||
"sDVOffsetMax": {
|
||||
"type": "number",
|
||||
@@ -321,7 +313,7 @@
|
||||
},
|
||||
"required": true,
|
||||
"access": "expert",
|
||||
"propertyOrder": 31
|
||||
"propertyOrder": 30
|
||||
},
|
||||
"sDHOffsetMin": {
|
||||
"type": "number",
|
||||
@@ -337,7 +329,7 @@
|
||||
},
|
||||
"required": true,
|
||||
"access": "expert",
|
||||
"propertyOrder": 32
|
||||
"propertyOrder": 31
|
||||
},
|
||||
"sDHOffsetMax": {
|
||||
"type": "number",
|
||||
@@ -353,7 +345,7 @@
|
||||
},
|
||||
"required": true,
|
||||
"access": "expert",
|
||||
"propertyOrder": 33
|
||||
"propertyOrder": 32
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
|
34
libsrc/hyperion/schema/schema-osEvents.json
Normal file
34
libsrc/hyperion/schema/schema-osEvents.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : true,
|
||||
"title" : "edt_conf_os_events_heading_title",
|
||||
"properties": {
|
||||
"suspendEnable": {
|
||||
"type": "boolean",
|
||||
"required": true,
|
||||
"title": "edt_conf_os_events_suspendEnable_title",
|
||||
"default": true,
|
||||
"propertyOrder": 1
|
||||
},
|
||||
"lockEnable": {
|
||||
"type": "boolean",
|
||||
"required": true,
|
||||
"title": "edt_conf_os_events_lockEnable_title",
|
||||
"default": true,
|
||||
"propertyOrder": 2
|
||||
},
|
||||
"suspendOnLockEnable": {
|
||||
"type": "boolean",
|
||||
"required": false,
|
||||
"title": "edt_conf_os_events_suspendOnLockEnable_title",
|
||||
"default": false,
|
||||
"options": {
|
||||
"dependencies": {
|
||||
"lockEnable": true
|
||||
}
|
||||
},
|
||||
"propertyOrder": 3
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
}
|
40
libsrc/hyperion/schema/schema-schedEvents.json
Normal file
40
libsrc/hyperion/schema/schema-schedEvents.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": true,
|
||||
"properties": {
|
||||
"enable": {
|
||||
"type": "boolean",
|
||||
"required": true,
|
||||
"title": "edt_conf_general_enable_title",
|
||||
"default": false,
|
||||
"propertyOrder": 1
|
||||
},
|
||||
"actions": {
|
||||
"type": "array",
|
||||
"title": "edt_conf_sched_actions_header_title",
|
||||
"minItems": 0,
|
||||
"required": false,
|
||||
"propertyOrder": 2,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": true,
|
||||
"title": "edt_conf_sched_actions_header_item_title",
|
||||
"properties": {
|
||||
"event": {
|
||||
"type": "string",
|
||||
"format": "time",
|
||||
"default": "23:00",
|
||||
"title": "edt_conf_time_event_title",
|
||||
"propertyOrder": 1
|
||||
},
|
||||
"action": {
|
||||
"$ref": "schema-eventActions.json"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
|
Reference in New Issue
Block a user