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>
19 using namespace CEC;
20 using namespace std;
21 
23 {
24  public:
26  {
27  None = 0x00,
28  PowerOffTV = 0x01,
29  PowerOnTV = 0x02,
30  SwitchInput = 0x04
31  };
32 
33  Q_DECLARE_FLAGS(MythCECActions, MythCECAction)
34 
35 #if CEC_LIB_VERSION_MAJOR <= 3
36  static int LogMessageCallback(void* /*unused*/, const cec_log_message Message);
37  static int KeyPressCallback (void* Adapter, const cec_keypress Keypress);
38  static int CommandCallback (void* Adapter, const cec_command Command);
39  static int AlertCallback (void* /*unused*/, const libcec_alert Alert, const libcec_parameter Data);
40 #else
41  static void LogMessageCallback(void* /*unused*/, const cec_log_message* Message);
42  static void KeyPressCallback (void* Adapter, const cec_keypress* Keypress);
43  static void CommandCallback (void* Adapter, const cec_command* Command);
44  static void AlertCallback (void* /*unused*/, libcec_alert Alert, libcec_parameter Data);
45 #endif
46  static void SourceCallback (void* /*unused*/, cec_logical_address Address, uint8_t Activated);
47  static QString AddressToString(int Address);
48 
49  MythCECAdapter() = default;
50  ~MythCECAdapter();
51  void Open (void);
52  void Close (void);
53  void Action (const QString &Action);
54  void IgnoreKeys (bool Ignore);
55 
56  protected:
57  void HandleActions (MythCECActions Actions);
58  int HandleCommand (const cec_command &Command);
59  int HandleKeyPress(const cec_keypress &Key) const;
60  static void HandleSource (cec_logical_address Address, uint8_t Activated);
61  static int LogMessage (const cec_log_message &Message);
62  static int HandleAlert (libcec_alert Alert, const libcec_parameter &Data);
63 
64  protected:
65  ICECAdapter *m_adapter { nullptr };
66  ICECCallbacks m_callbacks;
67  bool m_valid { false };
68  bool m_ignoreKeys { false };
69  bool m_powerOffTVAllowed { false };
70  bool m_powerOffTVOnExit { false };
71  bool m_powerOnTVAllowed { false };
72  bool m_powerOnTVOnStart { false };
73  bool m_switchInputAllowed { true };
74 };
75 #endif
76 
MythCECAdapter::m_callbacks
ICECCallbacks m_callbacks
Definition: mythcecadapter.h:66
Action
An action (for this plugin) consists of a description, and a set of key sequences.
Definition: action.h:41
Command
Definition: gamesettings.cpp:239
MythCECAdapter::MythCECAction
MythCECAction
Definition: mythcecadapter.h:26
MythCECAdapter::MythCECAdapter
MythCECAdapter()=default
LogMessage
QList< QByteArray > LogMessage
Definition: loggingserver.h:127
MythCECAdapter
Definition: mythcecadapter.h:23