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"
28 #include "inputlirc.h"
37 InputMan* InputMan::instance = NULL;
49 InputMan* InputMan::getInstance()
59 #ifdef VOMP_PLATFORM_RASPBERRY
60 inputLinux = new InputLinux();
61 ret = inputLinux->init();
65 { delete inputLinux; inputLinux = NULL; }
67 // FIXME enable modules by new config system NCONFIG
69 // inputCEC = new InputCEC();
70 // ret = inputCEC->init();
74 // { delete inputCEC; inputCEC = NULL; }
77 inputUDP = new InputUDP();
78 ret = inputUDP->init();
82 { delete inputUDP; inputUDP = NULL; }
84 inputLirc = new InputLIRC();
85 ret = inputLirc->init();
89 { delete inputLirc; inputLirc = NULL; }
92 inputWin = new InputWin();
93 ret = inputWin->init();
97 { delete inputWin; inputWin = NULL; }
102 Log::getInstance()->log("InputMan", Log::CRIT, "InputMan could not init any input module");
110 bool InputMan::start()
112 Log::getInstance()->log("InputMan", Log::DEBUG, "Start");
116 #ifdef VOMP_PLATFORM_RASPBERRY
117 if (inputLinux && inputLinux->start()) oneOK = true;
120 if (inputUDP && inputUDP->start()) oneOK = true;
125 USHORT lircPort = 8765;
126 // Override lircIP in inputlirc.conf2
127 #include "inputlirc.conf2"
128 if (inputLirc && inputLirc->start(lircIP, lircPort)) oneOK = true;
132 Log::getInstance()->log("InputMan", Log::CRIT, "InputMan could not start any input module");
137 void InputMan::stop()
139 Log::getInstance()->log("InputMan", Log::DEBUG, "Stop called");
141 #ifdef VOMP_PLATFORM_RASPBERRY
142 if (inputLinux) inputLinux->stop();
144 if (inputUDP) inputUDP->stop();
145 if (inputLirc) inputLirc->stop();
148 void InputMan::shutdown()
150 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start");
152 #ifdef VOMP_PLATFORM_RASPBERRY
156 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - Linux");
158 inputLinux->shutdown();
165 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - CEC");
166 inputCEC->shutdown();
175 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - UDP");
177 inputUDP->shutdown();
184 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - LIRC");
186 inputLirc->shutdown();
194 bool InputMan::mayHaveFewButtons()
196 // 052 returned true if remotelinux was in effect - linux or CEC. What was it for?
198 if (inputLinux || inputCEC) return true;
202 bool InputMan::handlesVolume()
204 #ifdef VOMP_PLATFORM_RASPBERRY
205 if (!inputCEC) return false;
206 return inputCEC->handlesVolume();
212 void InputMan::volumeUp()
214 #ifdef VOMP_PLATFORM_RASPBERRY
215 if (inputCEC) inputCEC->volumeUp();
219 void InputMan::volumeDown()
221 #ifdef VOMP_PLATFORM_RASPBERRY
222 if (inputCEC) inputCEC->volumeDown();
226 void InputMan::volumeMute()
228 #ifdef VOMP_PLATFORM_RASPBERRY
229 if (inputCEC) inputCEC->volumeMute();
233 void InputMan::changePowerState(bool powerOn)
235 #ifdef VOMP_PLATFORM_RASPBERRY
236 if (inputCEC) inputCEC->changePowerState(powerOn);
240 bool InputMan::addOptionsToPanes(int panenumber, Options* options, WOptionPane* pane)
242 #ifdef VOMP_PLATFORM_RASPBERRY
243 if (inputLinux) inputLinux->addOptionsToPanes(panenumber, options, pane);
244 if (inputCEC) inputCEC->addOptionsToPanes(panenumber, options, pane);
247 return true; // FIXME
250 bool InputMan::addOptionPagesToWTB(WTabBar *wtb)
252 WRemoteConfig* wrc = new WRemoteConfig();
253 wtb->addTab(tr("Remote Control"), wrc);
255 return true; // FIXME
258 bool InputMan::loadOptionsFromServer(VDR* vdr)
260 #ifdef VOMP_PLATFORM_RASPBERRY
261 if (inputLinux) inputLinux->loadOptionsFromServer(vdr);
262 if (inputCEC) inputCEC->loadOptionsFromServer(vdr);
265 return true; // FIXME
268 bool InputMan::saveOptionstoServer()
270 #ifdef VOMP_PLATFORM_RASPBERRY
271 if (inputLinux) inputLinux->saveOptionstoServer();
272 if (inputCEC) inputCEC->saveOptionstoServer();
274 return true; // FIXME
277 const char* InputMan::getVompKeyName(UCHAR number)
281 case Input::VOLUMEUP:
282 return tr("Volume Up");
283 case Input::VOLUMEDOWN:
284 return tr("Volume Down");
285 case Input::CHANNELUP:
286 return tr("Channel up");
287 case Input::CHANNELDOWN:
288 return tr("Channel down");
330 return tr("Reverse");
334 return tr("Forward");
341 case Input::SKIPBACK:
342 return tr("Skip back");
343 case Input::SKIPFORWARD:
344 return tr("Skip forward");
348 return tr("Fullscreen");
355 case Input::PICTURES:
356 return tr("Pictures");
367 case Input::PREVCHANNEL:
368 return tr("Previous Channel");
373 case Input::PLAYPAUSE:
374 return tr("Play/Pause");
381 std::string InputMan::getHardCodedHardwareKeyNamesForVompKey(UCHAR vompKey)
383 // Go through each active Input class and get the hardware key name for vompKey
385 // which doesn't make any sense
387 std::string keyNames;
389 #ifdef VOMP_PLATFORM_RASPBERRY
392 std::string k = inputLinux->getHardCodedHardwareKeyNamesForVompKey(vompKey);
393 if (k.size()) keyNames += k;
398 std::string k = inputCEC->getHardCodedHardwareKeyNamesForVompKey(vompKey);
399 if (k.size()) { keyNames += ", "; keyNames += k; }
405 std::string k = inputUDP->getHardCodedHardwareKeyNamesForVompKey(vompKey);
406 if (k.size()) { keyNames += ", "; keyNames += k; }
412 std::string InputMan::getAllHardwareKeyNamesAssignedToVompKey(UCHAR vompKey)
414 std::string keyNames;
416 #ifdef VOMP_PLATFORM_RASPBERRY
419 std::string k = inputLinux->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
420 if (k.size()) keyNames += k;
425 std::string k = inputCEC->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
426 if (k.size()) { keyNames += ", "; keyNames += k; }
432 std::string k = inputUDP->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
433 if (k.size()) { keyNames += ", "; keyNames += k; }
439 void InputMan::ResetToDefault()
441 #ifdef VOMP_PLATFORM_RASPBERRY
443 if (inputLinux) inputLinux->ResetToDefault();
445 if (inputCEC) inputCEC->ResetToDefault();
449 if (inputUDP) inputUDP->ResetToDefault();
452 void InputMan::EnterLearningMode(UCHAR vompKey)
454 #ifdef VOMP_PLATFORM_RASPBERRY
455 if (inputLinux) inputLinux->EnterLearningMode(vompKey);
457 // if (inputCEC) inputCEC->EnterLearningMode(); FIXME - is there any such thing?
461 void InputMan::cancelLearnMode()
463 #ifdef VOMP_PLATFORM_RASPBERRY
464 if (inputLinux) inputLinux->cancelLearnMode();
465 if (inputCEC) inputCEC->cancelLearnMode();
467 if (inputUDP) inputUDP->cancelLearnMode();