mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Have CECEvent to actions configurable, further clean-ups
This commit is contained in:
@@ -2,14 +2,13 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
#include <QMap>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <libcec/cec.h>
|
||||
|
||||
#include <utils/settings.h>
|
||||
|
||||
//#include <cec/CECEvent.h>
|
||||
#include <events/Event.h>
|
||||
|
||||
using CECCallbacks = CEC::ICECCallbacks;
|
||||
@@ -33,23 +32,28 @@ class CECHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CECHandler();
|
||||
CECHandler(const QJsonDocument& config, QObject * parent = nullptr);
|
||||
~CECHandler() override;
|
||||
|
||||
QString scan() const;
|
||||
|
||||
public slots:
|
||||
|
||||
bool start();
|
||||
void stop();
|
||||
|
||||
virtual void handleSettingsUpdate(settings::type type, const QJsonDocument& config);
|
||||
|
||||
signals:
|
||||
//void cecEvent(CECEvent event);
|
||||
private:
|
||||
|
||||
signals:
|
||||
void signalEvent(Event event);
|
||||
|
||||
private:
|
||||
|
||||
bool enable();
|
||||
void disable();
|
||||
|
||||
/* CEC Callbacks */
|
||||
static void onCecLogMessage (void * context, const CECLogMessage * message);
|
||||
static void onCecKeyPress (void * context, const CECKeyPress * key);
|
||||
@@ -64,6 +68,11 @@ private:
|
||||
bool openAdapter(const CECAdapterDescriptor & descriptor);
|
||||
void printAdapter(const CECAdapterDescriptor & descriptor) const;
|
||||
|
||||
// CEC Event Strings per https://github.com/Pulse-Eight/libcec/blob/master/src/libcec/CECTypeUtils.h
|
||||
void triggerAction(const QString& cecEvent);
|
||||
|
||||
QJsonDocument _config;
|
||||
|
||||
/* CEC Helpers */
|
||||
CECCallbacks getCallbacks() const;
|
||||
CECConfig getConfig() const;
|
||||
@@ -72,7 +81,14 @@ private:
|
||||
CECCallbacks _cecCallbacks {};
|
||||
CECConfig _cecConfig {};
|
||||
|
||||
bool _isInitialised;
|
||||
bool _isEnabled;
|
||||
|
||||
int _buttonReleaseDelayMs;
|
||||
int _buttonRepeatRateMs;
|
||||
int _doubleTapTimeoutMs;
|
||||
|
||||
QMap<QString,Event> _cecEventActionMap;
|
||||
|
||||
Logger * _logger {};
|
||||
};
|
||||
|
@@ -1,8 +1,11 @@
|
||||
#ifndef EVENT_H
|
||||
#define EVENT_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
enum class Event
|
||||
{
|
||||
Unknown,
|
||||
Suspend,
|
||||
Resume,
|
||||
ToggleSuspend,
|
||||
@@ -19,14 +22,29 @@ inline const char* eventToString(Event event)
|
||||
{
|
||||
case Event::Suspend: return "Suspend";
|
||||
case Event::Resume: return "Resume";
|
||||
case Event::ToggleSuspend: return "ToggleSuspend detector";
|
||||
case Event::ToggleSuspend: return "ToggleSuspend";
|
||||
case Event::Idle: return "Idle";
|
||||
case Event::ResumeIdle: return "ResumeIdle";
|
||||
case Event::ToggleIdle: return "ToggleIdle";
|
||||
case Event::Reload: return "Reload";
|
||||
case Event::Restart: return "Restart";
|
||||
case Event::Unknown:
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
inline Event stringToEvent(const QString& event)
|
||||
{
|
||||
if (event.compare("Suspend")==0) return Event::Suspend;
|
||||
if (event.compare("Resume")==0) return Event::Resume;
|
||||
if (event.compare("ToggleSuspend")==0) return Event::ToggleSuspend;
|
||||
if (event.compare("Idle")==0) return Event::Idle;
|
||||
if (event.compare("ResumeIdle")==0) return Event::ResumeIdle;
|
||||
if (event.compare("ToggleIdle")==0) return Event::ToggleIdle;
|
||||
if (event.compare("Reload")==0) return Event::Reload;
|
||||
if (event.compare("Restart")==0) return Event::Restart;
|
||||
return Event::Unknown;
|
||||
}
|
||||
|
||||
|
||||
#endif // EVENT_H
|
||||
|
Reference in New Issue
Block a user