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 // FIXME enable modules by new config system NCONFIG
64 // inputCEC = new InputCEC();
65 // i2 = inputCEC->init();
66 // if (!i2) { delete inputCEC; inputCEC = NULL; }
69 inputUDP = new InputUDP();
70 i3 = inputUDP->init();
71 if (!i3) { delete inputUDP; inputUDP = NULL; }
74 inputWin = new InputWin();
75 i4 = inputWin->init();
76 if (!i4) { delete inputWin; inputWin = NULL; }
79 if (!i1 && !i2 && !i3 && !i4)
81 Log::getInstance()->log("InputMan", Log::CRIT, "InputMan could not init any input module");
89 bool InputMan::start()
91 Log::getInstance()->log("InputMan", Log::DEBUG, "Start");
95 #ifdef VOMP_PLATFORM_RASPBERRY
98 i1 = inputLinux->start();
104 i3 = inputUDP->start();
110 void InputMan::stop()
112 Log::getInstance()->log("InputMan", Log::DEBUG, "Stop called");
114 #ifdef VOMP_PLATFORM_RASPBERRY
115 if (inputLinux) inputLinux->stop();
117 if (inputUDP) inputUDP->stop();
120 void InputMan::shutdown()
122 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start");
124 #ifdef VOMP_PLATFORM_RASPBERRY
128 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - Linux");
130 inputLinux->shutdown();
137 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - CEC");
138 inputCEC->shutdown();
147 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - UDP");
149 inputUDP->shutdown();
157 bool InputMan::mayHaveFewButtons()
159 // 052 returned true if remotelinux was in effect - linux or CEC. What was it for?
161 if (inputLinux || inputCEC) return true;
165 bool InputMan::handlesVolume()
167 #ifdef VOMP_PLATFORM_RASPBERRY
168 if (!inputCEC) return false;
169 return inputCEC->handlesVolume();
175 void InputMan::volumeUp()
177 #ifdef VOMP_PLATFORM_RASPBERRY
178 if (inputCEC) inputCEC->volumeUp();
182 void InputMan::volumeDown()
184 #ifdef VOMP_PLATFORM_RASPBERRY
185 if (inputCEC) inputCEC->volumeDown();
189 void InputMan::volumeMute()
191 #ifdef VOMP_PLATFORM_RASPBERRY
192 if (inputCEC) inputCEC->volumeMute();
196 void InputMan::changePowerState(bool powerOn)
198 #ifdef VOMP_PLATFORM_RASPBERRY
199 if (inputCEC) inputCEC->changePowerState(powerOn);
203 bool InputMan::addOptionsToPanes(int panenumber, Options* options, WOptionPane* pane)
205 #ifdef VOMP_PLATFORM_RASPBERRY
206 if (inputLinux) inputLinux->addOptionsToPanes(panenumber, options, pane);
207 if (inputCEC) inputCEC->addOptionsToPanes(panenumber, options, pane);
210 return true; // FIXME
213 bool InputMan::addOptionPagesToWTB(WTabBar *wtb)
215 WRemoteConfig* wrc = new WRemoteConfig();
216 wtb->addTab(tr("Remote Control"), wrc);
218 return true; // FIXME
221 bool InputMan::loadOptionsFromServer(VDR* vdr)
223 #ifdef VOMP_PLATFORM_RASPBERRY
224 if (inputLinux) inputLinux->loadOptionsFromServer(vdr);
225 if (inputCEC) inputCEC->loadOptionsFromServer(vdr);
228 return true; // FIXME
231 bool InputMan::saveOptionstoServer()
233 #ifdef VOMP_PLATFORM_RASPBERRY
234 if (inputLinux) inputLinux->saveOptionstoServer();
235 if (inputCEC) inputCEC->saveOptionstoServer();
237 return true; // FIXME
240 const char* InputMan::getVompKeyName(UCHAR number)
244 case Input::VOLUMEUP:
245 return tr("Volume Up");
246 case Input::VOLUMEDOWN:
247 return tr("Volume Down");
248 case Input::CHANNELUP:
249 return tr("Channel up");
250 case Input::CHANNELDOWN:
251 return tr("Channel down");
293 return tr("Reverse");
297 return tr("Forward");
304 case Input::SKIPBACK:
305 return tr("Skip back");
306 case Input::SKIPFORWARD:
307 return tr("Skip forward");
311 return tr("Fullscreen");
318 case Input::PICTURES:
319 return tr("Pictures");
330 case Input::PREVCHANNEL:
331 return tr("Previous Channel");
336 case Input::PLAYPAUSE:
337 return tr("Play/Pause");
344 std::string InputMan::getHardCodedHardwareKeyNamesForVompKey(UCHAR vompKey)
346 // Go through each active Input class and get the hardware key name for vompKey
348 // which doesn't make any sense
350 std::string keyNames;
352 #ifdef VOMP_PLATFORM_RASPBERRY
355 std::string k = inputLinux->getHardCodedHardwareKeyNamesForVompKey(vompKey);
356 if (k.size()) keyNames += k;
361 std::string k = inputCEC->getHardCodedHardwareKeyNamesForVompKey(vompKey);
362 if (k.size()) { keyNames += ", "; keyNames += k; }
368 std::string k = inputUDP->getHardCodedHardwareKeyNamesForVompKey(vompKey);
369 if (k.size()) { keyNames += ", "; keyNames += k; }
375 std::string InputMan::getAllHardwareKeyNamesAssignedToVompKey(UCHAR vompKey)
377 std::string keyNames;
379 #ifdef VOMP_PLATFORM_RASPBERRY
382 std::string k = inputLinux->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
383 if (k.size()) keyNames += k;
388 std::string k = inputCEC->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
389 if (k.size()) { keyNames += ", "; keyNames += k; }
395 std::string k = inputUDP->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
396 if (k.size()) { keyNames += ", "; keyNames += k; }
402 void InputMan::ResetToDefault()
404 #ifdef VOMP_PLATFORM_RASPBERRY
406 if (inputLinux) inputLinux->ResetToDefault();
408 if (inputCEC) inputCEC->ResetToDefault();
412 if (inputUDP) inputUDP->ResetToDefault();
415 void InputMan::EnterLearningMode(UCHAR vompKey)
417 #ifdef VOMP_PLATFORM_RASPBERRY
418 if (inputLinux) inputLinux->EnterLearningMode(vompKey);
420 // if (inputCEC) inputCEC->EnterLearningMode(); FIXME - is there any such thing?
424 void InputMan::cancelLearnMode()
426 #ifdef VOMP_PLATFORM_RASPBERRY
427 if (inputLinux) inputLinux->cancelLearnMode();
428 if (inputCEC) inputCEC->cancelLearnMode();
430 if (inputUDP) inputUDP->cancelLearnMode();