X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/ddc3964ed95d01e72229dc9af968a327cd84e56c..5c4cd1a455e924e578478c97d00b799ef3192ef0:/main/enigma.cpp diff --git a/main/enigma.cpp b/main/enigma.cpp index 81391c32..cc9781cc 100644 --- a/main/enigma.cpp +++ b/main/enigma.cpp @@ -1,24 +1,41 @@ +#ifdef WITH_SDL +#define SDLDC +#endif + #include +#include #include + +#include +#include +#include #include #include #include #include - -#include - -#include #include +#include +#include +#ifdef WITH_SDL +#include +#endif +#include #include - +#include +#include +#include #include #include -#include - #include - +#include #include +#include "bsod.h" + +#ifdef HAVE_GSTREAMER +#include +#endif + #ifdef OBJECT_DEBUG int object_total_remaining; @@ -28,153 +45,194 @@ void object_dump() } #endif -void dumpRegion(const gRegion ®ion) +static eWidgetDesktop *wdsk, *lcddsk; + +static int prev_ascii_code; + +int getPrevAsciiCode() { - 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()); - for (int y=0; y ptr; + eActionMap::getInstance(ptr); + if (key.flags & eRCKey::flagAscii) { - for (int x=0; xkeyPressed(key.producer->getIdentifier(), 510 /* faked KEY_ASCII */, 0); } + else + ptr->keyPressed(key.producer->getIdentifier(), key.code, key.flags); } -int main() +/************************************************/ +#include +#include +#include +#include +#include +#include +#include + +class eMain: public eApplication, public Object { + eInit init; + + ePtr m_mgr; + ePtr m_dvbdb; + ePtr m_locale_time_handler; + ePtr m_scan; + ePtr m_epgcache; + +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); + } + + ~eMain() + { + m_dvbdb->saveServicelist(); + m_scan = 0; + } +}; + +int exit_code; + +int main(int argc, char **argv) +{ +#ifdef MEMLEAK_CHECK + atexit(DumpUnfreed); +#endif + #ifdef OBJECT_DEBUG atexit(object_dump); #endif - eInit init; + +#ifdef HAVE_GSTREAMER + gst_init(&argc, &argv); +#endif + + // set pythonpath if unset + setenv("PYTHONPATH", LIBDIR "/enigma2/python", 0); + printf("PYTHONPATH: %s\n", getenv("PYTHONPATH")); - init.setRunlevel(eAutoInitNumbers::main); + bsodLogInit(); - // gui stuff -#if 0 + ePython python; + eMain main; + +#if 1 +#ifdef SDLDC + ePtr my_dc; + gSDLDC::getInstance(my_dc); +#else ePtr my_dc; gFBDC::getInstance(my_dc); -#if 1 - - gPainter p(my_dc); - gRGB pal[256]; - pal[0] = 0; - pal[1] = 0xff00ff; - pal[2] = 0xffFFff; - pal[3] = 0x00ff00; - - for (int a=0; a<0x10; ++a) - pal[a | 0x10] = (0x111111 * a) | 0xFF; - p.setPalette(pal, 0, 256); + int double_buffer = my_dc->haveDoubleBuffering(); +#endif - fontRenderClass::getInstance()->AddFont("/dbox2/cdkroot/share/fonts/arial.ttf", "Arial", 100); + ePtr my_lcd_dc; + gLCDDC::getInstance(my_lcd_dc); -#if 0 - p.resetClip(gRegion(eRect(0, 0, 720, 576))); - - - gRegion c; - eDebug("0"); - int i; + + /* ok, this is currently hardcoded for arabic. */ + /* some characters are wrong in the regular font, force them to use the replacement font */ + for (int i = 0x60c; i <= 0x66d; ++i) + eTextPara::forceReplacementGlyph(i); + eTextPara::forceReplacementGlyph(0xfdf2); + for (int i = 0xfe80; i < 0xff00; ++i) + eTextPara::forceReplacementGlyph(i); - c |= eRect(0, 20, 100, 10); - c |= eRect(0, 50, 100, 10); - c |= eRect(10, 10, 80, 100); + + eWidgetDesktop dsk(eSize(720, 576)); + eWidgetDesktop dsk_lcd(eSize(132, 64)); - c -= eRect(20, 20, 40, 40); + dsk.setStyleID(0); + dsk_lcd.setStyleID(1); - p.setForegroundColor(gColor(3)); - p.fill(eRect(0, 0, 100, 100)); - p.fill(eRect(200, 0, 100, 100)); +/* if (double_buffer) + { + eDebug(" - double buffering found, enable buffered graphics mode."); + dsk.setCompositionMode(eWidgetDesktop::cmBuffered); + } */ - for (int a=0; a %d %d", c.rects[a].left(), c.rects[a].top(), c.rects[a].right(), c.rects[a].bottom()); - eDebug("extends: %d %d %d %d", c.extends.left(), c.extends.top(), c.extends.right(), c.extends.bottom()); - p.setOffset(ePoint(100, 100)); - p.clip(c); - - p.setBackgroundColor(gColor(1)); - p.clear(); - p.setForegroundColor(gColor(2)); - p.line(ePoint(0, 0), ePoint(220, 190)); - p.clippop(); - - p.setBackgroundColor(gColor(0x1f)); - p.setForegroundColor(gColor(0x10)); - - ePtr fnt = new gFont("Arial", 70); - p.setFont(fnt); - p.renderText(eRect(100, 100, 500, 200), "Hello welt!"); -#else + wdsk = &dsk; + lcddsk = &dsk_lcd; - - eWidgetDesktop dsk(eSize(720, 576)); dsk.setDC(my_dc); + dsk_lcd.setDC(my_lcd_dc); - eWindow *bla = new eWindow(&dsk); - - bla->move(ePoint(100, 100)); - bla->resize(eSize(200, 200)); - bla->show(); - - eLabel *blablub = new eLabel(bla->child()); - blablub->setText("hello world"); - blablub->move(ePoint(0, 0)); - blablub->resize(eSize(400,400)); - -#if 0 - eWidget *bla2 = new eWidget(0); - dsk.addRootWidget(bla2, 0); - - bla2->move(ePoint(160, 160)); - bla2->resize(eSize(200, 200)); - bla2->show(); + ePtr m_pm; + loadPNG(m_pm, DATADIR "/enigma2/pal.png"); + if (!m_pm) + { + eFatal("pal.png not found!"); + } else + dsk.setPalette(*m_pm); + + dsk.setBackgroundColor(gRGB(0,0,0,0xFF)); #endif - dsk.recalcClipRegions(); + /* redrawing is done in an idle-timer, so we have to set the context */ + dsk.setRedrawTask(main); + dsk_lcd.setRedrawTask(main); -// dumpRegion(bla->m_visible_region); -// dumpRegion(bla2->m_visible_region); -// dumpRegion(blablub->m_visible_region); + eRCInput::getInstance()->keyEvent.connect(slot(keyEvent)); - eDebug("painting!"); - - dsk.invalidate(gRegion(eRect(0, 0, 720, 576))); - dsk.paint(); -#endif + printf("executing main\n"); + + bsodCatchSignals(); -#else + setIoPrio(IOPRIO_CLASS_BE, 3); - extern void contentTest(); + python.execute("mytest", "__main__"); + + if (exit_code == 5) /* python crash */ + bsodFatal(); + + dsk.paint(); + dsk_lcd.paint(); - eDebug("Contenttest"); - contentTest(); + { + gPainter p(my_lcd_dc); + p.resetClip(eRect(0, 0, 132, 64)); + p.clear(); + p.flush(); + } -#endif + return exit_code; +} - p.resetClip(gRegion(eRect(0, 0, 720, 576))); -// p.clear(); - sleep(1); - -// blablub->setText("123"); -// dumpRegion(blablub->m_visible_region); -// dumpRegion(dsk.m_dirty_region); - dsk.paint(); - +eWidgetDesktop *getDesktop(int which) +{ + return which ? lcddsk : wdsk; +} -#endif +eApplication *getApplication() +{ + return eApp; +} - ePython python; - - printf("about to execute TEST :)\n"); - python.execute("mytest", "test"); +void runMainloop() +{ + eApp->runLoop(); +} - return 0; +void quitMainloop(int exitCode) +{ + exit_code = exitCode; + eApp->quit(0); }