-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
main.h
89 lines (64 loc) · 2.29 KB
/
main.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "uinput.h"
#include "libcec.h"
#include <limits.h>
#include <string>
#include <queue>
#include <list>
class Command
{
public:
Command(int command, CEC::cec_user_control_code keycode=CEC::CEC_USER_CONTROL_CODE_UNKNOWN) : command(command), keycode(keycode) {};
~Command() {};
const int command;
union
{
const CEC::cec_user_control_code keycode;
};
};
class Main : public CecCallback {
private:
// Main controls
Cec cec;
UInput uinput;
char cec_name[HOST_NAME_MAX];
// Some config params
bool makeActive;
bool running; // TODO Change this to be threadsafe!. Voiatile or better
//
std::list<__u16> lastUInputKeys; // for key(s) repetition
//
Main();
virtual ~Main();
// Not implemented to avoid copying the singleton
Main(Main const&);
void operator=(Main const&);
static void signalHandler(int sigNum);
static const std::vector<std::list<__u16>> & setupUinputMap();
std::queue<Command> commands;
std::string onStandbyCommand;
std::string onActivateCommand;
std::string onDeactivateCommand;
CEC::cec_logical_address logicalAddress;
char *getCecName();
void push(Command command);
public:
static const std::vector<std::list<__u16>> uinputCecMap;
int onCecLogMessage(const CEC::cec_log_message &message);
int onCecKeyPress(const CEC::cec_keypress &key);
int onCecKeyPress(const CEC::cec_user_control_code & keycode);
int onCecCommand(const CEC::cec_command &command);
int onCecConfigurationChanged(const CEC::libcec_configuration & configuration);
int onCecAlert(const CEC::libcec_alert alert, const CEC::libcec_parameter & param);
int onCecMenuStateChanged(const CEC::cec_menu_state & menu_state);
void onCecSourceActivated(const CEC::cec_logical_address & address, bool isActivated);
static Main & instance();
void loop(const std::string &device = "");
void stop();
void restart();
void listDevices();
void setMakeActive(bool active) {this->makeActive = active;};
void setOnStandbyCommand(const std::string &cmd) {this->onStandbyCommand = cmd;};
void setOnActivateCommand(const std::string &cmd) {this->onActivateCommand = cmd;};
void setOnDeactivateCommand(const std::string &cmd) {this->onDeactivateCommand = cmd;};
void setTargetAddress(const HDMI::address & address) {cec.setTargetAddress(address);};
};