X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/4c1d83d373b4a0737da668945d1ddb3278b6c3b7..8c2738805bfb08c0398acf6cb61f21bf7afa0d4d:/main/enigma.cpp?ds=sidebyside diff --git a/main/enigma.cpp b/main/enigma.cpp index 4f3287f5..5a22110e 100644 --- a/main/enigma.cpp +++ b/main/enigma.cpp @@ -1,36 +1,40 @@ +#ifdef WITH_SDL +#define SDLDC +#endif + #include +#include #include + +#include +#include +#include #include #include #include #include - -#include - -#include #include -#ifdef SDLDC +#include +#include +#ifdef WITH_SDL #include #endif +#include #include - +#include +#include +#include #include #include -#include -#include - #include - -#include #include +#include -#include - -#include +#include "bsod.h" -#include - -#include +#ifdef HAVE_GSTREAMER +#include +#endif #ifdef OBJECT_DEBUG int object_total_remaining; @@ -41,48 +45,28 @@ void object_dump() } #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()); - for (int y=0; y keyPressed; - -PSignal1 &keyPressedSignal() -{ - return keyPressed; + int ret = prev_ascii_code; + prev_ascii_code = 0; + return ret; } void keyEvent(const eRCKey &key) { ePtr ptr; eActionMap::getInstance(ptr); - ptr->keyPressed(0, key.code, key.flags); -// if (!key.flags) -// keyPressed(key.code); + if (key.flags & eRCKey::flagAscii) + { + prev_ascii_code = key.code; + ptr->keyPressed(0, 510 /* faked KEY_ASCII */, 0); + } + else + ptr->keyPressed(0, key.code, key.flags); } /************************************************/ @@ -91,6 +75,8 @@ void keyEvent(const eRCKey &key) #include #include #include +#include +#include class eMain: public eApplication, public Object { @@ -98,9 +84,10 @@ class eMain: public eApplication, public Object ePtr m_mgr; ePtr m_dvbdb; - + ePtr m_locale_time_handler; ePtr m_scan; - + ePtr m_epgcache; + public: eMain() { @@ -109,33 +96,43 @@ public: /* 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); - -// m_scan = new eComponentScan(); -// m_scan->start(); - } ~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 +#ifdef HAVE_GSTREAMER + gst_init(&argc, &argv); +#endif + + // set pythonpath if unset + setenv("PYTHONPATH", LIBDIR "/enigma2/python", 0); + printf("PYTHONPATH: %s\n", getenv("PYTHONPATH")); + + bsodLogInit(); ePython python; eMain main; - + #if 1 #ifdef SDLDC ePtr my_dc; @@ -143,53 +140,103 @@ int main(int argc, char **argv) #else ePtr my_dc; gFBDC::getInstance(my_dc); + + int double_buffer = my_dc->haveDoubleBuffering(); #endif - fontRenderClass::getInstance()->AddFont("/usr/share/fonts/arial.ttf", "Arial", 100); + ePtr my_lcd_dc; + gLCDDC::getInstance(my_lcd_dc); + + + /* 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); + 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"); + loadPNG(m_pm, DATADIR "/enigma2/pal.png"); if (!m_pm) { - eFatal("hi ghost, please copy pal.png into your ./data, thanks!"); + eFatal("pal.png not found!"); } else dsk.setPalette(*m_pm); - dsk.setBackgroundColor(gRGB(0,0,0,0)); + 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); + eRCInput::getInstance()->keyEvent.connect(slot(keyEvent)); printf("executing main\n"); + + bsodCatchSignals(); + + setIoPrio(IOPRIO_CLASS_BE, 3); python.execute("mytest", "__main__"); + + if (exit_code == 5) /* python crash */ + bsodFatal(); + + dsk.paint(); + dsk_lcd.paint(); -// eApp->exec(); + { + gPainter p(my_lcd_dc); + p.resetClip(eRect(0, 0, 132, 64)); + p.clear(); + p.flush(); + } - return 0; + return exit_code; } -eWidgetDesktop *getDesktop() +eWidgetDesktop *getDesktop(int which) { - return wdsk; + return which ? lcddsk : wdsk; +} + +eApplication *getApplication() +{ + return eApp; } void runMainloop() { - eApp->exec(); + eApp->runLoop(); } -void quitMainloop() +void quitMainloop(int exitCode) { + exit_code = exitCode; eApp->quit(0); } + +void addFont(const char *filename, const char *alias, int scale_factor, int is_replacement) +{ + fontRenderClass::getInstance()->AddFont(filename, alias, scale_factor); + if (is_replacement) + eTextPara::setReplacementFont(alias); +}