Index: uisimulator/sdl/uisdl.c =================================================================== --- uisimulator/sdl/uisdl.c (revision 19599) +++ uisimulator/sdl/uisdl.c (working copy) @@ -112,7 +112,9 @@ return false; } +#ifndef LIBSIMULATOR atexit(SDL_Quit); +#endif /* Try and load the background image. If it fails go without */ if (background) { @@ -174,6 +176,8 @@ return true; } +#ifndef LIBSIMULATOR + #if defined(WIN32) && defined(main) /* Don't use SDL_main on windows -> no more stdio redirection */ #undef main @@ -270,3 +274,43 @@ return gui_shutdown(); } +#else + +int startup(void) +{ + if(!sim_kernel_init()) + return -1; + + if(!gui_startup()) + return -1; + + if(!thread_sdl_init(NULL)) + return -1; + + gui_message_loop(); + + gui_shutdown(); + SDL_Quit(); + + return 0; +} + +int shutdown(void) +{ + SDL_Event ev; + + ev.type = SDL_QUIT; + + return SDL_PushEvent(&ev); +} + +char *get_model_name(void) +{ +#ifdef MODEL_NAME + return MODEL_NAME; +#else + return "Unknown"; +#endif +} + +#endif /* LIBSIMULATOR */ Index: tools/configure =================================================================== --- tools/configure (revision 19599) +++ tools/configure (working copy) @@ -203,6 +203,12 @@ # use wildcard here to make it work even if it was named *.exe like # on cygwin rm -f /tmp/conftest-$id* + + if test "X$libsimulator" = "Xyes"; then + LDOPTS="$LDOPTS $SHARED_FLAG" + GCCOPTS="$GCCOPTS -DLIBSIMULATOR" + plugins="no" + fi fi } @@ -301,7 +307,7 @@ # echo "" echo "Enter your developer options (press enter when done)" - echo -n "(D)EBUG, (L)ogf, (S)imulator, (P)rofiling, (V)oice" + echo -n "(D)EBUG, (L)ogf, (S)imulator, l(I)bsimulator, (P)rofiling, (V)oice" if [ "$memory" = "2" ]; then echo -n ", (8)MB MOD" fi @@ -333,6 +339,11 @@ echo "Simulator build enabled" simulator="yes" ;; + [Ii]) + echo "libsimulator build enabled" + simulator="yes" + libsimulator="yes" + ;; [Pp]) if [ "yes" = "$use_debug" ]; then echo "Profiling is incompatible with debug" Index: utils/wpseditor/wpseditor.pro =================================================================== --- utils/wpseditor/wpseditor.pro (revision 19599) +++ utils/wpseditor/wpseditor.pro (working copy) @@ -1,4 +1,2 @@ TEMPLATE = subdirs -SUBDIRS = gui/src/QPropertyEditor gui libwps -libwps.commands = @$(MAKE) -C libwps -QMAKE_EXTRA_TARGETS += libwps +SUBDIRS = gui/src/QPropertyEditor gui Index: utils/wpseditor/gui/gui.pro =================================================================== --- utils/wpseditor/gui/gui.pro (revision 19599) +++ utils/wpseditor/gui/gui.pro (working copy) @@ -28,7 +28,6 @@ src/qwpseditorwindow.cpp \ src/utils.cpp \ src/qwpsdrawer.cpp \ - src/qwpsdrawer_static.cpp \ src/qsyntaxer.cpp \ src/numberedtextview.cpp Index: utils/wpseditor/gui/src/qwpsdrawer.cpp =================================================================== --- utils/wpseditor/gui/src/qwpsdrawer.cpp (revision 19599) +++ utils/wpseditor/gui/src/qwpsdrawer.cpp (working copy) @@ -29,246 +29,232 @@ #include "utils.h" #include "qtrackstate.h" #include "qwpsstate.h" -#include "api.h" QPointer drawer; QPixmap *QWpsDrawer::pix = NULL; QString QWpsDrawer::mTmpWpsString; QImage QWpsDrawer::backdrop; -proxy_api QWpsDrawer::api; QWpsDrawer::QWpsDrawer( QWpsState *ws,QTrackState *ms, QWidget *parent ) - : QWidget(parent),wpsState(ws),trackState(ms),showGrid(false),mCurTarget(qApp->applicationDirPath()+"/libwps_IRIVER_H10_5GB") { - - tryResolve(); + : QWidget(parent),wpsState(ws),trackState(ms),showGrid(false) +{ newTempWps(); } -bool QWpsDrawer::tryResolve() { +bool QWpsDrawer::tryResolve() +{ QLibrary lib(mCurTarget); - lib_wps_init = (pfwps_init)lib.resolve("wps_init"); - lib_wps_display = (pfwps_display)lib.resolve("wps_display"); - lib_wps_refresh = (pfwps_refresh)lib.resolve("wps_refresh"); + lib_startup = (pf_startup)lib.resolve("startup"); + lib_shutdown = (pf_shutdown)lib.resolve("shutdown"); lib_get_model_name = (pfget_model_name)lib.resolve("get_model_name"); - mResolved = lib_wps_init && lib_wps_display && lib_wps_refresh && lib_get_model_name; + mResolved = lib_startup && lib_shutdown && lib_get_model_name; + if (!mResolved) - DEBUGF1(tr("ERR: Failed to resolve funcs!")); - else { - int v = api.verbose; - memset(&api,0,sizeof(struct proxy_api)); - api.verbose = v; - api.putsxy = &QWpsDrawer::putsxy; - api.transparent_bitmap_part = &QWpsDrawer::transparent_bitmap_part; - api.bitmap_part = &QWpsDrawer::bitmap_part; - api.drawpixel = &QWpsDrawer::drawpixel; - api.fillrect = &QWpsDrawer::fillrect; - api.hline = &QWpsDrawer::hline; - api.vline = &QWpsDrawer::vline; - api.clear_viewport = &QWpsDrawer::clear_viewport; - api.load_wps_backdrop = &QWpsDrawer::load_wps_backdrop; - api.read_bmp_file = &QWpsDrawer::read_bmp_file; - api.debugf = &qlogger; + DEBUGF1("ERR: Failed to resolve funcs!"); + else + { qDebug()<<(mCurTarget+" resolved"); + + if(thread.isRunning()) + thread.stop(); + + thread.startup = lib_startup; + thread.shutdown = lib_shutdown; } + return mResolved; } -QWpsDrawer::~QWpsDrawer() { + +QWpsDrawer::~QWpsDrawer() +{ qDebug()<<"QWpsDrawer::~QWpsDrawer()"; + cleanTemp(); + + if(thread.isRunning()) + thread.stop(); } -void QWpsDrawer::mouseReleaseEvent ( QMouseEvent * event ) { - Q_UNUSED(event); - /*int x = event->x() - (this->width()-pix->width())/2, - y = event->y() - (this->height()-pix->height())/2; - DEBUGF1("x=%d,y=%d",x,y);*/ -} -void QWpsDrawer::newTempWps() { +void QWpsDrawer::newTempWps() +{ QTemporaryFile tmpWps; tmpWps.setAutoRemove(false); tmpWps.setFileTemplate(QDir::tempPath()+"/XXXXXXXXXX.wps"); - if (tmpWps.open()) { + if (tmpWps.open()) + { QString tmpDir = tmpWps.fileName().left(tmpWps.fileName().length()-4); - if (QDir::temp().mkpath(tmpDir)) { + if (QDir::temp().mkpath(tmpDir)) + { mTmpWpsString = tmpDir; DEBUGF3(QString("Created :"+mTmpWpsString).toAscii()); } } } -void QWpsDrawer::WpsInit(QString buffer, bool isFile) { +void QWpsDrawer::WpsInit(QString buffer, bool isFile) +{ DEBUGF3("QWpsDrawer::WpsInit"); + if (!mResolved) + { if (!tryResolve()) return; - if (isFile) { + } + + if (isFile) + { cleanTemp(); - DEBUGF1( tr("Loading %1").arg(buffer)); + DEBUGF1( QString("Loading %1").arg(buffer)); QFile file(buffer); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) mWpsString = file.readAll(); newTempWps(); - } else - mWpsString = buffer; + } + else { + mWpsString = buffer; QFile tfile(mTmpWpsString+".wps"); if (tfile.open(QIODevice::WriteOnly | QIODevice::Text)) tfile.write(mWpsString.toAscii(),mWpsString.length()); } - backdrop.fill(Qt::black); - DEBUGF3("clear backdrop"); - if (isFile) - lib_wps_init(buffer.toAscii(), &api, isFile); - else - lib_wps_init(QString(mTmpWpsString+".wps").toAscii(), &api, true); - pix = new QPixmap(api.getwidth(),api.getheight()); - pix->fill(Qt::black); - - drawBackdrop(); - - setMinimumWidth(api.getwidth()); - setMinimumHeight(api.getheight()); - update(); + + thread.start(); } -void QWpsDrawer::paintEvent(QPaintEvent * event) { +void QWpsDrawer::paintEvent(QPaintEvent * event) +{ DEBUGF3("QWpsDrawer::paintEvent()"); if (!mResolved) return; - if (pix==NULL) + + if (pix == NULL) return; + QPainter p(this); QRect rect = event->rect(); drawBackdrop(); - lib_wps_refresh(); - if (showGrid) { - QPainter g(pix); - viewport_api avp; - api.get_current_vp(&avp); - - g.setPen(Qt::green); - - for (int i=0;i*avp.fontheight/1.5width())/2,(rect.height()-pix->height())/2,*pix); } -void QWpsDrawer::clear_viewport(int x,int y,int w,int h, int color) { - DEBUGF2("clear_viewport(int x=%d,int y=%d,int w=%d,int h=%d, int color)",x,y,w,h); - QPainter p(pix); - //p.setOpacity(0.1); - //QImage img = backdrop.copy(x,y,w,h); - //p.drawImage(x,y,img); -} - -void QWpsDrawer::slotSetVolume() { +void QWpsDrawer::slotSetVolume() +{ Slider *slider = new Slider(this, tr("Volume"),-74,10); slider->show(); connect(slider, SIGNAL(valueChanged(int)), wpsState, SLOT(setVolume(int))); connect(this, SIGNAL(destroyed()),slider, SLOT(close())); } -void QWpsDrawer::slotSetProgress() { +void QWpsDrawer::slotSetProgress() +{ Slider *slider = new Slider(this,tr("Progress"),0,100); slider->show(); connect(slider, SIGNAL(valueChanged(int)), trackState, SLOT(setElapsed(int))); connect(this, SIGNAL(destroyed()),slider, SLOT(close())); } -void QWpsDrawer::slotWpsStateChanged(wpsstate ws_) { - if (api.set_wpsstate) - api.set_wpsstate(ws_); +void QWpsDrawer::slotWpsStateChanged(wpsstate ws_) +{ update(); } -void QWpsDrawer::slotTrackStateChanged(trackstate ms_) { - if (api.set_wpsstate) - api.set_trackstate(ms_); +void QWpsDrawer::slotTrackStateChanged(trackstate ms_) +{ update(); } -void QWpsDrawer::slotShowGrid(bool show) { +void QWpsDrawer::slotShowGrid(bool show) +{ showGrid = show; update(); } -void QWpsDrawer::drawBackdrop() { +void QWpsDrawer::drawBackdrop() +{ DEBUGF3("QWpsDrawer::drawBackdrop()"); if (backdrop.isNull()) return; + QPainter b(pix); QImage pink = backdrop.createMaskFromColor(qRgb(255,0,255),Qt::MaskOutColor); backdrop.setAlphaChannel(pink); b.drawImage(0,0,backdrop,0,0,pix->width(),pix->height()); } -void QWpsDrawer::slotSetAudioStatus(int status) { - api.set_audio_status(status); +void QWpsDrawer::slotSetAudioStatus(int status) +{ update(); } -void QWpsDrawer::cleanTemp(bool fileToo) { +void QWpsDrawer::cleanTemp(bool fileToo) +{ if (fileToo) QFile::remove(mTmpWpsString+".wps"); QDirIterator it(mTmpWpsString, QDirIterator::Subdirectories); - while (it.hasNext()) { + while (it.hasNext()) QFile::remove(it.next()); - } + QDir(mTmpWpsString).rmdir(mTmpWpsString); } -void QWpsDrawer::closeEvent(QCloseEvent *event) { +void QWpsDrawer::closeEvent(QCloseEvent *event) +{ qDebug()<<"QWpsDrawer::closeEvent()"; cleanTemp(); event->accept(); } -QString QWpsDrawer::getModelName(QString libraryName) { +QString QWpsDrawer::getModelName(QString libraryName) +{ QLibrary lib(libraryName); if ((pfget_model_name)lib.resolve("get_model_name")) return ((pfget_model_name)lib.resolve("get_model_name"))(); - DEBUGF1("ERR: failed to resolve "); - return "unknown"; + + DEBUGF1("ERR: failed to resolve :\n" + lib.errorString()); + + return "Unknown"; } -QList QWpsDrawer::getTargets() { - QList list ; +QList QWpsDrawer::getTargets() +{ + QList list; QDir d = QDir(qApp->applicationDirPath()); - QFileInfoList libs = d.entryInfoList(QStringList("libwps_*")); - qDebug() << libs.size()<<"libs found"; - for (int i = 0; i < libs.size(); i++) { + QFileInfoList libs = d.entryInfoList(QStringList("libsim_*")); + + qDebug() << libs.size()<<" libs found"; + + for (int i = 0; i < libs.size(); i++) + { QString modelName = getModelName(libs[i].absoluteFilePath()); qDebug() << libs[i].fileName()< #include #include +#include #include "wpsstate.h" @@ -35,17 +36,37 @@ class QWpsState; class QTrackState; -typedef int (*pfwps_init)(const char* buff,struct proxy_api *api, bool isfile); -typedef int (*pfwps_display)(); -typedef int (*pfwps_refresh)(); -typedef const char* (*pfget_model_name)(); +typedef int (*pf_startup)(); +typedef int (*pf_shutdown)(); +typedef char* (*pfget_model_name)(); -class QWpsDrawer : public QWidget { +class QWpsDrawer : public QWidget +{ Q_OBJECT + + class GUI_Thread : public QThread + { + public: + pf_startup startup; + pf_shutdown shutdown; + + void run(void) + { + if(startup) + startup(); + } + + void stop(void) + { + if(shutdown) + shutdown(); + + wait(); + } + } thread; - pfwps_init lib_wps_init; - pfwps_display lib_wps_display; - pfwps_refresh lib_wps_refresh; + pf_startup lib_startup; + pf_shutdown lib_shutdown; pfget_model_name lib_get_model_name; static QPixmap *pix; @@ -71,7 +92,6 @@ protected: virtual void paintEvent(QPaintEvent * event); virtual void closeEvent(QCloseEvent *event); - virtual void mouseReleaseEvent ( QMouseEvent * event ) ; void drawBackdrop(); void newTempWps(); void cleanTemp(bool fileToo=true); @@ -82,31 +102,17 @@ ~QWpsDrawer(); void WpsInit(QString buffer, bool isFile = true); - QString wpsString() const { + QString wpsString() const + { return mWpsString; }; - QString tempWps() const { + QString tempWps() const + { return mTmpWpsString; }; QList getTargets(); bool setTarget(QString target); - - static proxy_api api; - /***********Drawing api******************/ - static void putsxy(int x, int y, const unsigned char *str); - static void transparent_bitmap_part(const void *src, int src_x, int src_y, - int stride, int x, int y, int width, int height); - static void bitmap_part(const void *src, int src_x, int src_y, - int stride, int x, int y, int width, int height); - static void drawpixel(int x, int y); - static void fillrect(int x, int y, int width, int height); - static void hline(int x1, int x2, int y); - static void vline(int x, int y1, int y2); - static void clear_viewport(int x,int y,int w,int h, int color); - static bool load_wps_backdrop(char* filename); - static int read_bmp_file(const char* filename,int *width, int *height); - /****************************************/ public slots: void slotSetVolume(); void slotSetProgress(); Index: utils/wpseditor/gui/src/qwpsdrawer_static.cpp =================================================================== --- utils/wpseditor/gui/src/qwpsdrawer_static.cpp (revision 19599) +++ utils/wpseditor/gui/src/qwpsdrawer_static.cpp (working copy) @@ -1,97 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Copyright (C) 2007 by Rostilav Checkan - * $Id$ - * - * This program 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. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "qwpsdrawer.h" -#include -#include -#include -#include "utils.h" -#include "api.h" - -void QWpsDrawer::putsxy(int x, int y, const unsigned char *str) { - DEBUGF3("putsxy(int x=%d, int y=%d, *str=%s)",x,y,str); - QPainter p(pix); - viewport_api avp; - api.get_current_vp(&avp); - p.setPen(Qt::gray); - QFont font("times",avp.fontheight,QFont::Bold); - p.setFont(font); - p.drawText(x+avp.x,y + avp.fontheight + avp.y,(char*)str); -} -void QWpsDrawer::transparent_bitmap_part(const void *src, int src_x, int src_y, - int stride, int x, int y, int width, int height) { - QImage img; - img.load((char*)src); - DEBUGF2("transparent_bitmap_part(const void *src=%s, int src_x=%d, int src_y=%d,int stride=%d, int x=%d, int y=%d, int width=%d, int height=%d",(char*)src,src_x, src_y,stride, x, y, width, height); - QPainter p(pix); - QPoint target(x,y); - QRectF source(src_x, src_y, width, height); - - QImage pink = img.createMaskFromColor(qRgb(255,0,255),Qt::MaskOutColor); - img.setAlphaChannel(pink); - - p.drawImage(target, img, source); -} -void QWpsDrawer::bitmap_part(const void *src, int src_x, int src_y, - int stride, int x, int y, int width, int height) { - transparent_bitmap_part(src,src_x,src_y,stride,x,y,width,height); -} -void QWpsDrawer::drawpixel(int x, int y) { - QPainter p(pix); - p.setPen(Qt::blue); - p.drawPoint(x,y); -} -void QWpsDrawer::fillrect(int x, int y, int width, int height) { - QPainter p(pix); - DEBUGF2("fillrect(int x=%d, int y=%d, int width=%d, int height=%d)\n",x, y, width, height); - p.setPen(Qt::green); -} -void QWpsDrawer::hline(int x1, int x2, int y) { - QPainter p(pix); - p.setPen(Qt::black); - p.drawLine(x1,y,x2,y); -} -void QWpsDrawer::vline(int x, int y1, int y2) { - QPainter p(pix); - p.setPen(Qt::black); - p.drawLine(x,y1,x,y2); -} -bool QWpsDrawer::load_wps_backdrop(char* filename) { - DEBUGF3("load backdrop: %s", filename); - QFile file(filename); - QFileInfo info(file); - file.copy(mTmpWpsString+"/"+info.fileName()); - backdrop.load(filename); - return true; -} - -int QWpsDrawer::read_bmp_file(const char* filename,int *width, int *height) { - QImage img; - - QFile file(filename); - QFileInfo info(file); - file.copy(mTmpWpsString+"/"+info.fileName()); - - img.load(filename); - *width = img.width(); - *height = img.height(); - return 1; -} Index: utils/wpseditor/gui/src/qwpseditorwindow.cpp =================================================================== --- utils/wpseditor/gui/src/qwpseditorwindow.cpp (revision 19599) +++ utils/wpseditor/gui/src/qwpseditorwindow.cpp (working copy) @@ -50,7 +50,6 @@ scrollingLine = -1; setupUi(this); drawer = new QWpsDrawer(&wpsState,&trackState, this); - QWpsDrawer::api.verbose = 1; setCentralWidget(drawer); connectActions(); m_propertyEditor->addObject(&trackState); @@ -145,11 +144,8 @@ } } -void QWpsEditorWindow::slotVerboseLevel() { - bool ok; - int i = QInputDialog::getInteger(this, tr("Set Verbose Level"),tr("Level:"), QWpsDrawer::api.verbose, 0, 3, 1, &ok); - if (ok) - QWpsDrawer::api.verbose = i; +void QWpsEditorWindow::slotVerboseLevel() +{ } void QWpsEditorWindow::slotUpdatePlainWps() { Index: utils/wpseditor/gui/ui/mainwindow.ui =================================================================== --- utils/wpseditor/gui/ui/mainwindow.ui (revision 19599) +++ utils/wpseditor/gui/ui/mainwindow.ui (working copy) @@ -19,7 +19,7 @@ 0 0 882 - 21 + 19 @@ -48,14 +48,28 @@ - + + + + 0 + 650 + 882 + 19 + + + - - - 0 - 30 - + + + 0 + 371 + 882 + 279 + + + QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable + PlainWps @@ -63,6 +77,14 @@ 8 + + + 0 + 20 + 882 + 259 + + @@ -71,19 +93,6 @@ - - - - Qt::Vertical - - - - 20 - 211 - - - - @@ -100,10 +109,34 @@ + + + + Qt::Vertical + + + + 20 + 211 + + + + + + + 0 + 19 + 480 + 346 + + + + QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable + Property Editor @@ -114,15 +147,28 @@ false + + + 0 + 20 + 480 + 326 + + - - - 0 - 30 - + + + 508 + 19 + 374 + 346 + + + QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable + Log @@ -130,6 +176,14 @@ 2 + + + 0 + 20 + 374 + 326 + +