X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/c0f5089ea04bd04fe25148e712fa62cd49dc17da..558bcdaa17a7d7933751ef78c75183ec315ee1c5:/main/enigma.cpp diff --git a/main/enigma.cpp b/main/enigma.cpp index 4cc8eaf9..e669b19b 100644 --- a/main/enigma.cpp +++ b/main/enigma.cpp @@ -1,3 +1,10 @@ +#undef WITH_SDL + +#ifdef WITH_SDL +#error +#define SDLDC +#endif + #include #include #include @@ -5,132 +12,253 @@ #include #include -#include -#include -#include -#include -#include -#include #include -#include -#include +#include +#include +#include + +#ifdef WITH_SDL +#error +#include +#endif +#include + +#include +#include +#include +#include + +#include + +#include +#include + +#include + +#include + +#include + +#include + +#ifdef OBJECT_DEBUG +int object_total_remaining; + +void object_dump() +{ + printf("%d items left\n", object_total_remaining); +} +#endif + +void dumpRegion(const gRegion ®ion) +{ + fprintf(stderr, "extends: %d %d -> %d %d (%d rects)\n", + region.extends.left(), region.extends.top(), + region.extends.right(), region.extends.bottom(), region.rects.size()); +#if 0 + for (int y=0; y keyPressed; + +PSignal1 &keyPressedSignal() +{ + return keyPressed; +} + +void keyEvent(const eRCKey &key) +{ + ePtr ptr; + eActionMap::getInstance(ptr); + ptr->keyPressed(0, key.code, key.flags); +// if (!key.flags) +// keyPressed(key.code); +} + +/************************************************/ +#include +#include +#include +#include +#include +#include +#include class eMain: public eApplication, public Object { eInit init; ePtr m_mgr; - ePtr m_channel; ePtr m_dvbdb; + ePtr m_locale_time_handler; + ePtr m_scan; + ePtr m_epgcache; - ePtr m_playservice; - ePtr m_nav; - ePtr m_conn_event; public: eMain() { init.setRunlevel(eAutoInitNumbers::main); + + /* TODO: put into init */ m_dvbdb = new eDVBDB(); m_mgr = new eDVBResourceManager(); + m_locale_time_handler = new eDVBLocalTimeHandler(); + m_epgcache = new eEPGCache(); m_mgr->setChannelList(m_dvbdb); - ePtr service_center; - eServiceCenter::getInstance(service_center); +// m_scan = new eComponentScan(); +// m_scan->start(); - m_nav = new eNavigation(service_center); -#if 1 - if (service_center) - { - eServiceReference ref("2:0:1:0:0:0:0:0:0:0:/"); - ePtr lst; - if (service_center->list(ref, lst)) - eDebug("no list available!"); - else - { - std::list list; - if (lst->getContent(list)) - eDebug("list itself SUCKED AROUND!!!"); - else - for (std::list::const_iterator i(list.begin()); - i != list.end(); ++i) - eDebug("%s", i->toString().c_str()); - } - } -#endif - m_nav->connectEvent(slot(*this, &eMain::event), m_conn_event); - -// eServiceReference ref("1:0:1:6de2:44d:1:c00000:0:0:0:"); - eServiceReference ref("4097:47:0:0:0:0:0:0:0:0:/sine_60s_100.mp3"); - eServiceReference ref1("4097:47:0:0:0:0:0:0:0:0:/sine_60s_100.mp31"); - eServiceReference ref2("4097:47:0:0:0:0:0:0:0:0:/sine_60s_100.mp32"); - - if (m_nav->enqueueService(ref)) - eDebug("play sucked around!"); - else - eDebug("play r00lz!"); - - m_nav->enqueueService(ref1); - m_nav->enqueueService(ref2); - m_nav->enqueueService(ref1); - } - - void event(eNavigation *nav, int ev) - { - switch (ev) - { - case eNavigation::evNewService: - { - ePtr service; - nav->getCurrentService(service); - if (!service) - { - eDebug("no running service!"); - break; - } - ePtr s; - if (service->getIServiceInformation(s)) - { - eDebug("failed to get iserviceinformation"); - break; - } - eString name; - s->getName(name); - eDebug("NEW running service: %s", name.c_str()); - break; - } - case eNavigation::evPlayFailed: - eDebug("play failed!"); - break; - case eNavigation::evPlaylistDone: - eDebug("playlist done"); - break; - default: - eDebug("Navigation event %d", ev); - break; - } } ~eMain() { - + m_dvbdb->save(); + m_scan = 0; } }; -#ifdef OBJECT_DEBUG -int object_total_remaining; +/************************************************/ -void object_dump() -{ - printf("%d items left\n", object_total_remaining); -} -#endif +eLabel *lcd_label, *lcd_clock; -int main() -{ +int main(int argc, char **argv) +{ #ifdef OBJECT_DEBUG atexit(object_dump); #endif - eMain app; - return app.exec(); + + + ePython python; + eMain main; + + int double_buffer = 0; + +#if 1 +#ifdef SDLDC + ePtr my_dc; + gSDLDC::getInstance(my_dc); +#else + ePtr my_dc; + gFBDC::getInstance(my_dc); + + double_buffer = my_dc->haveDoubleBuffering(); +#endif + + ePtr my_lcd_dc; + gLCDDC::getInstance(my_lcd_dc); + + fontRenderClass::getInstance()->AddFont(FONTDIR "/arial.ttf", "Arial", 100); + + eWidgetDesktop dsk(eSize(720, 576)); + eWidgetDesktop dsk_lcd(eSize(132, 64)); + + if (double_buffer) + { + eDebug(" - double buffering found, enable buffered graphics mode."); + dsk.setCompositionMode(eWidgetDesktop::cmBuffered); + } + + wdsk = &dsk; + lcddsk = &dsk_lcd; + + dsk.setDC(my_dc); + dsk_lcd.setDC(my_lcd_dc); + + ePtr m_pm; + loadPNG(m_pm, "data/pal.png"); + if (!m_pm) + { + eFatal("hi ghost, please copy pal.png into your ./data, thanks!"); + } else + dsk.setPalette(*m_pm); + + dsk.setBackgroundColor(gRGB(0,0,0,0xFF)); +#endif + + /* redrawing is done in an idle-timer, so we have to set the context */ + dsk.setRedrawTask(main); + dsk_lcd.setRedrawTask(main); + + eWindow *lcd_win = new eWindow(&dsk_lcd); + + lcd_win->setFlag(eWindow::wfNoBorder); + + lcd_win->move(ePoint(0, 0)); + lcd_win->resize(eSize(132, 64)); + + lcd_label = new eLabel(lcd_win); + lcd_label->move(ePoint(0, 10)); + lcd_label->resize(eSize(132, 36)); + ePtr font = new gFont("Arial", 16); + lcd_label->setFont(font); + + lcd_clock = new eLabel(lcd_win); + lcd_clock->move(ePoint(50, 46)); + lcd_clock->resize(eSize(132, 20)); + //ePtr clkfont = new gFont("Arial", 18); + lcd_clock->setFont(font); + + //lcd_label->setText("bla bla bla, this lcd\nSUCKS!"); + //lcd_clock->setText("88:88:88"); + + lcd_win->show(); + + eRCInput::getInstance()->keyEvent.connect(slot(keyEvent)); + + printf("executing main\n"); + + python.execute("mytest", "__main__"); + +// eApp->exec(); + + return 0; +} + +eWidgetDesktop *getDesktop() +{ + return wdsk; +} + +void runMainloop() +{ + eApp->exec(); +} + +void quitMainloop() +{ + eApp->quit(0); +} + +void setLCD(const char *string) +{ + lcd_label->setText(string); +} + +void setLCDClock(const char *string) +{ + lcd_clock->setText(string); }