]> git.vomp.tv Git - vompclient.git/blob - input.h
Rename Remote class to Input, RemoteLinux to InputLinux
[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
32 typedef std::map<ULLONG,UCHAR> RemoteTranslationList;
33
34 class Input: public AbstractOption
35 {
36   public:
37     Input();
38     virtual ~Input();
39     static Input* getInstance();
40
41     bool start();
42     void stop();
43
44     bool addOptionPagesToWTB(WTabBar *wtb);
45     bool loadOptionsfromServer(VDR* vdr);
46     bool saveOptionstoServer();
47
48     void setRemoteType(UCHAR type);
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 int init(const char *devName)=0;
56     virtual int shutdown()=0;
57     virtual UCHAR getButtonPress(int how)=0; // DEPRECATED
58
59     virtual bool mayHaveFewButtons() {return false;};
60
61     virtual bool handlesVolume() {return false;};
62     virtual void volumeUp() {};
63     virtual void volumeDown() {};
64     virtual void volumeMute() {};
65
66     virtual void InitHWCListwithDefaults();
67     virtual char* HCWDesc(ULLONG hcw);
68     const char *CommandDesc(UCHAR number);
69     char *CommandTranslateStr(UCHAR command);
70     virtual const char*HardcodedTranslateStr(UCHAR command);
71     void EnterLearnMode(UCHAR command);
72     void ResetToDefault();
73
74     virtual void changePowerState(bool /* poweron */) {}; //informs the remote control, that about vomp's power state, this is important e.g. for cec
75
76     const static ULONG NOLEARNMODE = 256;
77     // Not buttons
78     const static UCHAR NA_LEARN    = 101;
79     const static UCHAR NA_NONE     = 98;
80     const static UCHAR NA_UNKNOWN  = 99;
81     const static UCHAR NA_SIGNAL   = 100;
82     const static UCHAR DF_UP       = 94;
83     const static UCHAR DF_DOWN     = 95;
84     const static UCHAR DF_LEFT     = 96;
85     const static UCHAR DF_RIGHT    = 97;
86
87     // Problem common buttons
88     const static UCHAR VOLUMEUP    = 16;
89     const static UCHAR VOLUMEDOWN  = 17;
90     const static UCHAR CHANNELUP   = 32;
91     const static UCHAR CHANNELDOWN = 33;
92
93     // Common buttons
94     const static UCHAR ZERO        = 0;
95     const static UCHAR ONE         = 1;
96     const static UCHAR TWO         = 2;
97     const static UCHAR THREE       = 3;
98     const static UCHAR FOUR        = 4;
99     const static UCHAR FIVE        = 5;
100     const static UCHAR SIX         = 6;
101     const static UCHAR SEVEN       = 7;
102     const static UCHAR EIGHT       = 8;
103     const static UCHAR NINE        = 9;
104     const static UCHAR POWER       = 61;
105     const static UCHAR GO          = 59;
106     const static UCHAR BACK        = 31;
107     const static UCHAR MENU        = 13;
108     const static UCHAR RED         = 11;
109     const static UCHAR GREEN       = 46;
110     const static UCHAR YELLOW      = 56;
111     const static UCHAR BLUE        = 41;
112     const static UCHAR MUTE        = 15;
113     const static UCHAR RADIO       = 12; // The unlabelled button on old
114     const static UCHAR REVERSE     = 50;
115     const static UCHAR PLAY        = 53;
116     const static UCHAR FORWARD     = 52;
117     const static UCHAR RECORD      = 55;
118     const static UCHAR STOP        = 54;
119     const static UCHAR PAUSE       = 48;
120     const static UCHAR SKIPBACK    = 36;
121     const static UCHAR SKIPFORWARD = 30;
122     const static UCHAR OK          = 37;
123
124     // Old remote only
125     const static UCHAR FULL        = 60;
126
127     // New remote only
128     const static UCHAR TV          = 28;
129     const static UCHAR VIDEOS      = 24;
130     const static UCHAR MUSIC       = 25;
131     const static UCHAR PICTURES    = 26;
132     const static UCHAR GUIDE       = 27;
133     const static UCHAR UP          = 20;
134     const static UCHAR DOWN        = 21;
135     const static UCHAR LEFT        = 22;
136     const static UCHAR RIGHT       = 23;
137     const static UCHAR PREVCHANNEL = 18;
138     const static UCHAR STAR        = 10;
139     const static UCHAR HASH        = 14;
140
141     // Android only
142     const static UCHAR PLAYPAUSE   = 201;
143     // cec only
144     const static UCHAR POWERON     = 202;
145     const static UCHAR POWEROFF    = 203;
146
147
148     // Remote types
149     const static UCHAR OLDREMOTE   = 1;
150     const static UCHAR NEWREMOTE   = 2;
151
152   protected:
153     virtual UCHAR TranslateHWCFixed(ULLONG code);
154     UCHAR TranslateHWCList(ULLONG code);
155     UCHAR TranslateHWC(ULLONG code);
156     
157     static Input* instance;
158     ULONG learnmode;
159     UCHAR remoteType;
160     RemoteTranslationList translist;
161
162     std::thread listenThread;
163     std::mutex threadStartProtect;
164
165     virtual void eventLoop() {}; // FIXME change to abstract
166     virtual void informStopEventLoop() {}; // abstract
167
168     bool listenLoopStop{};
169 };
170
171 #endif
172
173 // FIXME rename all remote stuff to some sort of INPUT
174 // Roll in UDP receiver
175
176 // FIXME have Top remote system create new listeners for various devices? Hot plug?
177 // Where remotelinux has multi listeners, move that to top?