X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/06469e38dc7f21a2587efc181f47fa219efa8e5f..af1080bf1a330ffa25e1d4e75c95fe0541656aa8:/main/enigma.cpp diff --git a/main/enigma.cpp b/main/enigma.cpp index 2003a452..1cdd867b 100644 --- a/main/enigma.cpp +++ b/main/enigma.cpp @@ -1,46 +1,36 @@ -#undef WITH_SDL - -#ifdef WITH_SDL -#error -#define SDLDC -#endif - +#include +#include #include +#include +#include #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 - -#include #include +#include -#include - -#include - -#include +#include "bsod.h" +#include "version_info.h" -#include +#include #ifdef OBJECT_DEBUG int object_total_remaining; @@ -51,51 +41,46 @@ 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()); -#if 0 - 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) { + static eRCKey last(0, 0, 0); + static int num_repeat; + ePtr ptr; eActionMap::getInstance(ptr); - ptr->keyPressed(0, key.code, key.flags); -// if (!key.flags) -// keyPressed(key.code); + + if ((key.code == last.code) && (key.producer == last.producer) && key.flags & eRCKey::flagRepeat) + num_repeat++; + else + { + num_repeat = 0; + last = key; + } + + if (num_repeat == 4) + { + ptr->keyPressed(key.producer->getIdentifier(), key.code, eRCKey::flagLong); + num_repeat++; + } + + if (key.flags & eRCKey::flagAscii) + { + prev_ascii_code = key.code; + ptr->keyPressed(key.producer->getIdentifier(), 510 /* faked KEY_ASCII */, 0); + } + else + ptr->keyPressed(key.producer->getIdentifier(), key.code, key.flags); } /************************************************/ @@ -110,19 +95,17 @@ void keyEvent(const eRCKey &key) class eMain: public eApplication, public Object { eInit init; - - ePtr m_mgr; + ePtr m_dvbdb; + ePtr m_mgr; ePtr m_locale_time_handler; - ePtr m_scan; ePtr m_epgcache; public: eMain() { init.setRunlevel(eAutoInitNumbers::main); - - /* TODO: put into init */ + /* TODO: put into init */ m_dvbdb = new eDVBDB(); m_mgr = new eDVBResourceManager(); m_locale_time_handler = new eDVBLocalTimeHandler(); @@ -133,51 +116,57 @@ public: ~eMain() { m_dvbdb->saveServicelist(); - m_scan = 0; + m_mgr->releaseCachedChannel(); } }; -/************************************************/ - -eLabel *lcd_label, *lcd_clock; - int exit_code; int main(int argc, char **argv) { +#ifdef MEMLEAK_CHECK + atexit(DumpUnfreed); +#endif + #ifdef OBJECT_DEBUG atexit(object_dump); #endif + gst_init(&argc, &argv); + // set pythonpath if unset - setenv("PYTHONPATH", LIBDIR "/enigma2/python", 0); + setenv("PYTHONPATH", eEnv::resolve("${libdir}/enigma2/python").c_str(), 0); printf("PYTHONPATH: %s\n", getenv("PYTHONPATH")); - + + bsodLogInit(); 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); + ePtr my_dc; + gMainDC::getInstance(my_dc); - double_buffer = my_dc->haveDoubleBuffering(); -#endif + //int double_buffer = my_dc->haveDoubleBuffering(); ePtr my_lcd_dc; gLCDDC::getInstance(my_lcd_dc); - fontRenderClass::getInstance()->AddFont(FONTDIR "/md_khmurabi_10.ttf", "Regular", 100); + + /* 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)); - + eWidgetDesktop dsk_lcd(my_lcd_dc->size()); + + dsk.setStyleID(0); + dsk_lcd.setStyleID(my_lcd_dc->size().width() == 96 ? 2 : 1); + /* if (double_buffer) { eDebug(" - double buffering found, enable buffered graphics mode."); @@ -191,7 +180,7 @@ int main(int argc, char **argv) dsk_lcd.setDC(my_lcd_dc); ePtr m_pm; - loadPNG(m_pm, DATADIR "/enigma2/pal.png"); + loadPNG(m_pm, eEnv::resolve("${datadir}/enigma2/skin_default/pal.png").c_str()); if (!m_pm) { eFatal("pal.png not found!"); @@ -204,64 +193,136 @@ int main(int argc, char **argv) /* 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)); + eDebug("Loading spinners..."); - lcd_label = new eLabel(lcd_win); - lcd_label->move(ePoint(0, 4)); - lcd_label->resize(eSize(132, 42)); - ePtr font = new gFont("Regular", 19); - //ePtr font = new gFont("Regular", 16); - lcd_label->setFont(font); - - lcd_clock = new eLabel(lcd_win); - lcd_clock->move(ePoint(50, 46)); - lcd_clock->resize(eSize(132, 18)); - ePtr clkfont = new gFont("Regular", 16); - lcd_clock->setFont(clkfont); - - //lcd_label->setText("bla bla bla, this lcd\nSUCKS!"); - //lcd_clock->setText("88:88:88"); - - lcd_win->show(); + { + int i; +#define MAX_SPINNER 64 + ePtr wait[MAX_SPINNER]; + for (i=0; isetSpinner(eRect(ePoint(100, 100), wait[0]->size()), wait, i); + else + my_dc->setSpinner(eRect(100, 100, 0, 0), wait, 1); + } + gRC::getInstance()->setSpinnerDC(my_dc); + eRCInput::getInstance()->keyEvent.connect(slot(keyEvent)); printf("executing main\n"); + + bsodCatchSignals(); - python.execute("mytest", "__main__"); + setIoPrio(IOPRIO_CLASS_BE, 3); -// eApp->exec(); +// python.execute("mytest", "__main__"); + python.execFile(eEnv::resolve("${libdir}/enigma2/python/mytest.py").c_str()); + + extern void setFullsize(); // definend in lib/gui/evideo.cpp + setFullsize(); + + if (exit_code == 5) /* python crash */ + { + eDebug("(exit code 5)"); + bsodFatal(0); + } + + dsk.paint(); + dsk_lcd.paint(); + + { + gPainter p(my_lcd_dc); + p.resetClip(eRect(0, 0, 132, 64)); + p.clear(); + } return exit_code; } -eWidgetDesktop *getDesktop() +eWidgetDesktop *getDesktop(int which) { - return wdsk; + return which ? lcddsk : wdsk; } -void runMainloop() +eApplication *getApplication() { - exit_code = eApp->exec(); + return eApp; } void quitMainloop(int exitCode) { - eApp->quit(exitCode); + FILE *f = fopen("/proc/stb/fp/was_timer_wakeup", "w"); + if (f) + { + fprintf(f, "%d", 0); + fclose(f); + } + else + { + int fd = open("/dev/dbox/fp0", O_WRONLY); + if (fd >= 0) + { + if (ioctl(fd, 10 /*FP_CLEAR_WAKEUP_TIMER*/) < 0) + eDebug("FP_CLEAR_WAKEUP_TIMER failed (%m)"); + close(fd); + } + else + eDebug("open /dev/dbox/fp0 for wakeup timer clear failed!(%m)"); + } + exit_code = exitCode; + eApp->quit(0); +} + +static void sigterm_handler(int num) +{ + quitMainloop(128 + num); } -void setLCD(const char *string) +void runMainloop() { - lcd_label->setText(string); + struct sigaction act; + + act.sa_handler = sigterm_handler; + act.sa_flags = SA_RESTART; + + if (sigemptyset(&act.sa_mask) == -1) + perror("sigemptyset"); + if (sigaction(SIGTERM, &act, 0) == -1) + perror("SIGTERM"); + + eApp->runLoop(); +} + +const char *getEnigmaVersionString() +{ + std::string date = enigma2_date; + std::string branch = enigma2_branch; + return std::string(date + '-' + branch).c_str(); } -void setLCDClock(const char *string) +#include + +void dump_malloc_stats(void) { - lcd_clock->setText(string); + struct mallinfo mi = mallinfo(); + eDebug("MALLOC: %d total", mi.uordblks); }