]> git.vomp.tv Git - vompclient.git/blob - inputlinux.h
Rename Remote class to Input, RemoteLinux to InputLinux
[vompclient.git] / inputlinux.h
1 /*
2     Copyright 2004-2020 Chris Tallon; 2012 Marten Richter
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #ifndef INPUTLINUX_H
21 #define INPUTLINUX_H
22
23 #include <stdio.h>
24 #include <libcec/cec.h>
25 #include <vector>
26
27 #include "defines.h"
28 #include "log.h"
29 #include "input.h"
30
31 class InputLinux : public Input
32 {
33   public:
34     InputLinux();
35     virtual ~InputLinux();
36
37     int init(const char *devName);
38     int shutdown();
39     int getDevice();
40     UCHAR getButtonPress(int) { return NA_UNKNOWN; } // DEPRECATED
41   //  void Signal();
42
43 //  void SendPower();
44     void InitHWCListwithDefaults();
45     const char*HardcodedTranslateStr(UCHAR command);
46     char* HCWDesc(ULLONG hcw);
47     
48     void changePowerState(bool poweron);
49
50     bool loadOptionsfromServer(VDR* vdr);
51     bool saveOptionstoServer();
52     bool addOptionsToPanes(int panenumber,Options *options,WOptionPane* pane);
53     bool handleOptionChanges(Option* option);
54
55     bool mayHaveFewButtons() {return true;};
56
57     virtual bool handlesVolume() { return cechandlesvolume; };
58     virtual void volumeUp();
59     virtual void volumeDown();
60     virtual void volumeMute();
61
62     int initCec();
63     void deinitCec();
64
65   private: 
66     int initted{};
67     bool signal{};
68     bool cechandlesvolume{};
69
70     UCHAR TranslateHWCFixed(ULLONG code);
71     void InitKeymap();
72     std::vector<int> devices;
73     int num_loop{};
74
75     CEC::ICECAdapter* cec_adap{};
76     CEC::libcec_configuration cec_config;
77     CEC::ICECCallbacks cec_callbacks;
78
79     void incomingCECkey(int keys);
80     void incomingPowerkey(UCHAR key);
81
82 #if CEC_LIB_VERSION_MAJOR >= 4
83     static void cecLogMessage(void *param, const CEC::cec_log_message* message);
84     static void cecKeyPress(void*param, const CEC::cec_keypress* key);
85     static void cecCommand(void *param, const CEC::cec_command* command);
86     static void cecConfigurationChanged(void *param, const CEC::libcec_configuration* config);
87 #else
88     static int cecLogMessage(void *param, const CEC::cec_log_message message);
89     static int cecKeyPress(void*param, const CEC::cec_keypress key);
90     static int cecCommand(void *param, const CEC::cec_command command);
91     static int cecConfigurationChanged(void *param, const CEC::libcec_configuration config);
92 #endif
93     static void cecSourceActivated(void*param, const CEC::cec_logical_address address, const uint8_t activated);
94
95     void eventLoop();
96     void informStopEventLoop();
97
98     int pfds[2];
99 };
100
101 #endif