2 Copyright 2007-2020 Chris Tallon, 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/>.
29 #include "wremoteconfig.h"
33 WRemoteConfig::WRemoteConfig()
35 remote = InputMan::getInstance();
39 sl.setShowSelOption(false);
40 sl.setPosition(10, 30);
45 WRemoteConfig::~WRemoteConfig()
49 void WRemoteConfig::initSelectList(bool startup)
51 InputMan* inputMan = InputMan::getInstance();
58 selection = sl.getCurrentOption();
59 top = sl.getTopOption();
67 for (UINT i = 0; i < 256; i++)
69 Log::getInstance()->log("WRemoteConfig", Log::DEBUG, "%u", i);
70 const char* vompKeyName = InputMan::getVompKeyName(static_cast<UCHAR>(i));
71 if (vompKeyName != NULL)
77 Log::getInstance()->log("WRemoteConfig", Log::DEBUG, "A");
78 line += inputMan->getHardCodedHardwareKeyNamesForVompKey(static_cast<UCHAR>(i));
80 Log::getInstance()->log("WRemoteConfig", Log::DEBUG, "B");
81 line += inputMan->getAllHardwareKeyNamesAssignedToVompKey(static_cast<UCHAR>(i));
82 Log::getInstance()->log("WRemoteConfig", Log::DEBUG, "C");
84 sl.addOption(line.c_str(), i, 0);
90 sl.hintSetCurrent(selection);
95 void WRemoteConfig::setSize(UINT w, UINT h)
98 sl.setSize(area.w - 20, area.h - 70);
101 void WRemoteConfig::draw()
105 drawText(tr("Command"), 15, 4, DrawStyle::LIGHTTEXT);
106 drawText(tr("Hard wired"), 165, 4, DrawStyle::LIGHTTEXT);
107 drawText(tr("User assignable"), 315, 4, DrawStyle::LIGHTTEXT);
111 drawText(tr("Learning! Press any hardwired key to exit."), 15, area.h - 30, DrawStyle::SELECTHIGHLIGHT);
115 drawText(tr("Press [ok] for learning or MENU to reset to defaults."), 15, area.h - 30, DrawStyle::LIGHTTEXT);
119 bool WRemoteConfig::mouseLBDOWN(int x, int y)
121 if (sl.mouseLBDOWN(x,y))
123 BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press
129 bool WRemoteConfig::mouseMove(int x, int y)
131 if (sl.mouseMove(x,y))
133 sl.setShowSelOption(true);
140 void WRemoteConfig::processMessage(Message* m)
142 Log::getInstance()->log("VRecordingList", Log::DEBUG, "Got message value %lu", m->message);
144 if (m->message == Message::MOUSE_MOVE)
146 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
148 sl.setShowSelOption(true);
150 viewman->updateView(this);
153 else if (m->message == Message::MOUSE_LBDOWN)
155 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
157 ViewMan::getInstance()->handleCommand(Input::OK); //simulate OK press
161 //check if press is outside this view! then simulate cancel
162 int x=(m->parameter>>16)-getScreenX();
163 int y=(m->parameter&0xFFFF)-getScreenY();
164 if (x<0 || y <0 || x>getWidth() || y>getHeight())
166 ViewMan::getInstance()->handleCommand(Input::BACK); //simulate cancel press
174 void WRemoteConfig::doSave()
176 Message* m = new Message();
177 m->message = Message::CHANGED_REMOTECONTROL;
180 //Command::getInstance()->postMessage(m);
185 int WRemoteConfig::handleCommand(int command)
190 if (command == Input::NA_LEARN)
192 initSelectList(false);
200 if (sl.getCurrentOption() != 0)
207 sl.setShowSelOption(false);
209 return 4; // return control to vopts
217 sl.setShowSelOption(true);
225 case Input::SKIPBACK:
230 case Input::SKIPFORWARD:
238 // remote->EnterLearningMode(sl.getCurrentOptionData()); FIXME
247 // Instead of returning 4 here which would delete this view
248 // before the doSave message is processed, let the message queue
249 // do the doSave then this close message. That will make the options menu
250 // disappear before this view
252 Message* m = new Message();
253 m->message = Message::CLOSE_ME;
256 //Command::getInstance()->postMessage(m);
262 // remote->ResetToDefault(); FIXME
263 initSelectList(false);