]> git.vomp.tv Git - vompclient.git/blob - input.h
WIP [broken]
[vompclient.git] / input.h
1 /*
2     Copyright 2004-2020 Chris Tallon
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 INPUT_H
21 #define INPUT_H
22
23 #include <stdio.h>
24 #include <map>
25 #include <thread>
26 #include <mutex>
27
28 #include "defines.h"
29 #include "abstractoption.h"
30
31 // FIXME make common base class sendKey function
32
33
34 typedef std::map<ULLONG, UCHAR> RemoteTranslationList;
35
36 class Input: public AbstractOption
37 {
38   public:
39     Input();
40     virtual ~Input();
41
42     virtual bool start() { return false; }
43     virtual void stop() {}
44
45     // Abstract Option interface
46  //   virtual bool addOptionPagesToWTB(WTabBar *wtb);
47     virtual bool loadOptionsfromServer(VDR* vdr);
48     virtual bool saveOptionstoServer();
49
50     void setHWCtoCommand(ULLONG hcw, UCHAR command);
51     void unsetHWC(ULLONG hcw);
52     void LoadKeysConfig(VDR* vdr, const char* keynum);
53     void SaveKeysConfig();
54     void EnterLearningMode(UCHAR command);
55
56     virtual int init()=0;
57     virtual void shutdown()=0;
58
59     virtual bool handlesVolume() {return false;};
60     virtual void volumeUp() {};
61     virtual void volumeDown() {};
62     virtual void volumeMute() {};
63     virtual void changePowerState(bool /* poweron */) {}; //informs the remote control, that about vomp's power state, this is important e.g. for cec
64
65     virtual void InitHWCListwithDefaults()=0;
66     virtual char* HCWDesc(ULLONG hcw);
67     char* CommandTranslateStr(UCHAR command);
68     static const char* HardcodedTranslateStr(UCHAR command);
69     void EnterLearnMode(UCHAR command);
70     void ResetToDefault();
71
72
73     const static ULONG NOLEARNMODE = 256;
74     // Not buttons
75     const static UCHAR NA_LEARN    = 101;
76     const static UCHAR NA_NONE     = 98;
77     const static UCHAR NA_UNKNOWN  = 99;
78     const static UCHAR NA_SIGNAL   = 100;
79
80     // Problem common buttons
81     const static UCHAR VOLUMEUP    = 16;
82     const static UCHAR VOLUMEDOWN  = 17;
83     const static UCHAR CHANNELUP   = 32;
84     const static UCHAR CHANNELDOWN = 33;
85
86     // Common buttons
87     const static UCHAR ZERO        = 0;
88     const static UCHAR ONE         = 1;
89     const static UCHAR TWO         = 2;
90     const static UCHAR THREE       = 3;
91     const static UCHAR FOUR        = 4;
92     const static UCHAR FIVE        = 5;
93     const static UCHAR SIX         = 6;
94     const static UCHAR SEVEN       = 7;
95     const static UCHAR EIGHT       = 8;
96     const static UCHAR NINE        = 9;
97     const static UCHAR POWER       = 61;
98     const static UCHAR GO          = 59;
99     const static UCHAR BACK        = 31;
100     const static UCHAR MENU        = 13;
101     const static UCHAR RED         = 11;
102     const static UCHAR GREEN       = 46;
103     const static UCHAR YELLOW      = 56;
104     const static UCHAR BLUE        = 41;
105     const static UCHAR MUTE        = 15;
106     const static UCHAR RADIO       = 12; // The unlabelled button on old
107     const static UCHAR REVERSE     = 50;
108     const static UCHAR PLAY        = 53;
109     const static UCHAR FORWARD     = 52;
110     const static UCHAR RECORD      = 55;
111     const static UCHAR STOP        = 54;
112     const static UCHAR PAUSE       = 48;
113     const static UCHAR SKIPBACK    = 36;
114     const static UCHAR SKIPFORWARD = 30;
115     const static UCHAR OK          = 37;
116
117     // Old remote only
118     const static UCHAR FULL        = 60;
119
120     // New remote only
121     const static UCHAR TV          = 28;
122     const static UCHAR VIDEOS      = 24;
123     const static UCHAR MUSIC       = 25;
124     const static UCHAR PICTURES    = 26;
125     const static UCHAR GUIDE       = 27;
126     const static UCHAR UP          = 20;
127     const static UCHAR DOWN        = 21;
128     const static UCHAR LEFT        = 22;
129     const static UCHAR RIGHT       = 23;
130     const static UCHAR PREVCHANNEL = 18;
131     const static UCHAR STAR        = 10;
132     const static UCHAR HASH        = 14;
133
134     // Android only
135     const static UCHAR PLAYPAUSE   = 201;
136     // cec only
137     const static UCHAR POWERON     = 202;
138     const static UCHAR POWEROFF    = 203;
139
140   protected:
141     virtual UCHAR TranslateHWCFixed(int code)=0;
142     UCHAR TranslateHWCList(int code);
143     UCHAR TranslateHWC(int code);
144     
145     ULONG learnmode;
146     RemoteTranslationList translist;
147 };
148
149 #endif