MythTV master
mythcecadapter.h
Go to the documentation of this file.
1#ifndef CECADAPTER_H_
2#define CECADAPTER_H_
3
4// Qt
5#include <QObject>
6
7#define LIBCEC_ENABLED QString("libCECEnabled")
8#define LIBCEC_DEVICE QString("libCECDevice")
9#define LIBCEC_BASE QString("libCECBase")
10#define LIBCEC_PORT QString("libCECPort")
11#define POWEROFFTV_ALLOWED QString("PowerOffTVAllowed")
12#define POWEROFFTV_ONEXIT QString("PowerOffTVOnExit")
13#define POWERONTV_ALLOWED QString("PowerOnTVAllowed")
14#define POWERONTV_ONSTART QString("PowerOnTVOnStart")
15
16// libcec
17#include <libcec/cec.h>
18#include <iostream>
19using namespace CEC;
20
21class MythMainWindow;
22
24{
25 public:
26 enum MythCECAction : std::uint8_t
27 {
28 None = 0x00,
29 PowerOffTV = 0x01,
30 PowerOnTV = 0x02,
31 SwitchInput = 0x04
32 };
33
34 Q_DECLARE_FLAGS(MythCECActions, MythCECAction)
35
36#if CEC_LIB_VERSION_MAJOR <= 3
37 static int LogMessageCallback(void* /*unused*/, const cec_log_message Message);
38 static int KeyPressCallback (void* Adapter, const cec_keypress Keypress);
39 static int CommandCallback (void* Adapter, const cec_command Command);
40 static int AlertCallback (void* /*unused*/, const libcec_alert Alert, const libcec_parameter Data);
41#else
42 static void LogMessageCallback(void* /*unused*/, const cec_log_message* Message);
43 static void KeyPressCallback (void* Adapter, const cec_keypress* Keypress);
44 static void CommandCallback (void* Adapter, const cec_command* Command);
45 static void AlertCallback (void* /*unused*/, libcec_alert Alert, libcec_parameter Data);
46#endif
47 static void SourceCallback (void* /*unused*/, cec_logical_address Address, uint8_t Activated);
48 static QString AddressToString(int Address);
49
50 MythCECAdapter() = default;
52 void Open (MythMainWindow* Window);
53 void Close (void);
54 void Action (const QString &Action);
55 void IgnoreKeys (bool Ignore);
56
57 protected:
58 void HandleActions (MythCECActions Actions);
59 int HandleCommand (const cec_command &Command);
60 int HandleKeyPress(cec_keypress Key) const;
61 static void HandleSource (cec_logical_address Address, uint8_t Activated);
62 static int LogMessage (const cec_log_message &Message);
63 static int HandleAlert (libcec_alert Alert, libcec_parameter Data);
64
65 protected:
66 ICECAdapter *m_adapter { nullptr };
67 ICECCallbacks m_callbacks;
68 bool m_valid { false };
69 bool m_ignoreKeys { false };
70 bool m_powerOffTVAllowed { false };
71 bool m_powerOffTVOnExit { false };
72 bool m_powerOnTVAllowed { false };
73 bool m_powerOnTVOnStart { false };
74 bool m_switchInputAllowed { true };
75};
76#endif
77
An action (for this plugin) consists of a description, and a set of key sequences.
Definition: action.h:41
ICECCallbacks m_callbacks
static int KeyPressCallback(void *Adapter, const cec_keypress Keypress)
void IgnoreKeys(bool Ignore)
static QString AddressToString(int Address)
static void HandleSource(cec_logical_address Address, uint8_t Activated)
void Open(MythMainWindow *Window)
ICECAdapter * m_adapter
static int LogMessageCallback(void *, const cec_log_message Message)
bool m_powerOffTVAllowed
MythCECAdapter()=default
bool m_switchInputAllowed
static int HandleAlert(libcec_alert Alert, libcec_parameter Data)
void Action(const QString &Action)
static int AlertCallback(void *, const libcec_alert Alert, const libcec_parameter Data)
static int LogMessage(const cec_log_message &Message)
void HandleActions(MythCECActions Actions)
static void SourceCallback(void *, cec_logical_address Address, uint8_t Activated)
int HandleCommand(const cec_command &Command)
int HandleKeyPress(cec_keypress Key) const
static int CommandCallback(void *Adapter, const cec_command Command)