From 2a26cd8a9ed01e18aa5760eb8471d6412eb0ad4d Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Fri, 5 Aug 2005 23:57:05 +0000 Subject: [PATCH] Options view files added, new remote type supported --- Makefile | 4 +- command.cc | 50 ++++++++-- led.cc | 2 + led.h | 2 + player.cc | 2 + remote.cc | 22 ++++- remote.h | 49 ++++++++-- vchannellist.cc | 131 +++++++++++++------------ vconnect.cc | 4 +- vlivebanner.cc | 2 + voptions.cc | 244 ++++++++++++++++++++++++++++++++++++++++++++++ voptions.h | 52 ++++++++++ vquestion.cc | 62 ++++++------ vradiolive.cc | 2 + vrecordinglist.cc | 149 ++++++++++++++-------------- vrecordingmenu.cc | 162 +++++++++++++++--------------- vserverselect.cc | 47 +++++---- vvideolive.cc | 2 + vvolume.cc | 6 +- vwelcome.cc | 131 +++++++++++++++---------- vwelcome.h | 2 + wjpeg.cc | 2 - woptionbox.cc | 110 +++++++++++++++++++++ woptionbox.h | 51 ++++++++++ wsymbol.cc | 82 +++++++++++++++- wsymbol.h | 4 +- 26 files changed, 1023 insertions(+), 353 deletions(-) create mode 100644 voptions.cc create mode 100644 voptions.h create mode 100644 woptionbox.cc create mode 100644 woptionbox.h diff --git a/Makefile b/Makefile index 1ccbb7d..cef5d10 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,8 @@ OBJECTS = main.o command.o log.o remote.o led.o mtd.o video.o audio.o tcp.o dire list.o queue.o node.o recording.o channel.o message.o playerradio.o messagequeue.o \ view.o vinfo.o vwallpaper.o vvolume.o vrecordinglist.o vlivebanner.o vmute.o \ vrecordingmenu.o vquestion.o vchannellist.o vwelcome.o vvideolive.o vvideorec.o vradiolive.o \ - vchannelselect.o vserverselect.o colour.o vconnect.o \ - wselectlist.o wjpeg.o wsymbol.o wbutton.o \ + vchannelselect.o vserverselect.o colour.o vconnect.o voptions.o \ + wselectlist.o wjpeg.o wsymbol.o wbutton.o woptionbox.o \ fonts/helvB24.o fonts/helvB18.o .PHONY: clean fresh all install strip diff --git a/command.cc b/command.cc index 06ae398..22cf675 100644 --- a/command.cc +++ b/command.cc @@ -123,9 +123,9 @@ void Command::run() while(irun) { button = remote->getButtonPress(2); // FIXME why is this set to 2 and not 0? so it can quit - if ((button == Remote::NONE) || (button == Remote::UNKNOWN)) continue; + if ((button == Remote::NA_NONE) || (button == Remote::NA_UNKNOWN)) continue; - if (button != Remote::SIGNAL) handleCommand(button); + if (button != Remote::NA_SIGNAL) handleCommand(button); processMessageQueue(); } } @@ -170,8 +170,10 @@ void Command::handleCommand(int button) switch(button) { - case Remote::LEFT: - case Remote::RIGHT: + case Remote::DF_LEFT: + case Remote::DF_RIGHT: + case Remote::VOLUMEUP: + case Remote::VOLUMEDOWN: { VVolume* v = new VVolume(); v->handleCommand(button); // this will draw+show @@ -298,10 +300,6 @@ void Command::doJustConnected(VConnect* vconnect) } } - // Save power state = on - - vdr->configSave("General", "Last Power State", "On"); - // Go S-Video if config says so @@ -325,9 +323,43 @@ void Command::doJustConnected(VConnect* vconnect) logger->log("Command", Log::INFO, "Config TV/S-Video not found"); } - // s video done + // Set remote type + + char* remoteType = vdr->configLoad("General", "Remote type"); + + if (remoteType) + { + if (!strcasecmp(remoteType, "New")) + { + logger->log("Command", Log::INFO, "Switching to New remote type"); + remote->setRemoteType(Remote::NEWREMOTE); + } + else + { + logger->log("Command", Log::INFO, "Switching to Old remote type"); + remote->setRemoteType(Remote::OLDREMOTE); + } + } + else + { + logger->log("Command", Log::INFO, "Config General/Remote type not found"); + remote->setRemoteType(Remote::OLDREMOTE); + } + + // Save power state = on + + vdr->configSave("General", "Last Power State", "On"); + + // config done VWelcome* vw = new VWelcome(); viewman->add(vw); viewman->redrawAll(); + +/* + handleCommand(Remote::DOWN); + handleCommand(Remote::DOWN); + handleCommand(Remote::DOWN); + handleCommand(Remote::OK); +*/ } diff --git a/led.cc b/led.cc index 8f49364..a4bffbf 100644 --- a/led.cc +++ b/led.cc @@ -61,6 +61,7 @@ int Led::on() if (!initted) return 0; int result = ioctl(device, IR_SET_LED, 0); + Log::getInstance()->log("LED", Log::DEBUG, "led on %i %i", device, result); if (result >= 0) return 1; else return 0; } @@ -70,6 +71,7 @@ int Led::off() if (!initted) return 0; int result = ioctl(device, IR_SET_LED, 1); + Log::getInstance()->log("LED", Log::DEBUG, "led off %i %i", device, result); if (result >= 0) return 1; else return 0; } diff --git a/led.h b/led.h index 4b67e0b..67cf380 100644 --- a/led.h +++ b/led.h @@ -26,6 +26,8 @@ #include "stb.h" +#include "log.h" // temp while fix led on bug! + class Led { public: diff --git a/player.cc b/player.cc index 4cbef18..27bb9b7 100644 --- a/player.cc +++ b/player.cc @@ -215,11 +215,13 @@ void Player::stop() } playing = 0; + paused = 0; threadStop(); video->stop(); video->blank(); audio->stop(); + audio->unPause(); vfeed.stop(); afeed.stop(); video->reset(); diff --git a/remote.cc b/remote.cc index c589ab1..a0ed018 100644 --- a/remote.cc +++ b/remote.cc @@ -30,6 +30,7 @@ Remote::Remote() device = 0; tv.tv_sec = 0; tv.tv_usec = 0; + remoteType = OLDREMOTE; } Remote::~Remote() @@ -72,6 +73,12 @@ int Remote::getDevice() return device; } +void Remote::setRemoteType(UCHAR newType) +{ + if ((newType != OLDREMOTE) && (newType != NEWREMOTE)) return; + remoteType = newType; +} + UCHAR Remote::getButtonPress(int waitType) { /* how = 0 - block @@ -117,15 +124,24 @@ UCHAR Remote::getButtonPress(int waitType) // 0 = nothing happened // 1 = data arrived (actually num of descriptors that changed) // other value = signal or error - if (retval == 0) return NONE; - if (retval == -1) return SIGNAL; + if (retval == 0) return NA_NONE; + if (retval == -1) return NA_SIGNAL; int count = read(device, &input, 4); if (count == 4) { input = (0X00FF0000 & input) >> 16; Log::getInstance()->log("Remote", Log::DEBUG, "Button %i", input); + + if (remoteType == OLDREMOTE) + { + if (input == VOLUMEDOWN) return DF_LEFT; + if (input == VOLUMEUP) return DF_RIGHT; + if (input == CHANNELUP) return DF_UP; + if (input == CHANNELDOWN) return DF_DOWN; + } + return (UCHAR) input; } - return UNKNOWN; + return NA_UNKNOWN; } diff --git a/remote.h b/remote.h index 440718c..799f62f 100644 --- a/remote.h +++ b/remote.h @@ -38,8 +38,25 @@ class Remote int init(char *devName); int shutdown(); int getDevice(); + void setRemoteType(UCHAR type); UCHAR getButtonPress(int how); + // Not buttons + const static UCHAR NA_NONE = 98; + const static UCHAR NA_UNKNOWN = 99; + const static UCHAR NA_SIGNAL = 100; + const static UCHAR DF_UP = 94; + const static UCHAR DF_DOWN = 95; + const static UCHAR DF_LEFT = 96; + const static UCHAR DF_RIGHT = 97; + + // Problem common buttons + const static UCHAR VOLUMEUP = 16; + const static UCHAR VOLUMEDOWN = 17; + const static UCHAR CHANNELUP = 32; + const static UCHAR CHANNELDOWN = 33; + + // Common buttons const static UCHAR ZERO = 0; const static UCHAR ONE = 1; const static UCHAR TWO = 2; @@ -58,13 +75,8 @@ class Remote const static UCHAR GREEN = 46; const static UCHAR YELLOW = 56; const static UCHAR BLUE = 41; - const static UCHAR LEFT = 17; - const static UCHAR RIGHT = 16; - const static UCHAR UP = 32; - const static UCHAR DOWN = 33; const static UCHAR MUTE = 15; - const static UCHAR OSD = 12; - const static UCHAR FULL = 60; + const static UCHAR RADIO = 12; // The unlabelled button on old const static UCHAR REVERSE = 50; const static UCHAR PLAY = 53; const static UCHAR FORWARD = 52; @@ -74,15 +86,34 @@ class Remote const static UCHAR SKIPBACK = 36; const static UCHAR SKIPFORWARD = 30; const static UCHAR OK = 37; - const static UCHAR NONE = 98; - const static UCHAR UNKNOWN = 99; - const static UCHAR SIGNAL = 100; + + // Old remote only + const static UCHAR FULL = 60; + + // New remote only + const static UCHAR TV = 28; + const static UCHAR VIDEOS = 24; + const static UCHAR MUSIC = 25; + const static UCHAR PICTURES = 26; + const static UCHAR GUIDE = 27; + const static UCHAR UP = 20; + const static UCHAR DOWN = 21; + const static UCHAR LEFT = 22; + const static UCHAR RIGHT = 23; + const static UCHAR PREVCHANNEL = 18; + const static UCHAR STAR = 10; + const static UCHAR HASH = 14; + + // Remote types + const static UCHAR OLDREMOTE = 1; + const static UCHAR NEWREMOTE = 2; private: static Remote* instance; int initted; int device; struct timeval tv; + UCHAR remoteType; }; #endif diff --git a/vchannellist.cc b/vchannellist.cc index 17a98d2..1dcdeab 100644 --- a/vchannellist.cc +++ b/vchannellist.cc @@ -134,84 +134,89 @@ void VChannelList::doShowingBar() int VChannelList::handleCommand(int command) { - if (command == Remote::UP) + switch(command) { - sl.up(); - sl.draw(); - - doShowingBar(); - show(); - return 2; - } - else if (command == Remote::DOWN) - { - sl.down(); - sl.draw(); + case Remote::DF_UP: + case Remote::UP: + { + sl.up(); + sl.draw(); - doShowingBar(); - show(); - return 2; - } - else if (command == Remote::SKIPBACK) - { - sl.pageUp(); - sl.draw(); + doShowingBar(); + show(); + return 2; + } + case Remote::DF_DOWN: + case Remote::DOWN: + { + sl.down(); + sl.draw(); - doShowingBar(); - show(); - return 2; - } - else if (command == Remote::SKIPFORWARD) - { - sl.pageDown(); - sl.draw(); + doShowingBar(); + show(); + return 2; + } + case Remote::SKIPBACK: + { + sl.pageUp(); + sl.draw(); - doShowingBar(); - show(); - return 2; - } - else if (command == Remote::OK) - { - Channel* chan = NULL; - if (chanList) + doShowingBar(); + show(); + return 2; + } + case Remote::SKIPFORWARD: { - int currentOption = sl.getCurrentOption(); - chanList->reset(); + sl.pageDown(); + sl.draw(); - while((chan = (Channel*)chanList->getCurrent())) + doShowingBar(); + show(); + return 2; + } + case Remote::OK: + { + Channel* chan = NULL; + if (chanList) { - if (currentOption == chan->index) break; - chanList->next(); + int currentOption = sl.getCurrentOption(); + chanList->reset(); + + while((chan = (Channel*)chanList->getCurrent())) + { + if (currentOption == chan->index) break; + chanList->next(); + } } - } - if (chan == NULL) return 2; + if (chan == NULL) return 2; - View* v = NULL; + View* v = NULL; -// stop radio -// if (chan->type == VDR::RADIO) return 2; + // stop radio + // if (chan->type == VDR::RADIO) return 2; - if (chan->type == VDR::VIDEO) - { - v = new VVideoLive(chanList); - ((VVideoLive*)v)->setChannel(chan->number); + if (chan->type == VDR::VIDEO) + { + v = new VVideoLive(chanList); + ((VVideoLive*)v)->setChannel(chan->number); + } + else if (chan->type == VDR::RADIO) + { + v = new VRadioLive(chanList); + ((VRadioLive*)v)->setChannel(chan->number); + } + + ViewMan::getInstance()->addNoLock(v); + v->draw(); + v->show(); + + return 2; } - else if (chan->type == VDR::RADIO) + case Remote::BACK: { - v = new VRadioLive(chanList); - ((VRadioLive*)v)->setChannel(chan->number); + return 4; } - - ViewMan::getInstance()->addNoLock(v); - v->draw(); - v->show(); - - return 2; - } - else if (command == Remote::BACK) - { - return 4; } // stop command getting to any more views return 1; diff --git a/vconnect.cc b/vconnect.cc index 79abef7..0a31bf8 100644 --- a/vconnect.cc +++ b/vconnect.cc @@ -93,8 +93,7 @@ void VConnect::threadMethod() threadWaitForSignal(); } - printf("server selected %i\n", selectedServer); - + logger->log("Command", Log::NOTICE, "Connecting to server at %s", serverIPs[selectedServer]); vdr->setServerIP(serverIPs[selectedServer]); // Clear the serverIPs vector @@ -104,7 +103,6 @@ void VConnect::threadMethod() } serverIPs.clear(); - logger->log("Command", Log::NOTICE, "Connecting to server at %s", serverIPs[selectedServer]); setMainText("\n Connecting to VDR"); draw(); show(); diff --git a/vlivebanner.cc b/vlivebanner.cc index 278e8ef..bd2db8a 100644 --- a/vlivebanner.cc +++ b/vlivebanner.cc @@ -75,6 +75,7 @@ int VLiveBanner::handleCommand(int command) { return 4; } + case Remote::DF_UP: case Remote::UP: { sl.up(); @@ -83,6 +84,7 @@ int VLiveBanner::handleCommand(int command) show(); return 2; } + case Remote::DF_DOWN: case Remote::DOWN: { sl.down(); diff --git a/voptions.cc b/voptions.cc new file mode 100644 index 0000000..9c80dde --- /dev/null +++ b/voptions.cc @@ -0,0 +1,244 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + VOMP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "voptions.h" + +VOptions::VOptions() +{ + setDimensions(190, 460); + + if (Video::getInstance()->getFormat() == Video::PAL) + { + setScreenPos(140, 170); + } + else + { + setScreenPos(130, 140); + } + + setBackgroundColour(Colour::VIEWBACKGROUND); + setTitleBarOn(1); + setTitleBarColour(Colour::TITLEBARBACKGROUND); + setTitleText("Options"); + + int fontHeight = surface->getFontHeight(); + + optionBox[0].setScreenPos(screenX + 290, screenY + 45); + optionBox[0].setDimensions(fontHeight, 150); + optionBox[0].addOption("Old"); + optionBox[0].addOption("New"); + + optionBox[1].setScreenPos(screenX + 290, screenY + 75); + optionBox[1].setDimensions(fontHeight, 150); + optionBox[1].addOption("RGB+composite"); + optionBox[1].addOption("S-Video"); + + optionBox[2].setScreenPos(screenX + 290, screenY + 105); + optionBox[2].setDimensions(fontHeight, 150); + optionBox[2].addOption("On"); + optionBox[2].addOption("Off"); + optionBox[2].addOption("Last state"); + + + char* config; + vdr = VDR::getInstance(); + + + config = vdr->configLoad("General", "Remote type"); + if (!config) + { + optionBox[0].setSelected("Old"); + } + else if (!strcasecmp(config, "New")) + { + optionBox[0].setSelected("New"); + } + else + { + optionBox[0].setSelected("Old"); + } + + + config = vdr->configLoad("TV", "S-Video"); + if (!config) + { + optionBox[1].setSelected("RGB+composite"); + } + else if (!strcasecmp(config, "Yes")) + { + optionBox[1].setSelected("S-Video"); + } + else + { + optionBox[1].setSelected("RGB+composite"); + } + + + config = vdr->configLoad("General", "Power After Boot"); + if (!config) + { + optionBox[2].setSelected("On"); + } + else if (!strcasecmp(config, "On")) // just for completeness + { + optionBox[2].setSelected("On"); + } + else if (!strcasecmp(config, "Off")) + { + optionBox[2].setSelected("Off"); + } + else if (!strcasecmp(config, "Last state")) + { + optionBox[2].setSelected("Last state"); + } + else + { + optionBox[2].setSelected("On"); + } + + + selectedOption = 0; + optionBox[0].setActive(1); +} + +VOptions::~VOptions() +{ +} + +void VOptions::draw() +{ + View::draw(); + + WSymbol ws; + Colour cl; + + drawText("Remote control type", 10, 45, Colour::LIGHTTEXT); + drawText("TV connection type", 10, 75, Colour::LIGHTTEXT); + drawText("Power state after bootup", 10, 105, Colour::LIGHTTEXT); + + drawText("Press back to exit, <, > or [ok] to change", 10, 160, Colour::LIGHTTEXT); + + for (UINT i = 0; i < numOptions; i++) + { + if (i == selectedOption) cl = Colour::SELECTHIGHLIGHT; + else cl = Colour::BUTTONBACKGROUND; + + ws.nextSymbol = WSymbol::LEFTARROW; + ws.setScreenPos(screenX + 272, screenY + 47 + (i * 30)); + ws.draw(cl); + ws.nextSymbol = WSymbol::RIGHTARROW; + ws.setScreenPos(screenX + 442, screenY + 47 + (i * 30)); + ws.draw(cl); + optionBox[i].draw(); + optionBox[i].show(); + } + +} + +int VOptions::handleCommand(int command) +{ + switch(command) + { + case Remote::DF_UP: + case Remote::UP: + { + if (selectedOption > 0) + { + optionBox[selectedOption].setActive(0); + --selectedOption; + optionBox[selectedOption].setActive(1); + draw(); + show(); + } + return 2; + } + case Remote::DF_DOWN: + case Remote::DOWN: + { + if (selectedOption < (numOptions - 1)) + { + optionBox[selectedOption].setActive(0); + ++selectedOption; + optionBox[selectedOption].setActive(1); + draw(); + show(); + } + return 2; + } + case Remote::DF_LEFT: + case Remote::LEFT: + { + optionBox[selectedOption].left(); + draw(); + show(); + return 2; + } + case Remote::DF_RIGHT: + case Remote::RIGHT: + { + optionBox[selectedOption].right(); + draw(); + show(); + return 2; + } + case Remote::BACK: + { + doSave(); + return 4; + } + case Remote::OK: + { + optionBox[selectedOption].cycle(); + draw(); + show(); + } + } + + return 1; +} + +void VOptions::doSave() +{ + char* remoteType = optionBox[0].getSelected(); + vdr->configSave("General", "Remote type", remoteType); + if (!strcmp(remoteType, "New")) + { + Remote::getInstance()->setRemoteType(Remote::NEWREMOTE); + } + else + { + Remote::getInstance()->setRemoteType(Remote::OLDREMOTE); + } + + char* tvconnection = optionBox[1].getSelected(); + if (!strcmp(tvconnection, "S-Video")) + { + vdr->configSave("TV", "S-Video", "Yes"); + Video::getInstance()->setConnection(Video::SVIDEO); + } + else + { + vdr->configSave("TV", "S-Video", "No"); + Video::getInstance()->setConnection(Video::COMPOSITERGB); + } + + char* powerState = optionBox[2].getSelected(); + vdr->configSave("General", "Power After Boot", powerState); +} diff --git a/voptions.h b/voptions.h new file mode 100644 index 0000000..2ae5c1f --- /dev/null +++ b/voptions.h @@ -0,0 +1,52 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + VOMP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef VOPTIONS_H +#define VOPTIONS_H + +#include "view.h" +#include "remote.h" +#include "viewman.h" +#include "vdr.h" +#include "colour.h" +#include "video.h" +#include "woptionbox.h" +#include "wsymbol.h" + +class VOptions : public View +{ + public: + VOptions(); + ~VOptions(); + + int handleCommand(int command); + void draw(); + + private: + void doSave(); + + const static UINT numOptions = 3; + UINT selectedOption; + WOptionBox optionBox[numOptions]; + VDR* vdr; + +}; + +#endif diff --git a/vquestion.cc b/vquestion.cc index d15a562..f0c2dab 100644 --- a/vquestion.cc +++ b/vquestion.cc @@ -73,37 +73,41 @@ void VQuestion::swap() int VQuestion::handleCommand(int command) { - if (command == Remote::LEFT) + switch(command) { - swap(); - draw(); - show(); - return 2; + case Remote::DF_LEFT: + case Remote::LEFT: + { + swap(); + draw(); + show(); + return 2; + } + case Remote::DF_RIGHT: + case Remote::RIGHT: + { + swap(); + draw(); + show(); + return 2; + } + case Remote::BACK: + { + return 4; + } + case Remote::OK: + { + if (selectedOption != YES) return 4; + + Message* m = new Message(); + m->from = this; + m->to = parent; + m->message = Message::QUESTION_YES; + ViewMan::getInstance()->postMessage(m); + + return 4; + } } - else if (command == Remote::RIGHT) - { - swap(); - draw(); - show(); - return 2; - } - else if (command == Remote::BACK) - { - return 4; - } - else if (command == Remote::OK) - { - if (selectedOption != YES) return 4; - - Message* m = new Message(); - m->from = this; - m->to = parent; - m->message = Message::QUESTION_YES; - ViewMan::getInstance()->postMessage(m); - - return 4; - } - return 1; } diff --git a/vradiolive.cc b/vradiolive.cc index 9273437..c0e57ef 100644 --- a/vradiolive.cc +++ b/vradiolive.cc @@ -54,6 +54,7 @@ int VRadioLive::handleCommand(int command) vdr->stopStreaming(); return 4; } + case Remote::DF_UP: case Remote::UP: { player->stop(); @@ -63,6 +64,7 @@ int VRadioLive::handleCommand(int command) player->play(); return 2; } + case Remote::DF_DOWN: case Remote::DOWN: { player->stop(); diff --git a/vrecordinglist.cc b/vrecordinglist.cc index 59a9135..8dd20e4 100644 --- a/vrecordinglist.cc +++ b/vrecordinglist.cc @@ -266,93 +266,98 @@ Recording* VRecordingList::getCurrentOptionRecording() int VRecordingList::handleCommand(int command) { - if (command == Remote::UP) + switch(command) { - sl.up(); - sl.draw(); - - doShowingBar(); - show(); - return 2; - } - else if (command == Remote::DOWN) - { - sl.down(); - sl.draw(); + case Remote::DF_UP: + case Remote::UP: + { + sl.up(); + sl.draw(); - doShowingBar(); - show(); - return 2; - } - else if (command == Remote::SKIPBACK) - { - sl.pageUp(); - sl.draw(); + doShowingBar(); + show(); + return 2; + } + case Remote::DF_DOWN: + case Remote::DOWN: + { + sl.down(); + sl.draw(); - doShowingBar(); - show(); - return 2; - } - else if (command == Remote::SKIPFORWARD) - { - sl.pageDown(); - sl.draw(); + doShowingBar(); + show(); + return 2; + } + case Remote::SKIPBACK: + { + sl.pageUp(); + sl.draw(); - doShowingBar(); - show(); - return 2; - } - else if (command == Remote::OK) - { - if (sl.getNumOptions() == 0) return 2; + doShowingBar(); + show(); + return 2; + } + case Remote::SKIPFORWARD: + { + sl.pageDown(); + sl.draw(); - // Check to see if it is a sub directory - Directory* curDir; - for(recDir->dirList->reset(); (curDir = (Directory*)recDir->dirList->getCurrent()); recDir->dirList->next()) + doShowingBar(); + show(); + return 2; + } + case Remote::OK: { - if (curDir->index == sl.getCurrentOption()) + if (sl.getNumOptions() == 0) return 2; + + // Check to see if it is a sub directory + Directory* curDir; + for(recDir->dirList->reset(); (curDir = (Directory*)recDir->dirList->getCurrent()); recDir->dirList->next()) { - VRecordingList* sub = new VRecordingList(); - sub->setDir(curDir); - ViewMan::getInstance()->addNoLock(sub); + if (curDir->index == sl.getCurrentOption()) + { + VRecordingList* sub = new VRecordingList(); + sub->setDir(curDir); + ViewMan::getInstance()->addNoLock(sub); - sub->draw(); - sub->show(); + sub->draw(); + sub->show(); - return 2; + return 2; + } } - } - // check to see if it's a recording - Recording* current; - for(recDir->recList->reset(); (current = (Recording*)recDir->recList->getCurrent()); recDir->recList->next()) - { - if (current->index == sl.getCurrentOption()) + // check to see if it's a recording + Recording* current; + for(recDir->recList->reset(); (current = (Recording*)recDir->recList->getCurrent()); recDir->recList->next()) { - Log::getInstance()->log("VRecordingList", Log::DEBUG, "Found the option you pointed at. %s %s", current->getProgName(), current->fileName); - - VRecordingMenu* v = new VRecordingMenu(); - v->setParent(this); - v->setRecording(current); - ViewMan::getInstance()->addNoLock(v); - v->draw(); - v->show(); - return 2; + if (current->index == sl.getCurrentOption()) + { + Log::getInstance()->log("VRecordingList", Log::DEBUG, "Found the option you pointed at. %s %s", current->getProgName(), current->fileName); + + VRecordingMenu* v = new VRecordingMenu(); + v->setParent(this); + v->setRecording(current); + ViewMan::getInstance()->addNoLock(v); + v->draw(); + v->show(); + return 2; + } } + // should not get to here + return 1; + } + case Remote::BACK: + { + return 4; + } + case Remote::PLAY: + { + if (doPlay()) return 2; + return 1; } - // should not get to here - return 1; - } - else if (command == Remote::BACK) - { - return 4; - } - else if (command == Remote::PLAY) - { - if (doPlay()) return 2; - return 1; - } + } // stop command getting to any more views return 1; } diff --git a/vrecordingmenu.cc b/vrecordingmenu.cc index 5212c2b..bdf3af7 100644 --- a/vrecordingmenu.cc +++ b/vrecordingmenu.cc @@ -71,102 +71,106 @@ void VRecordingMenu::draw() int VRecordingMenu::handleCommand(int command) { - if (command == Remote::UP) + switch(command) { - sl.up(); - sl.draw(); - show(); - return 2; - } - else if (command == Remote::DOWN) - { - sl.down(); - sl.draw(); - show(); - return 2; - } - else if (command == Remote::OK) - { - if (sl.getCurrentOption() == 0) + case Remote::DF_UP: + case Remote::UP: { - Message* m = new Message(); - m->from = this; - m->to = vRecList; - m->message = Message::PLAY_SELECTED_RECORDING; - ViewMan::getInstance()->postMessage(m); - return 4; + sl.up(); + sl.draw(); + show(); + return 2; } - - if (sl.getCurrentOption() == 1) + case Remote::DF_DOWN: + case Remote::DOWN: { - Message* m = new Message(); - m->from = this; - m->to = vRecList; - m->message = Message::RESUME_SELECTED_RECORDING; - ViewMan::getInstance()->postMessage(m); - return 4; + sl.down(); + sl.draw(); + show(); + return 2; } - - if (sl.getCurrentOption() == 2) + case Remote::OK: { - char* summary = VDR::getInstance()->getRecordingSummary(rec->fileName); - - VInfo* vi = new VInfo(); - vi->setTitleText("Programme summary"); - vi->setBorderOn(1); - vi->setExitable(); - if (summary) vi->setMainText(summary); - else vi->setMainText("Summary unavailable"); - if (Video::getInstance()->getFormat() == Video::PAL) + if (sl.getCurrentOption() == 0) { - vi->setScreenPos(120, 130); + Message* m = new Message(); + m->from = this; + m->to = vRecList; + m->message = Message::PLAY_SELECTED_RECORDING; + ViewMan::getInstance()->postMessage(m); + return 4; } - else + + if (sl.getCurrentOption() == 1) { - vi->setScreenPos(110, 90); + Message* m = new Message(); + m->from = this; + m->to = vRecList; + m->message = Message::RESUME_SELECTED_RECORDING; + ViewMan::getInstance()->postMessage(m); + return 4; } - vi->setDimensions(300, 490); - - ViewMan::getInstance()->addNoLock(vi); - vi->draw(); - vi->show(); - if (summary) delete[] summary; - - return 2; - } - else if (sl.getCurrentOption() == 3) - { - VQuestion* v = new VQuestion(); - v->setParent(this); - v->setBackgroundColour(Colour::VIEWBACKGROUND); - v->setTitleBarColour(Colour::DANGER); - v->setTitleBarOn(1); - v->setBorderOn(1); - v->setTitleText("Delete recording"); - v->setMainText("Are you sure you want to delete this recording?"); - v->setDefault(VQuestion::NO); - if (Video::getInstance()->getFormat() == Video::PAL) + if (sl.getCurrentOption() == 2) { - v->setScreenPos(230, 160); + char* summary = VDR::getInstance()->getRecordingSummary(rec->fileName); + + VInfo* vi = new VInfo(); + vi->setTitleText("Programme summary"); + vi->setBorderOn(1); + vi->setExitable(); + if (summary) vi->setMainText(summary); + else vi->setMainText("Summary unavailable"); + if (Video::getInstance()->getFormat() == Video::PAL) + { + vi->setScreenPos(120, 130); + } + else + { + vi->setScreenPos(110, 90); + } + vi->setDimensions(300, 490); + + ViewMan::getInstance()->addNoLock(vi); + vi->draw(); + vi->show(); + + if (summary) delete[] summary; + + return 2; } - else + else if (sl.getCurrentOption() == 3) { - v->setScreenPos(220, 140); + VQuestion* v = new VQuestion(); + v->setParent(this); + v->setBackgroundColour(Colour::VIEWBACKGROUND); + v->setTitleBarColour(Colour::DANGER); + v->setTitleBarOn(1); + v->setBorderOn(1); + v->setTitleText("Delete recording"); + v->setMainText("Are you sure you want to delete this recording?"); + v->setDefault(VQuestion::NO); + if (Video::getInstance()->getFormat() == Video::PAL) + { + v->setScreenPos(230, 160); + } + else + { + v->setScreenPos(220, 140); + } + v->setDimensions(180, 260); + + ViewMan::getInstance()->addNoLock(v); + v->draw(); + v->show(); + return 2; } - v->setDimensions(180, 260); - - ViewMan::getInstance()->addNoLock(v); - v->draw(); - v->show(); - return 2; + } + case Remote::BACK: + { + return 4; } } - else if (command == Remote::BACK) - { - return 4; - } - // stop command getting to any more views return 1; } diff --git a/vserverselect.cc b/vserverselect.cc index d0ae51f..9dd91a3 100644 --- a/vserverselect.cc +++ b/vserverselect.cc @@ -63,28 +63,33 @@ void VServerSelect::draw() int VServerSelect::handleCommand(int command) { - if (command == Remote::UP) + switch(command) { - sl.up(); - sl.draw(); - show(); - return 2; - } - else if (command == Remote::DOWN) - { - sl.down(); - sl.draw(); - show(); - return 2; - } - else if (command == Remote::OK) - { - Message* m = new Message(); - m->to = parent; - m->message = Message::SERVER_SELECTED; - m->parameter = sl.getCurrentOption(); - ViewMan::getInstance()->postMessage(m); - return 4; + case Remote::DF_UP: + case Remote::UP: + { + sl.up(); + sl.draw(); + show(); + return 2; + } + case Remote::DF_DOWN: + case Remote::DOWN: + { + sl.down(); + sl.draw(); + show(); + return 2; + } + case Remote::OK: + { + Message* m = new Message(); + m->to = parent; + m->message = Message::SERVER_SELECTED; + m->parameter = sl.getCurrentOption(); + ViewMan::getInstance()->postMessage(m); + return 4; + } } return 1; diff --git a/vvideolive.cc b/vvideolive.cc index d09bbba..96bb763 100644 --- a/vvideolive.cc +++ b/vvideolive.cc @@ -62,6 +62,7 @@ int VVideoLive::handleCommand(int command) vdr->stopStreaming(); return 4; } + case Remote::DF_UP: case Remote::UP: { player->stop(); @@ -72,6 +73,7 @@ int VVideoLive::handleCommand(int command) player->play(); return 2; } + case Remote::DF_DOWN: case Remote::DOWN: { player->stop(); diff --git a/vvolume.cc b/vvolume.cc index 441a7ef..0ad0825 100644 --- a/vvolume.cc +++ b/vvolume.cc @@ -70,7 +70,8 @@ int VVolume::handleCommand(int command) { switch(command) { - case Remote::LEFT: + case Remote::DF_LEFT: + case Remote::VOLUMEDOWN: { displayVolume = Audio::getInstance()->volumeDown(); draw(); @@ -78,7 +79,8 @@ int VVolume::handleCommand(int command) // handled return 2; } - case Remote::RIGHT: + case Remote::DF_RIGHT: + case Remote::VOLUMEUP: { displayVolume = Audio::getInstance()->volumeUp(); draw(); diff --git a/vwelcome.cc b/vwelcome.cc index d17e070..8881035 100644 --- a/vwelcome.cc +++ b/vwelcome.cc @@ -22,7 +22,7 @@ VWelcome::VWelcome() { - setDimensions(190, 460); + setDimensions(200, 460); if (Video::getInstance()->getFormat() == Video::PAL) { @@ -39,15 +39,16 @@ VWelcome::VWelcome() setTitleText("Welcome"); sl.setScreenPos(screenX + 20, screenY + 40); - sl.setDimensions(130, 170); + sl.setDimensions(140, 170); sl.addOption("1. Live TV", 1); sl.addOption("2. Radio", 0); sl.addOption("3. Recordings", 0); - sl.addOption("4. Stand by", 0); - sl.addOption("5. Reboot", 0); + sl.addOption("4. Options", 0); + sl.addOption("5. Stand by", 0); + sl.addOption("6. Reboot", 0); - jpeg.setScreenPos(screenX + 240, screenY + 50); + jpeg.setScreenPos(screenX + 240, screenY + 60); } VWelcome::~VWelcome() @@ -74,75 +75,91 @@ void VWelcome::draw() int VWelcome::handleCommand(int command) { - if (command == Remote::UP) + switch(command) { - sl.up(); - sl.draw(); - show(); - return 2; - } - else if (command == Remote::DOWN) - { - sl.down(); - sl.draw(); - show(); - return 2; - } - else if (command == Remote::ONE) - { - doChannelsList(); - return 2; - } - else if (command == Remote::TWO) - { - doRadioList(); - return 2; - } - else if (command == Remote::THREE) - { - doRecordingsList(); - return 2; - } - else if (command == Remote::FOUR) - { - Message* m = new Message(); - m->message = Message::STANDBY; - Command::getInstance()->postMessage(m); - return 4; - } - else if (command == Remote::FIVE) - { - Command::getInstance()->doReboot(); - } - else if (command == Remote::OK) - { - int option = sl.getCurrentOption(); - if (option == 0) + case Remote::DF_UP: + case Remote::UP: + { + sl.up(); + sl.draw(); + show(); + return 2; + } + case Remote::DF_DOWN: + case Remote::DOWN: + { + sl.down(); + sl.draw(); + show(); + return 2; + } + case Remote::ONE: { doChannelsList(); return 2; } - else if (option == 1) + case Remote::TWO: { doRadioList(); return 2; } - else if (option == 2) + case Remote::THREE: { doRecordingsList(); return 2; } - else if (option == 3) + case Remote::FOUR: + { + doOptions(); + return 2; + } + case Remote::FIVE: { Message* m = new Message(); m->message = Message::STANDBY; Command::getInstance()->postMessage(m); return 4; } - else if (option == 4) + case Remote::SIX: { Command::getInstance()->doReboot(); - return 2; + } + case Remote::OK: + { + int option = sl.getCurrentOption(); + if (option == 0) + { + doChannelsList(); + return 2; + } + else if (option == 1) + { + doRadioList(); + return 2; + } + else if (option == 2) + { + doRecordingsList(); + return 2; + } + else if (option == 3) + { + doOptions(); + return 2; + } + else if (option == 4) + { + Message* m = new Message(); + m->message = Message::STANDBY; + Command::getInstance()->postMessage(m); + return 4; + } + else if (option == 5) + { + Command::getInstance()->doReboot(); + return 2; + } + return 2; // never gets here } } @@ -225,3 +242,11 @@ void VWelcome::doRecordingsList() viewman->removeView(viewWait, 1, 1); Log::getInstance()->log("VWelcome", Log::DEBUG, "possible delay end"); } + +void VWelcome::doOptions() +{ + VOptions* voptions = new VOptions(); + ViewMan::getInstance()->addNoLock(voptions); + voptions->draw(); + voptions->show(); +} diff --git a/vwelcome.h b/vwelcome.h index a5c3b58..e8f680e 100644 --- a/vwelcome.h +++ b/vwelcome.h @@ -37,6 +37,7 @@ #include "message.h" #include "colour.h" #include "video.h" +#include "voptions.h" class VWelcome : public View { @@ -55,6 +56,7 @@ class VWelcome : public View void doChannelsList(); void doRadioList(); void doRecordingsList(); + void doOptions(); }; #endif diff --git a/wjpeg.cc b/wjpeg.cc index 6379c4e..47d6d1e 100644 --- a/wjpeg.cc +++ b/wjpeg.cc @@ -35,8 +35,6 @@ void WJpeg::draw() { Log* logger = Log::getInstance(); - logger->log("BJpeg", Log::DEBUG, "Here1"); - FILE* infile = fopen(fileName, "r"); if (infile == NULL) { diff --git a/woptionbox.cc b/woptionbox.cc new file mode 100644 index 0000000..cd2cafe --- /dev/null +++ b/woptionbox.cc @@ -0,0 +1,110 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + VOMP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "woptionbox.h" + +WOptionBox::WOptionBox() +{ + numOptions = 0; + options = NULL; + active = 0; + currentOption = 0; +} + +WOptionBox::~WOptionBox() +{ + if (!options) return; + + for(UINT i = 0; i < numOptions; i++) delete[] options[i]; + free(options); +} + +void WOptionBox::addOption(char* takeText) +{ + int length = strlen(takeText); + char* newOption = new char[length + 1]; + strcpy(newOption, takeText); + + options = (char**)realloc(options, numOptions * sizeof(char*)); + options[numOptions] = newOption; + + numOptions++; +} + +void WOptionBox::setActive(UCHAR tactive) +{ + active = tactive; +} + +void WOptionBox::draw() +{ + if (active) + { + fillColour(Colour::SELECTHIGHLIGHT); + drawText(options[currentOption], 0, 0, Colour::DARKTEXT); + } + else + { + fillColour(Colour::BUTTONBACKGROUND); + drawText(options[currentOption], 0, 0, Colour::LIGHTTEXT); + } +} + +void WOptionBox::left() +{ + if (currentOption == 0) return; + --currentOption; +} + +void WOptionBox::right() +{ + if (currentOption == (numOptions - 1)) return; + ++currentOption; +} + +void WOptionBox::cycle() +{ + if (currentOption == (numOptions - 1)) + { + currentOption = 0; + } + else + { + ++currentOption; + } +} + +void WOptionBox::setSelected(char* toSelect) +{ + for(UINT i = 0; i < numOptions; i++) + { + if (!strcmp(toSelect, options[i])) + { + currentOption = i; + return; + } + } + currentOption = 0; +} + +char* WOptionBox::getSelected() +{ + return options[currentOption]; +} diff --git a/woptionbox.h b/woptionbox.h new file mode 100644 index 0000000..25253eb --- /dev/null +++ b/woptionbox.h @@ -0,0 +1,51 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + VOMP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef WOPTIONBOX_H +#define WOPTIONBOX_H + +#include + +#include "defines.h" +#include "box.h" +#include "colour.h" + +class WOptionBox : public Box +{ + public: + WOptionBox(); + ~WOptionBox(); + void addOption(char* newOption); + void setSelected(char* selectedOption); + char* getSelected(); + void setActive(UCHAR tactive); + void left(); + void right(); + void cycle(); + void draw(); + + private: + UCHAR active; + UINT numOptions; + char** options; + UINT currentOption; +}; + +#endif diff --git a/wsymbol.cc b/wsymbol.cc index 1d02df4..a12d033 100644 --- a/wsymbol.cc +++ b/wsymbol.cc @@ -20,8 +20,8 @@ #include "wsymbol.h" -UCHAR WSymbol::widths[] = { 2, 2, 4, 4, 1, 1, 3, 3, 3, 3, 3, 4, 4 }; -UCHAR WSymbol::heights[] = { 8, 8, 12, 12, 24, 4, 18, 18, 18, 18, 18, 30, 30 }; +UCHAR WSymbol::widths[] = { 2, 2, 4, 4, 1, 1, 3, 3, 3, 3, 3, 4, 4, 2, 2}; +UCHAR WSymbol::heights[] = { 8, 8, 12, 12, 24, 4, 18, 18, 18, 18, 18, 30, 30, 16, 16}; UCHAR WSymbol::symbols[] = { @@ -522,7 +522,79 @@ UCHAR WSymbol::symbols[] = { 0x00, 0x01, 0xC0, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00 +0x00, 0x00, 0x00, 0x00, + +/* +00000000 00000011 +00000000 00001111 +00000000 00111111 +00000000 11111111 +00000011 11111111 +00001111 11111111 +00111111 11111111 +11111111 11111111 +11111111 11111111 +00111111 11111111 +00001111 11111111 +00000011 11111111 +00000000 11111111 +00000000 00111111 +00000000 00001111 +00000000 00000011 +*/ + +0x00, 0x03, +0x00, 0x07, +0x00, 0x3F, +0x00, 0xFF, +0x03, 0xFF, +0x07, 0xFF, +0x3F, 0xFF, +0xFF, 0xFF, +0xFF, 0xFF, +0x3F, 0xFF, +0x07, 0xFF, +0x03, 0xFF, +0x00, 0xFF, +0x00, 0x3F, +0x00, 0x07, +0x00, 0x03, + +/* +11000000 00000000 +11110000 00000000 +11111100 00000000 +11111111 00000000 +11111111 11000000 +11111111 11110000 +11111111 11111100 +11111111 11111111 +11111111 11111111 +11111111 11111100 +11111111 11110000 +11111111 11000000 +11111111 00000000 +11111100 00000000 +11110000 00000000 +11000000 00000000 +*/ + +0xC0, 0x00, +0xF0, 0x00, +0xFC, 0x00, +0xFF, 0x00, +0xFF, 0xC0, +0xFF, 0xF0, +0xFF, 0xFC, +0xFF, 0xFF, +0xFF, 0xFF, +0xFF, 0xFC, +0xFF, 0xF0, +0xFF, 0xC0, +0xFF, 0x00, +0xFC, 0x00, +0xF0, 0x00, +0xC0, 0x00 }; @@ -532,7 +604,7 @@ WSymbol::WSymbol() nextSymbol = 0; } -void WSymbol::draw() +void WSymbol::draw(Colour& colour) { int offset = 0; for(int i = 0; i < nextSymbol; i++) @@ -556,7 +628,7 @@ void WSymbol::draw() if ((base[bytesIn] >> (7 - bitsIn)) & 0x01) { - drawPixel(x, y, Colour::LIGHTTEXT); + drawPixel(x, y, colour); } } } diff --git a/wsymbol.h b/wsymbol.h index 5b0eb79..8e02bae 100644 --- a/wsymbol.h +++ b/wsymbol.h @@ -30,7 +30,7 @@ class WSymbol : public Box public: WSymbol(); - void draw(); + void draw(Colour& colour = Colour::LIGHTTEXT); UCHAR nextSymbol; const static UCHAR VOLUME = 0; @@ -46,6 +46,8 @@ class WSymbol : public Box const static UCHAR PLAY = 10; const static UCHAR MUTE = 11; const static UCHAR UNMUTE = 12; + const static UCHAR LEFTARROW = 13; + const static UCHAR RIGHTARROW = 14; private: static UCHAR symbols[]; -- 2.39.5