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()
58 #ifdef VOMP_PLATFORM_RASPBERRY
59 inputLinux = new InputLinux();
60 ret = inputLinux->init();
64 { delete inputLinux; inputLinux = NULL; }
66 // FIXME enable modules by new config system NCONFIG
68 // inputCEC = new InputCEC();
69 // ret = inputCEC->init();
73 // { delete inputCEC; inputCEC = NULL; }
76 inputUDP = new InputUDP();
77 ret = inputUDP->init();
81 { delete inputUDP; inputUDP = NULL; }
84 inputWin = new InputWin();
85 ret = inputWin->init();
89 { delete inputWin; inputWin = NULL; }
94 Log::getInstance()->log("InputMan", Log::CRIT, "InputMan could not init any input module");
102 bool InputMan::start()
104 Log::getInstance()->log("InputMan", Log::DEBUG, "Start");
108 #ifdef VOMP_PLATFORM_RASPBERRY
109 if (inputLinux && inputLinux->start()) oneOK = true;
112 if (inputUDP && inputUDP->start()) oneOK = true;
115 Log::getInstance()->log("InputMan", Log::CRIT, "InputMan could not start any input module");
120 void InputMan::stop()
122 Log::getInstance()->log("InputMan", Log::DEBUG, "Stop called");
124 #ifdef VOMP_PLATFORM_RASPBERRY
125 if (inputLinux) inputLinux->stop();
127 if (inputUDP) inputUDP->stop();
130 void InputMan::shutdown()
132 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start");
134 #ifdef VOMP_PLATFORM_RASPBERRY
138 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - Linux");
140 inputLinux->shutdown();
147 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - CEC");
148 inputCEC->shutdown();
157 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - UDP");
159 inputUDP->shutdown();
167 bool InputMan::mayHaveFewButtons()
169 // 052 returned true if remotelinux was in effect - linux or CEC. What was it for?
171 if (inputLinux || inputCEC) return true;
175 bool InputMan::handlesVolume()
177 #ifdef VOMP_PLATFORM_RASPBERRY
178 if (!inputCEC) return false;
179 return inputCEC->handlesVolume();
185 void InputMan::volumeUp()
187 #ifdef VOMP_PLATFORM_RASPBERRY
188 if (inputCEC) inputCEC->volumeUp();
192 void InputMan::volumeDown()
194 #ifdef VOMP_PLATFORM_RASPBERRY
195 if (inputCEC) inputCEC->volumeDown();
199 void InputMan::volumeMute()
201 #ifdef VOMP_PLATFORM_RASPBERRY
202 if (inputCEC) inputCEC->volumeMute();
206 void InputMan::changePowerState(bool powerOn)
208 #ifdef VOMP_PLATFORM_RASPBERRY
209 if (inputCEC) inputCEC->changePowerState(powerOn);
213 bool InputMan::addOptionsToPanes(int panenumber, Options* options, WOptionPane* pane)
215 #ifdef VOMP_PLATFORM_RASPBERRY
216 if (inputLinux) inputLinux->addOptionsToPanes(panenumber, options, pane);
217 if (inputCEC) inputCEC->addOptionsToPanes(panenumber, options, pane);
220 return true; // FIXME
223 bool InputMan::addOptionPagesToWTB(WTabBar *wtb)
225 WRemoteConfig* wrc = new WRemoteConfig();
226 wtb->addTab(tr("Remote Control"), wrc);
228 return true; // FIXME
231 bool InputMan::loadOptionsFromServer(VDR* vdr)
233 #ifdef VOMP_PLATFORM_RASPBERRY
234 if (inputLinux) inputLinux->loadOptionsFromServer(vdr);
235 if (inputCEC) inputCEC->loadOptionsFromServer(vdr);
238 return true; // FIXME
241 bool InputMan::saveOptionstoServer()
243 #ifdef VOMP_PLATFORM_RASPBERRY
244 if (inputLinux) inputLinux->saveOptionstoServer();
245 if (inputCEC) inputCEC->saveOptionstoServer();
247 return true; // FIXME
250 const char* InputMan::getVompKeyName(UCHAR number)
254 case Input::VOLUMEUP:
255 return tr("Volume Up");
256 case Input::VOLUMEDOWN:
257 return tr("Volume Down");
258 case Input::CHANNELUP:
259 return tr("Channel up");
260 case Input::CHANNELDOWN:
261 return tr("Channel down");
303 return tr("Reverse");
307 return tr("Forward");
314 case Input::SKIPBACK:
315 return tr("Skip back");
316 case Input::SKIPFORWARD:
317 return tr("Skip forward");
321 return tr("Fullscreen");
328 case Input::PICTURES:
329 return tr("Pictures");
340 case Input::PREVCHANNEL:
341 return tr("Previous Channel");
346 case Input::PLAYPAUSE:
347 return tr("Play/Pause");
354 std::string InputMan::getHardCodedHardwareKeyNamesForVompKey(UCHAR vompKey)
356 // Go through each active Input class and get the hardware key name for vompKey
358 // which doesn't make any sense
360 std::string keyNames;
362 #ifdef VOMP_PLATFORM_RASPBERRY
365 std::string k = inputLinux->getHardCodedHardwareKeyNamesForVompKey(vompKey);
366 if (k.size()) keyNames += k;
371 std::string k = inputCEC->getHardCodedHardwareKeyNamesForVompKey(vompKey);
372 if (k.size()) { keyNames += ", "; keyNames += k; }
378 std::string k = inputUDP->getHardCodedHardwareKeyNamesForVompKey(vompKey);
379 if (k.size()) { keyNames += ", "; keyNames += k; }
385 std::string InputMan::getAllHardwareKeyNamesAssignedToVompKey(UCHAR vompKey)
387 std::string keyNames;
389 #ifdef VOMP_PLATFORM_RASPBERRY
392 std::string k = inputLinux->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
393 if (k.size()) keyNames += k;
398 std::string k = inputCEC->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
399 if (k.size()) { keyNames += ", "; keyNames += k; }
405 std::string k = inputUDP->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
406 if (k.size()) { keyNames += ", "; keyNames += k; }
412 void InputMan::ResetToDefault()
414 #ifdef VOMP_PLATFORM_RASPBERRY
416 if (inputLinux) inputLinux->ResetToDefault();
418 if (inputCEC) inputCEC->ResetToDefault();
422 if (inputUDP) inputUDP->ResetToDefault();
425 void InputMan::EnterLearningMode(UCHAR vompKey)
427 #ifdef VOMP_PLATFORM_RASPBERRY
428 if (inputLinux) inputLinux->EnterLearningMode(vompKey);
430 // if (inputCEC) inputCEC->EnterLearningMode(); FIXME - is there any such thing?
434 void InputMan::cancelLearnMode()
436 #ifdef VOMP_PLATFORM_RASPBERRY
437 if (inputLinux) inputLinux->cancelLearnMode();
438 if (inputCEC) inputCEC->cancelLearnMode();
440 if (inputUDP) inputUDP->cancelLearnMode();