Date:2011-07-29 01:13:35 (12 years 8 months ago)
Author:Paul Cercueil
Commit:5f77e3baf7e3376cc6d8513bc819369871f1105c
Message:Cleaned GP2X-specific code that was built on all platforms.

There was a lot of gp2x-specific code which was built for
all platform. For instance, the code was compiled for all
the platforms with the constant "TARGET_GP2X" defined.
This obviously had to be fixed.
Files: src/Makefile.am (1 diff)
src/browsedialog.cpp (3 diffs)
src/gmenu2x.cpp (38 diffs)
src/gmenu2x.h (4 diffs)
src/inputdialog.cpp (4 diffs)
src/linkapp.cpp (3 diffs)
src/menusettingint.cpp (1 diff)
src/menusettingrgba.cpp (1 diff)
src/messagebox.cpp (2 diffs)
src/settingsdialog.cpp (2 diffs)
src/touchscreen.cpp (3 diffs)
src/touchscreen.h (2 diffs)

Change Details

src/Makefile.am
2929
3030AM_CFLAGS= @CFLAGS@ @SDL_CFLAGS@
3131
32AM_CXXFLAGS = @CXXFLAGS@ @SDL_CFLAGS@ -DTARGET_GP2X \
32AM_CXXFLAGS = @CXXFLAGS@ @SDL_CFLAGS@ \
3333    -fno-exceptions \
3434    -Wall -Wextra -Wundef -Wunused-macros
3535
src/browsedialog.cpp
5858    selected = 0;
5959    close = false;
6060    while (!close) {
61        if (gmenu2x->f200) gmenu2x->ts.poll();
61        if (gmenu2x->ts.initialized()) gmenu2x->ts.poll();
6262
6363        paint();
6464
...... 
127127        action = getAction(&event);
128128    }
129129
130    if (gmenu2x->f200 && gmenu2x->ts.pressed() && !gmenu2x->ts.inRect(touchRect)) ts_pressed = false;
130    if (gmenu2x->ts.initialized() && gmenu2x->ts.pressed() && !gmenu2x->ts.inRect(touchRect)) ts_pressed = false;
131131
132132    if (action == BrowseDialog::ACT_SELECT && (*fl)[selected] == "..")
133133        action = BrowseDialog::ACT_GOUP;
...... 
262262        icon->blit(gmenu2x->s, 5, offsetY);
263263        gmenu2x->s->write(gmenu2x->font, (*fl)[i], 24, offsetY + 8, ASFont::HAlignLeft, ASFont::VAlignMiddle);
264264
265        if (gmenu2x->f200 && gmenu2x->ts.pressed() && gmenu2x->ts.inRect(touchRect.x, offsetY + 3, touchRect.w, rowHeight)) {
265        if (gmenu2x->ts.initialized() && gmenu2x->ts.pressed() && gmenu2x->ts.inRect(touchRect.x, offsetY + 3, touchRect.w, rowHeight)) {
266266            ts_pressed = true;
267267            selected = i;
268268        }
src/gmenu2x.cpp
7979
8080#include <sys/mman.h>
8181
82#ifdef TARGET_PANDORA
82#ifdef PLATFORM_PANDORA
8383//#include <pnd_container.h>
8484//#include <pnd_conf.h>
8585//#include <pnd_discovery.h>
...... 
207207    return 0;
208208}
209209
210void GMenu2X::gp2x_init() {
211#ifdef TARGET_GP2X
210void GMenu2X::init() {
211#ifdef PLATFORM_GP2X
212212/* gp2x_mem = open("/dev/mem", O_RDWR);
213213    gp2x_memregs=(unsigned short *)mmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, gp2x_mem, 0xc0000000);
214214    MEM_REG=&gp2x_memregs[0];
...... 
216216        //if wm97xx fails to open, set f200 to false to prevent any further access to the touchscreen
217217        f200 = ts.init();
218218    }*/
219#else
219220    batteryHandle = fopen("/sys/class/power_supply/battery/capacity", "r");
220221    usbHandle = fopen("/sys/class/power_supply/USB/online", "r");
221222    acHandle = fopen("/sys/class/power_supply/ac/online", "r");
...... 
224225#endif
225226}
226227
227void GMenu2X::gp2x_deinit() {
228#ifdef TARGET_GP2X
228void GMenu2X::deinit() {
229#ifdef PLATFORM_GP2X
229230/* if (gp2x_mem!=0) {
230231        gp2x_memregs[0x28DA>>1]=0x4AB;
231232        gp2x_memregs[0x290C>>1]=640;
...... 
233234    }
234235
235236    if (f200) ts.deinit();*/
236#endif
237#else
237238    if (batteryHandle) fclose(batteryHandle);
238239    if (backlightHandle) fclose(backlightHandle);
239240    if (usbHandle) fclose(usbHandle);
240241    if (acHandle) fclose(acHandle);
242#endif
241243}
242244
243void GMenu2X::gp2x_tvout_on(bool /*pal*/) {
244#ifdef TARGET_GP2X
245void GMenu2X::tvout_on(bool /*pal*/) {
246#ifdef PLATFORM_GP2X
245247/* if (gp2x_mem!=0) {
246248// Ioctl_Dummy_t *msg;
247249// int TVHandle = ioctl(SDL_videofd, FBMMSP2CTRL, msg);
...... 
257259#endif
258260}
259261
260void GMenu2X::gp2x_tvout_off() {
261#ifdef TARGET_GP2X
262void GMenu2X::tvout_off() {
263#ifdef PLATFORM_GP2X
262264/* if (gp2x_mem!=0) {
263265        close(cx25874);
264266        cx25874 = 0;
...... 
268270}
269271
270272
271GMenu2X::GMenu2X() {
273GMenu2X::GMenu2X()
274{
275#ifdef PLATFORM_GP2X
272276    //Detect firmware version and type
273277    if (fileExists("/etc/open2x")) {
274278        fwType = "open2x";
...... 
277281        fwType = "gph";
278282        fwVersion = "";
279283    }
280#ifdef TARGET_GP2X
281    f200 = fileExists("/dev/touchscreen/wm97xx");
282#else
283    f200 = true;
284#endif
285284
286285    //open2x
287286    savedVolumeMode = 0;
...... 
297296    o2x_usb_host_on_boot = false;
298297    o2x_usb_hid_on_boot = false;
299298    o2x_usb_storage_on_boot = false;
299#endif
300300
301301    usbnet = samba = inet = web = false;
302302    useSelectionPng = false;
303303
304304    //load config data
305305    readConfig();
306
307#ifdef PLATFORM_GP2X
306308    if (fwType=="open2x") {
307309        readConfigOpen2x();
308310        // VOLUME MODIFIER
...... 
313315        }
314316    } else
315317        readCommonIni();
318#endif
316319
317320    halfX = resX/2;
318321    halfY = resY/2;
...... 
327330    usbHandle = 0;
328331    acHandle = 0;
329332
333    init();
330334
331#ifdef TARGET_GP2X
332    gp2x_mem = 0;
335#ifdef PLATFORM_GP2X
333336    cx25874 = 0;
334    gp2x_init();
335337
336338    //Fix tv-out
337339/* if (gp2x_mem!=0) {
...... 
403405
404406GMenu2X::~GMenu2X() {
405407    writeConfig();
408
409#ifdef PLATFORM_GP2X
406410    if (fwType=="open2x") writeConfigOpen2x();
411#endif
407412
408413    quit();
409414
...... 
420425
421426    unsetenv("SDL_FBCON_DONT_CLEAR");
422427
423#ifdef TARGET_GP2X
428#ifdef PLATFORM_GP2X
424429/* if (gp2x_mem!=0) {
425430        //Fix tv-out
426431        if (gp2x_memregs[0x2800>>1]&0x100) {
...... 
521526        //Add virtual links in the setting section
522527        else if (menu->getSections()[i]=="settings") {
523528            menu->addActionLink(i,"GMenu2X",MakeDelegate(this,&GMenu2X::options),tr["Configure GMenu2X's options"],"skin:icons/configure.png");
524            if (fwType=="open2x")
525                menu->addActionLink(i,"Open2x",MakeDelegate(this,&GMenu2X::settingsOpen2x),tr["Configure Open2x system settings"],"skin:icons/o2xconfigure.png");
526529            menu->addActionLink(i,tr["Skin"],MakeDelegate(this,&GMenu2X::skinMenu),tr["Configure skin"],"skin:icons/skin.png");
527530            menu->addActionLink(i,tr["Wallpaper"],MakeDelegate(this,&GMenu2X::changeWallpaper),tr["Change GMenu2X wallpaper"],"skin:icons/wallpaper.png");
528#ifdef TARGET_GP2X
531#ifdef PLATFORM_GP2X
532            if (fwType=="open2x")
533                menu->addActionLink(i,"Open2x",MakeDelegate(this,&GMenu2X::settingsOpen2x),tr["Configure Open2x system settings"],"skin:icons/o2xconfigure.png");
529534/* menu->addActionLink(i,"TV",MakeDelegate(this,&GMenu2X::toggleTvOut),tr["Activate/deactivate tv-out"],"skin:icons/tv.png");
530535            menu->addActionLink(i,"USB Sd",MakeDelegate(this,&GMenu2X::activateSdUsb),tr["Activate Usb on SD"],"skin:icons/usb.png");
531536            if (fwType=="gph" && !f200)
...... 
686691    ledOff();
687692}
688693
689
694#ifdef PLATFORM_GP2X
690695void GMenu2X::readConfigOpen2x() {
691696    string conffile = "/etc/config/open2x.conf";
692697    if (fileExists(conffile)) {
...... 
735740    }
736741    ledOff();
737742}
743#endif
738744
739745void GMenu2X::writeSkinConfig() {
740746    ledOn();
...... 
776782    ledOff();
777783}
778784
785#ifdef PLATFORM_GP2X
779786void GMenu2X::readCommonIni() {
780787    if (fileExists("/usr/gp2x/common.ini")) {
781788        ifstream inf("/usr/gp2x/common.ini", ios_base::in);
...... 
813820}
814821
815822void GMenu2X::writeCommonIni() {}
823#endif
816824
817825void GMenu2X::readTmp() {
818826    lastSelectorElement = -1;
...... 
856864}
857865
858866void GMenu2X::initServices() {
859#ifdef TARGET_GP2X
867#ifdef PLATFORM_GP2X
860868/* if (usbnet) {
861869        string services = "scripts/services.sh "+ip+" "+(inet?"on":"off")+" "+(samba?"on":"off")+" "+(web?"on":"off")+" &";
862870        system(services.c_str());
...... 
865873}
866874
867875void GMenu2X::ledOn() {
868#ifdef TARGET_GP2X
876#ifdef PLATFORM_GP2X
869877// if (gp2x_mem!=0 && !f200) gp2x_memregs[0x106E >> 1] ^= 16;
870878    //SDL_SYS_JoystickGp2xSys(joy.joystick, BATT_LED_ON);
871879#endif
872880}
873881
874882void GMenu2X::ledOff() {
875#ifdef TARGET_GP2X
883#ifdef PLATFORM_GP2X
876884// if (gp2x_mem!=0 && !f200) gp2x_memregs[0x106E >> 1] ^= 16;
877885    //SDL_SYS_JoystickGp2xSys(joy.joystick, BATT_LED_OFF);
878886#endif
...... 
906914    uint sectionLinkPadding = (skinConfInt["topBarHeight"] - 32 - font->getLineHeight()) / 3;
907915
908916    bool quit = false;
909    int x,y, offset = menu->sectionLinks()->size()>linksPerPage ? 2 : 6, helpBoxHeight = fwType=="open2x" ? 154 : 139;
917    int x,y, offset = menu->sectionLinks()->size()>linksPerPage ? 2 : 6;
918#ifdef PLATFORM_GP2X
919    int helpBoxHeight = fwType=="open2x" ? 154 : 139;
920#else
921    int helpBoxHeight = 154;
922#endif
910923    uint i;
911924    long tickBattery = -60000, tickNow;
912925    string batteryIcon = "imgs/battery/0.png";
...... 
9941007            }
9951008        }
9961009
997        if (f200) {
1010        if (ts.initialized()) {
9981011            btnContextMenu.paint();
9991012        }
10001013        //check battery status every 60 seconds
...... 
10271040            s->write( font, tr["A+VOLUP, A+VOLDOWN: Change volume"], 20, 140 );
10281041            s->write( font, tr["SELECT: Show contextual menu"], 20, 155 );
10291042            s->write( font, tr["START: Show options menu"], 20, 170 );
1043#ifdef PLATFORM_GP2X
10301044            if (fwType=="open2x") s->write( font, tr["X: Toggle speaker mode"], 20, 185 );
1031
1045#endif
10321046        }
10331047
10341048#ifdef WITH_DEBUG
...... 
10471061        s->flip();
10481062
10491063        //touchscreen
1050        if (f200) {
1064        if (ts.initialized()) {
10511065            ts.poll();
10521066            btnContextMenu.handleTS();
10531067            re.x = 0; re.y = 0; re.h = skinConfInt["topBarHeight"]; re.w = resX;
...... 
10741088            }
10751089        }
10761090
1077//#ifdef TARGET_GP2X
1078
10791091        switch (input.waitForPressedButton()) {
10801092            case ACCEPT:
10811093                if (menu->selLink() != NULL) menu->selLink()->run();
...... 
11831195    if (fd.exec()) {
11841196        if (confInt["saveSelection"] && (confInt["section"]!=menu->selSectionIndex() || confInt["link"]!=menu->selLinkIndex()))
11851197            writeConfig();
1198#ifdef PLATFORM_GP2X
11861199        if (fwType == "open2x" && savedVolumeMode != volumeMode)
11871200            writeConfigOpen2x();
1201#endif
11881202
11891203        //string command = cmdclean(fd.path()+"/"+fd.file) + "; sync & cd "+cmdclean(getExePath())+"; exec ./gmenu2x";
11901204        string command = cmdclean(fd.getPath()+"/"+fd.getFile());
...... 
12531267    }
12541268}
12551269
1270#ifdef PLATFORM_GP2X
12561271void GMenu2X::settingsOpen2x() {
12571272    SettingsDialog sd(this, input, ts, tr["Open2x Settings"]);
12581273    sd.addSetting(new MenuSettingBool(this,tr["USB net on boot"],tr["Allow USB networking to be started at boot time"],&o2x_usb_net_on_boot));
...... 
12771292        setVolume(confInt["globalVolume"]);
12781293    }
12791294}
1295#endif
12801296
12811297void GMenu2X::skinMenu() {
12821298    FileLister fl_sk(getHome() + "/skins", true, false);
...... 
13071323}
13081324
13091325void GMenu2X::toggleTvOut() {
1310#ifdef TARGET_GP2X
1326#ifdef PLATFORM_GP2X
13111327/* if (cx25874!=0)
13121328        gp2x_tvout_off();
13131329    else
...... 
15011517        s->flip();
15021518
15031519        //touchscreen
1504        if (f200) {
1520        if (ts.initialized()) {
15051521            ts.poll();
15061522            if (ts.released()) {
15071523                if (!ts.inRect(box))
...... 
17631779
17641780    uint lineY = 42;
17651781
1766#ifdef _TARGET_PANDORA
1782#ifdef PLATFORM_PANDORA
17671783    //char *configpath = pnd_conf_query_searchpath();
17681784#else
17691785    if (confInt["menuClock"]<430) {
...... 
17821798    vector<string> files;
17831799    scanPath(CARD_ROOT, &files);
17841800
1801    const char *nandpath = NULL;
1802
1803#if defined(PLATFORM_GP2X)
17851804    //Onyl gph firmware has nand
1786/* if (fwType=="gph" && !f200) {
1805    if (fwType=="gph" && !isF200())
1806        nandpath = "/boot/local/nand";
1807#elif defined(PLATFORM_DINGUX)
1808    nandpath = "/media/ccnandb1";
1809#endif
1810
1811    if (nandpath) {
17871812        scanbg.write(font,tr["Scanning NAND filesystem..."],5,lineY);
17881813        scanbg.blit(s,0,0);
17891814        s->flip();
17901815        lineY += 26;
1791        scanPath("/boot/local/nand",&files);
1816        scanPath(nandpath, &files);
17921817    }
1793*/
1818
17941819    stringstream ss;
17951820    ss << files.size();
17961821    string str = "";
...... 
18731898            scanPath(filepath, files);
18741899        if (statRet != -1) {
18751900            ext = filepath.substr(filepath.length()-4,4);
1876#ifdef TARGET_GP2X
1877            if (ext==".gpu" || ext==".dge")
1901#ifdef PLATFORM_GP2X
1902            if (ext==".gpu")
1903#elif defined(PLATFORM_DINGUX) || defined(PLATFORM_NANONOTE)
1904            if (ext==".dge")
18781905#else
18791906            if (ext==".pxml")
18801907#endif
...... 
18861913}
18871914
18881915unsigned short GMenu2X::getBatteryLevel() {
1889#ifdef TARGET_GP2X
1916#ifdef PLATFORM_GP2X
18901917/* if (batteryHandle<=0) return 0;
18911918
18921919    if (f200) {
...... 
19191946        if (battval>690) return 2;
19201947        if (battval>680) return 1;
19211948    }*/
1949
1950#else
19221951    if (!batteryHandle) return 0;
19231952    int battval = 0;
19241953    char battvalcstr[5];
...... 
19641993}
19651994
19661995void GMenu2X::applyRamTimings() {
1967#ifdef TARGET_GP2X
1996#ifdef PLATFORM_GP2X
19681997    // 6 4 1 1 1 2 2
19691998/* if (gp2x_mem!=0) {
19701999        int tRC = 5, tRAS = 3, tWR = 0, tMRD = 0, tRFC = 0, tRP = 1, tRCD = 1;
...... 
19752004}
19762005
19772006void GMenu2X::applyDefaultTimings() {
1978#ifdef TARGET_GP2X
2007#ifdef PLATFORM_GP2X
19792008    // 8 16 3 8 8 8 8
19802009/* if (gp2x_mem!=0) {
19812010        int tRC = 7, tRAS = 15, tWR = 2, tMRD = 7, tRFC = 7, tRP = 7, tRCD = 7;
...... 
19892018
19902019void GMenu2X::setClock(unsigned mhz) {
19912020    mhz = constrain(mhz, 30, confInt["maxClock"]);
1992#ifdef TARGET_GP2X
2021#if defined(PLATFORM_DINGUX) || defined(PLATFORM_NANONOTE)
19932022    jz_cpuspeed(mhz);
19942023#endif
19952024}
19962025
19972026void GMenu2X::setGamma(int /*gamma*/) {
1998#ifdef TARGET_GP2X
2027#ifdef PLATFORM_GP2X
19992028/* float fgamma = (float)constrain(gamma,1,100)/10;
20002029    fgamma = 1 / fgamma;
20012030    MEM_REG[0x2880>>1]&=~(1<<12);
src/gmenu2x.h
136136    string ip, defaultgw, lastSelectorDir;
137137    int lastSelectorElement;
138138    void readConfig();
139    void readConfigOpen2x();
140139    void readTmp();
141    void readCommonIni();
142    void writeCommonIni();
143140
144141    void initServices();
145142    void initFont();
146143    void initMenu();
147144
148#ifdef TARGET_GP2X
145#ifdef PLATFORM_GP2X
146    void readConfigOpen2x();
147    void readCommonIni();
148    void writeCommonIni();
149
149150    unsigned long gp2x_mem;
150151    unsigned short *gp2x_memregs;
151152    volatile unsigned short *MEM_REG;
152153    int cx25874; //tv-out
153154#endif
154    void gp2x_tvout_on(bool pal);
155    void gp2x_tvout_off();
156    void gp2x_init();
157    void gp2x_deinit();
155
156    void tvout_on(bool pal);
157    void tvout_off();
158    void init();
159    void deinit();
158160    void toggleTvOut();
159161
160162public:
...... 
191193    //Configuration settings
192194    bool useSelectionPng;
193195    void setSkin(const string &skin, bool setWallpaper = true);
196
197#ifdef PLATFORM_GP2X
194198    //firmware type and version
195199    string fwType, fwVersion;
196    //gp2x type
197    bool f200;
200
201    bool isF200() { return ts.initialized(); }
198202
199203    // Open2x settings ---------------------------------------------------------
200204    bool o2x_usb_net_on_boot, o2x_ftp_on_boot, o2x_telnet_on_boot, o2x_gp2xjoy_on_boot, o2x_usb_host_on_boot, o2x_usb_hid_on_boot, o2x_usb_storage_on_boot;
201205    string o2x_usb_net_ip;
202206    int volumeMode, savedVolumeMode; // just use the const int scale values at top of source
207#endif
203208
204209    // Volume scaling values to store from config files
205210    int volumeScalerPhones;
...... 
214219    //Status functions
215220    void main();
216221    void options();
222#ifdef PLATFORM_GP2X
217223    void settingsOpen2x();
224#endif
218225    void skinMenu();
226    /*
219227    void activateSdUsb();
220228    void activateNandUsb();
221229    void activateRootUsb();
230    */
222231    void about();
223232    void viewLog();
224233    void contextMenu();
...... 
241250    void setInputSpeed();
242251
243252    void writeConfig();
253#ifdef PLATFORM_GP2X
244254    void writeConfigOpen2x();
255#endif
245256    void writeSkinConfig();
246257    void writeTmp(int selelem=-1, const string &selectordir="");
247258
src/inputdialog.cpp
160160
161161        if (caretOn) gmenu2x->s->box(box.x+box.w-12, box.y+3, 8, box.h-6, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
162162
163        if (gmenu2x->f200) ts.poll();
163        if (ts.initialized()) ts.poll();
164164        action = drawVirtualKeyboard();
165165        gmenu2x->s->flip();
166166
...... 
311311            SDL_Rect re = {kbLeft+xc*KEY_WIDTH-1, KB_TOP+l*KEY_HEIGHT, KEY_WIDTH-1, KEY_HEIGHT-2};
312312
313313            //if ts on rect, change selection
314            if (gmenu2x->f200 && ts.pressed() && ts.inRect(re)) {
314            if (ts.initialized() && ts.pressed() && ts.inRect(re)) {
315315                selCol = xc;
316316                selRow = l;
317317            }
...... 
325325    //Ok/Cancel
326326    SDL_Rect re = {kbLeft-1, KB_TOP+kb->size()*KEY_HEIGHT, kbLength*KEY_WIDTH/2-1, KEY_HEIGHT-1};
327327    gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
328    if (gmenu2x->f200 && ts.pressed() && ts.inRect(re)) {
328    if (ts.initialized() && ts.pressed() && ts.inRect(re)) {
329329        selCol = 0;
330330        selRow = kb->size();
331331    }
...... 
333333
334334    re.x = kbLeft+kbLength*KEY_WIDTH/2-1;
335335    gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
336    if (gmenu2x->f200 && ts.pressed() && ts.inRect(re)) {
336    if (ts.initialized() && ts.pressed() && ts.inRect(re)) {
337337        selCol = 1;
338338        selRow = kb->size();
339339    }
340340    gmenu2x->s->write(gmenu2x->font, gmenu2x->tr["OK"], (int)(160+kbLength*KEY_WIDTH/4), KB_TOP+kb->size()*KEY_HEIGHT+KEY_HEIGHT/2, ASFont::HAlignCenter, ASFont::VAlignMiddle);
341341
342342    //if ts released
343    if (gmenu2x->f200 && ts.released() && ts.inRect(kbRect)) {
343    if (ts.initialized() && ts.released() && ts.inRect(kbRect)) {
344344        action = ID_ACTION_SELECT;
345345    }
346346
src/linkapp.cpp
215215}
216216// /G
217217
218bool LinkApp::targetExists() {
219#ifndef TARGET_GP2X
220    return true; //For displaying elements during testing on pc
221#endif
222
218bool LinkApp::targetExists()
219{
223220    string target = exec;
224221    if (!exec.empty() && exec[0]!='/' && !workdir.empty())
225222        target = workdir + "/" + exec;
...... 
417414void LinkApp::launch(const string &selectedFile, const string &selectedDir) {
418415    drawRun();
419416    save();
420#ifndef TARGET_GP2X
421    //delay for testing
422    SDL_Delay(1000);
423#endif
424417
425418    //Set correct working directory
426419    string wd = workdir;
...... 
491484    } else {
492485        if (gmenu2x->confInt["saveSelection"] && (gmenu2x->confInt["section"]!=gmenu2x->menu->selSectionIndex() || gmenu2x->confInt["link"]!=gmenu2x->menu->selLinkIndex()))
493486            gmenu2x->writeConfig();
487
488#ifdef PLATFORM_GP2X
494489        if (gmenu2x->fwType == "open2x" && gmenu2x->savedVolumeMode != gmenu2x->volumeMode)
495490            gmenu2x->writeConfigOpen2x();
491#endif
492
496493        if (selectedFile=="")
497494            gmenu2x->writeTmp();
498495             gmenu2x->quit();
src/menusettingint.cpp
111111
112112void MenuSettingInt::adjustInput()
113113{
114#ifdef TARGET_GP2X
114#ifdef PLATFORM_GP2X
115115// gmenu2x->input.setInterval(30, ACTION_LEFT );
116116// gmenu2x->input.setInterval(30, ACTION_RIGHT);
117117#endif
src/menusettingrgba.cpp
191191
192192void MenuSettingRGBA::adjustInput()
193193{
194#ifdef TARGET_GP2X
194#ifdef PLATFORM_GP2X
195195    /*
196196    gmenu2x->input.setInterval(30, ACTION_Y );
197197    gmenu2x->input.setInterval(30, ACTION_X );
src/messagebox.cpp
105105
106106    bevent_t event;
107107    while (result<0) {
108
109#ifdef PLATFORM_GP2X
108110        //touchscreen
109111        if (gmenu2x->f200) {
110112            if (gmenu2x->ts.poll()) {
...... 
115117                    }
116118            }
117119        }
120#endif
121
118122/*
119123        gmenu2x->input.update();
120124        for (uint i=0; i<buttons.size(); i++)
src/settingsdialog.cpp
5959
6060    while (!close) {
6161        action = SD_NO_ACTION;
62        if (gmenu2x->f200) ts.poll();
62        if (ts.initialized()) ts.poll();
6363
6464        bg.blit(gmenu2x->s,0,0);
6565
...... 
8686
8787        gmenu2x->s->setClipRect(clipRect);
8888        if (ts_pressed && !ts.pressed()) ts_pressed = false;
89        if (gmenu2x->f200 && ts.pressed() && !ts.inRect(touchRect)) ts_pressed = false;
89        if (ts.initialized() && ts.pressed() && !ts.inRect(touchRect)) ts_pressed = false;
9090        for (i=firstElement; i<voices.size() && i<firstElement+numRows; i++) {
9191            iY = i-firstElement;
9292            voices[i]->draw(iY*rowHeight+gmenu2x->skinConfInt["topBarHeight"]+2);
93            if (gmenu2x->f200 && ts.pressed() && ts.inRect(touchRect.x, touchRect.y+(iY*rowHeight), touchRect.w, rowHeight)) {
93            if (ts.initialized() && ts.pressed() && ts.inRect(touchRect.x, touchRect.y+(iY*rowHeight), touchRect.w, rowHeight)) {
9494                ts_pressed = true;
9595                sel = i;
9696            }
src/touchscreen.cpp
2626using namespace std;
2727
2828Touchscreen::Touchscreen() {
29    wm97xx = 0;
29    ts_fd = 0;
3030    calibrated = false;
3131    wasPressed = false;
3232    _handled = false;
...... 
4040}
4141
4242Touchscreen::~Touchscreen() {
43    if (wm97xx) deinit();
43    deinit();
4444}
4545
4646bool Touchscreen::init() {
47#ifdef TARGET_GP2X
48    wm97xx = open("/dev/touchscreen/wm97xx", O_RDONLY|O_NOCTTY);
47#ifdef PLATFORM_GP2X
48    ts_fd = open("/dev/touchscreen/wm97xx", O_RDONLY|O_NOCTTY);
4949#endif
5050    return initialized();
5151}
5252
53bool Touchscreen::initialized() {
54#ifdef TARGET_GP2X
55    return wm97xx>0;
56#else
57    return true;
58#endif
59}
60
61void Touchscreen::deinit() {
62#ifdef TARGET_GP2X
63    close(wm97xx);
64    wm97xx = 0;
65#endif
53void Touchscreen::deinit()
54{
55    if (ts_fd) close(ts_fd);
56    ts_fd = 0;
6657}
6758
6859void Touchscreen::calibrate() {
...... 
7566
7667bool Touchscreen::poll() {
7768    wasPressed = pressed();
78#ifdef TARGET_GP2X
79    read(wm97xx, &event, sizeof(TS_EVENT));
69#ifdef PLATFORM_GP2X
70    read(ts_fd, &event, sizeof(TS_EVENT));
8071    if (!calibrated) calibrate();
8172
8273    if (event.pressure>0) {
src/touchscreen.h
3636
3737class Touchscreen {
3838private:
39    int wm97xx;
39    int ts_fd;
4040    bool calibrated, _handled;
4141    TS_EVENT event;
4242    int calibX, calibY;
...... 
5050    ~Touchscreen();
5151
5252    bool init();
53    bool initialized();
5453    void deinit();
5554
55    bool initialized() {
56#ifdef PLATFORM_GP2X
57        return ts_fd>0;
58#endif
59        return false;
60    }
61
5662    bool poll();
5763    bool pressed();
5864    bool released();

Archive Download the corresponding diff file



interactive