2 Copyright 2020 Chris Tallon; 2012 Marten Richter
4 This file is part of VOMP.
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.
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.
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/>.
21 #include "wremoteconfig.h"
23 #include "inputlinux.h"
31 InputMan* InputMan::instance = NULL;
43 InputMan* InputMan::getInstance()
50 bool i1{}, i2{}, i3{};
52 #ifdef VOMP_PLATFORM_RASPBERRY
53 inputLinux = new InputLinux();
54 i1 = inputLinux->init();
55 if (!i1) { delete inputLinux; inputLinux = NULL; }
57 // inputCEC = new InputCEC();
58 // i2 = inputCEC->init();
59 // if (!i2) { delete inputCEC; inputCEC = NULL; }
62 inputUDP = new InputUDP();
63 i3 = inputUDP->init();
64 if (!i3) { delete inputUDP; inputUDP = NULL; }
67 if (!i1 && !i2 && !i3)
69 Log::getInstance()->log("InputMan", Log::CRIT, "InputMan could not init any input module");
77 bool InputMan::start()
79 Log::getInstance()->log("InputMan", Log::DEBUG, "Start");
85 i1 = inputLinux->start();
90 i3 = inputUDP->start();
98 if (inputLinux) inputLinux->stop();
99 if (inputUDP) inputUDP->stop();
102 void InputMan::shutdown()
104 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start");
108 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - Linux");
110 inputLinux->shutdown();
117 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - CEC");
118 inputCEC->shutdown();
125 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - UDP");
127 inputUDP->shutdown();
135 bool InputMan::mayHaveFewButtons()
137 // 052 returned true if remotelinux was in effect - linux or CEC. What was it for?
139 if (inputLinux || inputCEC) return true;
143 bool InputMan::handlesVolume()
145 if (!inputCEC) return false;
146 return inputCEC->handlesVolume();
149 void InputMan::volumeUp()
151 if (inputCEC) inputCEC->volumeUp();
154 void InputMan::volumeDown()
156 if (inputCEC) inputCEC->volumeDown();
159 void InputMan::volumeMute()
161 if (inputCEC) inputCEC->volumeMute();
164 void InputMan::changePowerState(bool powerOn)
166 if (inputCEC) inputCEC->changePowerState(powerOn);
169 bool InputMan::addOptionsToPanes(int panenumber, Options* options, WOptionPane* pane)
171 if (inputLinux) inputLinux->addOptionsToPanes(panenumber, options, pane);
172 if (inputCEC) inputCEC->addOptionsToPanes(panenumber, options, pane);
174 return true; // FIXME
177 bool InputMan::addOptionPagesToWTB(WTabBar *wtb)
179 //if (inputLinux) inputLinux->addOptionPagesToWTB(wtb);
180 //if (inputCEC) inputCEC->addOptionPagesToWTB(wtb);
182 WRemoteConfig* wrc = new WRemoteConfig();
183 wtb->addTab(tr("Remote Control"), wrc);
185 return true; // FIXME
188 bool InputMan::saveOptionstoServer()
190 if (inputLinux) inputLinux->saveOptionstoServer();
191 if (inputCEC) inputCEC->saveOptionstoServer();
193 return true; // FIXME
196 const char* InputMan::getVompKeyName(UCHAR number)
200 case Input::VOLUMEUP:
201 return tr("Volume Up");
202 case Input::VOLUMEDOWN:
203 return tr("Volume Down");
204 case Input::CHANNELUP:
205 return tr("Channel up");
206 case Input::CHANNELDOWN:
207 return tr("Channel down");
249 return tr("Reverse");
253 return tr("Forward");
260 case Input::SKIPBACK:
261 return tr("Skip back");
262 case Input::SKIPFORWARD:
263 return tr("Skip forward");
267 return tr("Fullscreen");
274 case Input::PICTURES:
275 return tr("Pictures");
286 case Input::PREVCHANNEL:
287 return tr("Previous Channel");
292 case Input::PLAYPAUSE:
293 return tr("Play/Pause");
300 std::string InputMan::getHardCodedHardwareKeyNamesForVompKey(UCHAR vompKey)
302 // Go through each active Input class and get the hardware key name for vompKey
304 // which doesn't make any sense
306 std::string keyNames;
310 std::string k = inputLinux->getHardCodedHardwareKeyNamesForVompKey(vompKey);
311 if (k.size()) keyNames += k;
316 std::string k = inputCEC->getHardCodedHardwareKeyNamesForVompKey(vompKey);
317 if (k.size()) { keyNames += ", "; keyNames += k; }
322 std::string k = inputUDP->getHardCodedHardwareKeyNamesForVompKey(vompKey);
323 if (k.size()) { keyNames += ", "; keyNames += k; }
329 std::string InputMan::getAllHardwareKeyNamesAssignedToVompKey(UCHAR vompKey)
331 std::string keyNames;
335 std::string k = inputLinux->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
336 if (k.size()) keyNames += k;
341 std::string k = inputCEC->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
342 if (k.size()) { keyNames += ", "; keyNames += k; }
347 std::string k = inputUDP->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
348 if (k.size()) { keyNames += ", "; keyNames += k; }