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