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"
34 InputMan* InputMan::instance = NULL;
46 InputMan* InputMan::getInstance()
53 bool i1{}, i2{}, i3{}, i4{};
55 #ifdef VOMP_PLATFORM_RASPBERRY
56 inputLinux = new InputLinux();
57 i1 = inputLinux->init();
58 if (!i1) { delete inputLinux; inputLinux = NULL; }
60 inputCEC = new InputCEC();
61 i2 = inputCEC->init();
62 if (!i2) { delete inputCEC; inputCEC = NULL; }
65 inputUDP = new InputUDP();
66 i3 = inputUDP->init();
67 if (!i3) { delete inputUDP; inputUDP = NULL; }
70 inputWin = new InputWin();
71 i4 = inputWin->init();
72 if (!i4) { delete inputWin; inputWin = NULL; }
75 if (!i1 && !i2 && !i3 && !i4)
77 Log::getInstance()->log("InputMan", Log::CRIT, "InputMan could not init any input module");
85 bool InputMan::start()
87 Log::getInstance()->log("InputMan", Log::DEBUG, "Start");
91 #ifdef VOMP_PLATFORM_RASPBERRY
94 i1 = inputLinux->start();
100 i3 = inputUDP->start();
106 void InputMan::stop()
108 Log::getInstance()->log("InputMan", Log::DEBUG, "Stop called");
110 #ifdef VOMP_PLATFORM_RASPBERRY
111 if (inputLinux) inputLinux->stop();
113 if (inputUDP) inputUDP->stop();
116 void InputMan::shutdown()
118 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start");
120 #ifdef VOMP_PLATFORM_RASPBERRY
124 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - Linux");
126 inputLinux->shutdown();
133 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - CEC");
134 inputCEC->shutdown();
143 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - UDP");
145 inputUDP->shutdown();
153 bool InputMan::mayHaveFewButtons()
155 // 052 returned true if remotelinux was in effect - linux or CEC. What was it for?
157 if (inputLinux || inputCEC) return true;
161 bool InputMan::handlesVolume()
163 #ifdef VOMP_PLATFORM_RASPBERRY
164 if (!inputCEC) return false;
165 return inputCEC->handlesVolume();
171 void InputMan::volumeUp()
173 #ifdef VOMP_PLATFORM_RASPBERRY
174 if (inputCEC) inputCEC->volumeUp();
178 void InputMan::volumeDown()
180 #ifdef VOMP_PLATFORM_RASPBERRY
181 if (inputCEC) inputCEC->volumeDown();
185 void InputMan::volumeMute()
187 #ifdef VOMP_PLATFORM_RASPBERRY
188 if (inputCEC) inputCEC->volumeMute();
192 void InputMan::changePowerState(bool powerOn)
194 #ifdef VOMP_PLATFORM_RASPBERRY
195 if (inputCEC) inputCEC->changePowerState(powerOn);
199 bool InputMan::addOptionsToPanes(int panenumber, Options* options, WOptionPane* pane)
201 #ifdef VOMP_PLATFORM_RASPBERRY
202 if (inputLinux) inputLinux->addOptionsToPanes(panenumber, options, pane);
203 if (inputCEC) inputCEC->addOptionsToPanes(panenumber, options, pane);
206 return true; // FIXME
209 bool InputMan::addOptionPagesToWTB(WTabBar *wtb)
211 WRemoteConfig* wrc = new WRemoteConfig();
212 wtb->addTab(tr("Remote Control"), wrc);
214 return true; // FIXME
217 bool InputMan::loadOptionsFromServer(VDR* vdr)
219 #ifdef VOMP_PLATFORM_RASPBERRY
220 if (inputLinux) inputLinux->loadOptionsFromServer(vdr);
221 if (inputCEC) inputCEC->loadOptionsFromServer(vdr);
224 return true; // FIXME
227 bool InputMan::saveOptionstoServer()
229 #ifdef VOMP_PLATFORM_RASPBERRY
230 if (inputLinux) inputLinux->saveOptionstoServer();
231 if (inputCEC) inputCEC->saveOptionstoServer();
233 return true; // FIXME
236 const char* InputMan::getVompKeyName(UCHAR number)
240 case Input::VOLUMEUP:
241 return tr("Volume Up");
242 case Input::VOLUMEDOWN:
243 return tr("Volume Down");
244 case Input::CHANNELUP:
245 return tr("Channel up");
246 case Input::CHANNELDOWN:
247 return tr("Channel down");
289 return tr("Reverse");
293 return tr("Forward");
300 case Input::SKIPBACK:
301 return tr("Skip back");
302 case Input::SKIPFORWARD:
303 return tr("Skip forward");
307 return tr("Fullscreen");
314 case Input::PICTURES:
315 return tr("Pictures");
326 case Input::PREVCHANNEL:
327 return tr("Previous Channel");
332 case Input::PLAYPAUSE:
333 return tr("Play/Pause");
340 std::string InputMan::getHardCodedHardwareKeyNamesForVompKey(UCHAR vompKey)
342 // Go through each active Input class and get the hardware key name for vompKey
344 // which doesn't make any sense
346 std::string keyNames;
348 #ifdef VOMP_PLATFORM_RASPBERRY
351 std::string k = inputLinux->getHardCodedHardwareKeyNamesForVompKey(vompKey);
352 if (k.size()) keyNames += k;
357 std::string k = inputCEC->getHardCodedHardwareKeyNamesForVompKey(vompKey);
358 if (k.size()) { keyNames += ", "; keyNames += k; }
364 std::string k = inputUDP->getHardCodedHardwareKeyNamesForVompKey(vompKey);
365 if (k.size()) { keyNames += ", "; keyNames += k; }
371 std::string InputMan::getAllHardwareKeyNamesAssignedToVompKey(UCHAR vompKey)
373 std::string keyNames;
375 #ifdef VOMP_PLATFORM_RASPBERRY
378 std::string k = inputLinux->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
379 if (k.size()) keyNames += k;
384 std::string k = inputCEC->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
385 if (k.size()) { keyNames += ", "; keyNames += k; }
391 std::string k = inputUDP->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
392 if (k.size()) { keyNames += ", "; keyNames += k; }
398 void InputMan::ResetToDefault()
400 #ifdef VOMP_PLATFORM_RASPBERRY
402 if (inputLinux) inputLinux->ResetToDefault();
404 if (inputCEC) inputCEC->ResetToDefault();
408 if (inputUDP) inputUDP->ResetToDefault();
411 void InputMan::EnterLearningMode(UCHAR vompKey)
413 #ifdef VOMP_PLATFORM_RASPBERRY
414 if (inputLinux) inputLinux->EnterLearningMode(vompKey);
416 // if (inputCEC) inputCEC->EnterLearningMode(); FIXME - is there any such thing?
420 void InputMan::cancelLearnMode()
422 #ifdef VOMP_PLATFORM_RASPBERRY
423 if (inputLinux) inputLinux->cancelLearnMode();
424 if (inputCEC) inputCEC->cancelLearnMode();
426 if (inputUDP) inputUDP->cancelLearnMode();