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 #include "inputlinux.h"
31 InputMan* InputMan::instance = NULL;
43 InputMan* InputMan::getInstance()
50 bool i1{}, i2{}, i3{};
52 #ifdef VOMP_PLATFORM_RASPBERRY
53 inputLinux = new InputLinux();
54 i1 = inputLinux->init();
55 if (!i1) { delete inputLinux; inputLinux = NULL; }
57 inputCEC = new InputCEC();
58 i2 = inputCEC->init();
59 if (!i2) { delete inputCEC; inputCEC = NULL; }
62 inputUDP = new InputUDP();
63 i3 = inputUDP->init();
64 if (!i3) { delete inputUDP; inputUDP = NULL; }
67 if (!i1 && !i2 && !i3)
69 Log::getInstance()->log("InputMan", Log::CRIT, "InputMan could not init any input module");
77 bool InputMan::start()
79 Log::getInstance()->log("InputMan", Log::DEBUG, "Start");
85 i1 = inputLinux->start();
90 i3 = inputUDP->start();
98 if (inputLinux) inputLinux->stop();
99 if (inputUDP) inputUDP->stop();
102 void InputMan::shutdown()
104 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start");
108 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - Linux");
110 inputLinux->shutdown();
117 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - CEC");
118 inputCEC->shutdown();
125 Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - UDP");
127 inputUDP->shutdown();
135 bool InputMan::mayHaveFewButtons()
137 // 052 returned true if remotelinux was in effect - linux or CEC. What was it for?
139 if (inputLinux || inputCEC) return true;
143 bool InputMan::handlesVolume()
145 if (!inputCEC) return false;
146 return inputCEC->handlesVolume();
149 void InputMan::volumeUp()
151 if (inputCEC) inputCEC->volumeUp();
154 void InputMan::volumeDown()
156 if (inputCEC) inputCEC->volumeDown();
159 void InputMan::volumeMute()
161 if (inputCEC) inputCEC->volumeMute();
164 void InputMan::changePowerState(bool powerOn)
166 if (inputCEC) inputCEC->changePowerState(powerOn);
169 bool InputMan::addOptionsToPanes(int panenumber, Options* options, WOptionPane* pane)
171 if (inputLinux) inputLinux->addOptionsToPanes(panenumber, options, pane);
172 if (inputCEC) inputCEC->addOptionsToPanes(panenumber, options, pane);
174 return true; // FIXME
177 bool InputMan::addOptionPagesToWTB(WTabBar *wtb)
179 WRemoteConfig* wrc = new WRemoteConfig();
180 wtb->addTab(tr("Remote Control"), wrc);
182 return true; // FIXME
185 bool InputMan::loadOptionsFromServer(VDR* vdr)
187 if (inputLinux) inputLinux->loadOptionsFromServer(vdr);
188 if (inputCEC) inputCEC->loadOptionsFromServer(vdr);
190 return true; // FIXME
193 bool InputMan::saveOptionstoServer()
195 if (inputLinux) inputLinux->saveOptionstoServer();
196 if (inputCEC) inputCEC->saveOptionstoServer();
198 return true; // FIXME
201 const char* InputMan::getVompKeyName(UCHAR number)
205 case Input::VOLUMEUP:
206 return tr("Volume Up");
207 case Input::VOLUMEDOWN:
208 return tr("Volume Down");
209 case Input::CHANNELUP:
210 return tr("Channel up");
211 case Input::CHANNELDOWN:
212 return tr("Channel down");
254 return tr("Reverse");
258 return tr("Forward");
265 case Input::SKIPBACK:
266 return tr("Skip back");
267 case Input::SKIPFORWARD:
268 return tr("Skip forward");
272 return tr("Fullscreen");
279 case Input::PICTURES:
280 return tr("Pictures");
291 case Input::PREVCHANNEL:
292 return tr("Previous Channel");
297 case Input::PLAYPAUSE:
298 return tr("Play/Pause");
305 std::string InputMan::getHardCodedHardwareKeyNamesForVompKey(UCHAR vompKey)
307 // Go through each active Input class and get the hardware key name for vompKey
309 // which doesn't make any sense
311 std::string keyNames;
315 std::string k = inputLinux->getHardCodedHardwareKeyNamesForVompKey(vompKey);
316 if (k.size()) keyNames += k;
321 std::string k = inputCEC->getHardCodedHardwareKeyNamesForVompKey(vompKey);
322 if (k.size()) { keyNames += ", "; keyNames += k; }
327 std::string k = inputUDP->getHardCodedHardwareKeyNamesForVompKey(vompKey);
328 if (k.size()) { keyNames += ", "; keyNames += k; }
334 std::string InputMan::getAllHardwareKeyNamesAssignedToVompKey(UCHAR vompKey)
336 std::string keyNames;
340 std::string k = inputLinux->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
341 if (k.size()) keyNames += k;
346 std::string k = inputCEC->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
347 if (k.size()) { keyNames += ", "; keyNames += k; }
352 std::string k = inputUDP->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
353 if (k.size()) { keyNames += ", "; keyNames += k; }
359 void InputMan::ResetToDefault()
361 if (inputLinux) inputLinux->ResetToDefault();
363 if (inputCEC) inputCEC->ResetToDefault();
365 if (inputUDP) inputUDP->ResetToDefault();
368 void InputMan::EnterLearningMode(UCHAR vompKey)
370 if (inputLinux) inputLinux->EnterLearningMode(vompKey);
372 // if (inputCEC) inputCEC->EnterLearningMode(); FIXME - is there any such thing?
375 void InputMan::cancelLearnMode()
377 if (inputLinux) inputLinux->cancelLearnMode();
378 if (inputCEC) inputCEC->cancelLearnMode();
379 if (inputUDP) inputUDP->cancelLearnMode();