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