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 #ifdef VOMP_PLATFORM_RASPBERRY
24 #include "inputlinux.h"
36 InputMan* InputMan::instance = NULL;
48 InputMan* InputMan::getInstance()
55 bool i1{}, i2{}, i3{}, i4{};
57 #ifdef VOMP_PLATFORM_RASPBERRY
58 inputLinux = new InputLinux();
59 i1 = inputLinux->init();
60 if (!i1) { delete inputLinux; inputLinux = NULL; }
62 // inputCEC = new InputCEC();
63 // i2 = inputCEC->init();
64 // if (!i2) { delete inputCEC; inputCEC = NULL; }
67 inputUDP = new InputUDP();
68 i3 = inputUDP->init();
69 if (!i3) { delete inputUDP; inputUDP = NULL; }
72 inputWin = new InputWin();
73 i4 = inputWin->init();
74 if (!i4) { delete inputWin; inputWin = NULL; }
77 if (!i1 && !i2 && !i3 && !i4)
79 Log::getInstance()->log("InputMan", Log::CRIT, "InputMan could not init any input module");
87 bool InputMan::start()
89 Log::getInstance()->log("InputMan", Log::DEBUG, "Start");
93 #ifdef VOMP_PLATFORM_RASPBERRY
96 i1 = inputLinux->start();
102 i3 = inputUDP->start();
108 void InputMan::stop()
110 Log::getInstance()->log("InputMan", Log::DEBUG, "Stop called");
112 #ifdef VOMP_PLATFORM_RASPBERRY
113 if (inputLinux) inputLinux->stop();
115 if (inputUDP) inputUDP->stop();
118 void InputMan::shutdown()
120 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start");
122 #ifdef VOMP_PLATFORM_RASPBERRY
126 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - Linux");
128 inputLinux->shutdown();
135 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - CEC");
136 inputCEC->shutdown();
145 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - UDP");
147 inputUDP->shutdown();
155 bool InputMan::mayHaveFewButtons()
157 // 052 returned true if remotelinux was in effect - linux or CEC. What was it for?
159 if (inputLinux || inputCEC) return true;
163 bool InputMan::handlesVolume()
165 #ifdef VOMP_PLATFORM_RASPBERRY
166 if (!inputCEC) return false;
167 return inputCEC->handlesVolume();
173 void InputMan::volumeUp()
175 #ifdef VOMP_PLATFORM_RASPBERRY
176 if (inputCEC) inputCEC->volumeUp();
180 void InputMan::volumeDown()
182 #ifdef VOMP_PLATFORM_RASPBERRY
183 if (inputCEC) inputCEC->volumeDown();
187 void InputMan::volumeMute()
189 #ifdef VOMP_PLATFORM_RASPBERRY
190 if (inputCEC) inputCEC->volumeMute();
194 void InputMan::changePowerState(bool powerOn)
196 #ifdef VOMP_PLATFORM_RASPBERRY
197 if (inputCEC) inputCEC->changePowerState(powerOn);
201 bool InputMan::addOptionsToPanes(int panenumber, Options* options, WOptionPane* pane)
203 #ifdef VOMP_PLATFORM_RASPBERRY
204 if (inputLinux) inputLinux->addOptionsToPanes(panenumber, options, pane);
205 if (inputCEC) inputCEC->addOptionsToPanes(panenumber, options, pane);
208 return true; // FIXME
211 bool InputMan::addOptionPagesToWTB(WTabBar *wtb)
213 WRemoteConfig* wrc = new WRemoteConfig();
214 wtb->addTab(tr("Remote Control"), wrc);
216 return true; // FIXME
219 bool InputMan::loadOptionsFromServer(VDR* vdr)
221 #ifdef VOMP_PLATFORM_RASPBERRY
222 if (inputLinux) inputLinux->loadOptionsFromServer(vdr);
223 if (inputCEC) inputCEC->loadOptionsFromServer(vdr);
226 return true; // FIXME
229 bool InputMan::saveOptionstoServer()
231 #ifdef VOMP_PLATFORM_RASPBERRY
232 if (inputLinux) inputLinux->saveOptionstoServer();
233 if (inputCEC) inputCEC->saveOptionstoServer();
235 return true; // FIXME
238 const char* InputMan::getVompKeyName(UCHAR number)
242 case Input::VOLUMEUP:
243 return tr("Volume Up");
244 case Input::VOLUMEDOWN:
245 return tr("Volume Down");
246 case Input::CHANNELUP:
247 return tr("Channel up");
248 case Input::CHANNELDOWN:
249 return tr("Channel down");
291 return tr("Reverse");
295 return tr("Forward");
302 case Input::SKIPBACK:
303 return tr("Skip back");
304 case Input::SKIPFORWARD:
305 return tr("Skip forward");
309 return tr("Fullscreen");
316 case Input::PICTURES:
317 return tr("Pictures");
328 case Input::PREVCHANNEL:
329 return tr("Previous Channel");
334 case Input::PLAYPAUSE:
335 return tr("Play/Pause");
342 std::string InputMan::getHardCodedHardwareKeyNamesForVompKey(UCHAR vompKey)
344 // Go through each active Input class and get the hardware key name for vompKey
346 // which doesn't make any sense
348 std::string keyNames;
350 #ifdef VOMP_PLATFORM_RASPBERRY
353 std::string k = inputLinux->getHardCodedHardwareKeyNamesForVompKey(vompKey);
354 if (k.size()) keyNames += k;
359 std::string k = inputCEC->getHardCodedHardwareKeyNamesForVompKey(vompKey);
360 if (k.size()) { keyNames += ", "; keyNames += k; }
366 std::string k = inputUDP->getHardCodedHardwareKeyNamesForVompKey(vompKey);
367 if (k.size()) { keyNames += ", "; keyNames += k; }
373 std::string InputMan::getAllHardwareKeyNamesAssignedToVompKey(UCHAR vompKey)
375 std::string keyNames;
377 #ifdef VOMP_PLATFORM_RASPBERRY
380 std::string k = inputLinux->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
381 if (k.size()) keyNames += k;
386 std::string k = inputCEC->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
387 if (k.size()) { keyNames += ", "; keyNames += k; }
393 std::string k = inputUDP->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
394 if (k.size()) { keyNames += ", "; keyNames += k; }
400 void InputMan::ResetToDefault()
402 #ifdef VOMP_PLATFORM_RASPBERRY
404 if (inputLinux) inputLinux->ResetToDefault();
406 if (inputCEC) inputCEC->ResetToDefault();
410 if (inputUDP) inputUDP->ResetToDefault();
413 void InputMan::EnterLearningMode(UCHAR vompKey)
415 #ifdef VOMP_PLATFORM_RASPBERRY
416 if (inputLinux) inputLinux->EnterLearningMode(vompKey);
418 // if (inputCEC) inputCEC->EnterLearningMode(); FIXME - is there any such thing?
422 void InputMan::cancelLearnMode()
424 #ifdef VOMP_PLATFORM_RASPBERRY
425 if (inputLinux) inputLinux->cancelLearnMode();
426 if (inputCEC) inputCEC->cancelLearnMode();
428 if (inputUDP) inputUDP->cancelLearnMode();