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 | ||
---|---|---|
29 | 29 | |
30 | 30 | AM_CFLAGS= @CFLAGS@ @SDL_CFLAGS@ |
31 | 31 | |
32 | AM_CXXFLAGS = @CXXFLAGS@ @SDL_CFLAGS@ -DTARGET_GP2X \ | |
32 | AM_CXXFLAGS = @CXXFLAGS@ @SDL_CFLAGS@ \ | |
33 | 33 | -fno-exceptions \ |
34 | 34 | -Wall -Wextra -Wundef -Wunused-macros |
35 | 35 |
src/browsedialog.cpp | ||
---|---|---|
58 | 58 | selected = 0; |
59 | 59 | close = false; |
60 | 60 | while (!close) { |
61 | if (gmenu2x->f200) gmenu2x->ts.poll(); | |
61 | if (gmenu2x->ts.initialized()) gmenu2x->ts.poll(); | |
62 | 62 | |
63 | 63 | paint(); |
64 | 64 | |
... | ... | |
127 | 127 | action = getAction(&event); |
128 | 128 | } |
129 | 129 | |
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; | |
131 | 131 | |
132 | 132 | if (action == BrowseDialog::ACT_SELECT && (*fl)[selected] == "..") |
133 | 133 | action = BrowseDialog::ACT_GOUP; |
... | ... | |
262 | 262 | icon->blit(gmenu2x->s, 5, offsetY); |
263 | 263 | gmenu2x->s->write(gmenu2x->font, (*fl)[i], 24, offsetY + 8, ASFont::HAlignLeft, ASFont::VAlignMiddle); |
264 | 264 | |
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)) { | |
266 | 266 | ts_pressed = true; |
267 | 267 | selected = i; |
268 | 268 | } |
src/gmenu2x.cpp | ||
---|---|---|
79 | 79 | |
80 | 80 | #include <sys/mman.h> |
81 | 81 | |
82 | #ifdef TARGET_PANDORA | |
82 | #ifdef PLATFORM_PANDORA | |
83 | 83 | //#include <pnd_container.h> |
84 | 84 | //#include <pnd_conf.h> |
85 | 85 | //#include <pnd_discovery.h> |
... | ... | |
207 | 207 | return 0; |
208 | 208 | } |
209 | 209 | |
210 | void GMenu2X::gp2x_init() { | |
211 | #ifdef TARGET_GP2X | |
210 | void GMenu2X::init() { | |
211 | #ifdef PLATFORM_GP2X | |
212 | 212 | /* gp2x_mem = open("/dev/mem", O_RDWR); |
213 | 213 | gp2x_memregs=(unsigned short *)mmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, gp2x_mem, 0xc0000000); |
214 | 214 | MEM_REG=&gp2x_memregs[0]; |
... | ... | |
216 | 216 | //if wm97xx fails to open, set f200 to false to prevent any further access to the touchscreen |
217 | 217 | f200 = ts.init(); |
218 | 218 | }*/ |
219 | #else | |
219 | 220 | batteryHandle = fopen("/sys/class/power_supply/battery/capacity", "r"); |
220 | 221 | usbHandle = fopen("/sys/class/power_supply/USB/online", "r"); |
221 | 222 | acHandle = fopen("/sys/class/power_supply/ac/online", "r"); |
... | ... | |
224 | 225 | #endif |
225 | 226 | } |
226 | 227 | |
227 | void GMenu2X::gp2x_deinit() { | |
228 | #ifdef TARGET_GP2X | |
228 | void GMenu2X::deinit() { | |
229 | #ifdef PLATFORM_GP2X | |
229 | 230 | /* if (gp2x_mem!=0) { |
230 | 231 | gp2x_memregs[0x28DA>>1]=0x4AB; |
231 | 232 | gp2x_memregs[0x290C>>1]=640; |
... | ... | |
233 | 234 | } |
234 | 235 | |
235 | 236 | if (f200) ts.deinit();*/ |
236 | #endif | |
237 | #else | |
237 | 238 | if (batteryHandle) fclose(batteryHandle); |
238 | 239 | if (backlightHandle) fclose(backlightHandle); |
239 | 240 | if (usbHandle) fclose(usbHandle); |
240 | 241 | if (acHandle) fclose(acHandle); |
242 | #endif | |
241 | 243 | } |
242 | 244 | |
243 | void GMenu2X::gp2x_tvout_on(bool /*pal*/) { | |
244 | #ifdef TARGET_GP2X | |
245 | void GMenu2X::tvout_on(bool /*pal*/) { | |
246 | #ifdef PLATFORM_GP2X | |
245 | 247 | /* if (gp2x_mem!=0) { |
246 | 248 | // Ioctl_Dummy_t *msg; |
247 | 249 | // int TVHandle = ioctl(SDL_videofd, FBMMSP2CTRL, msg); |
... | ... | |
257 | 259 | #endif |
258 | 260 | } |
259 | 261 | |
260 | void GMenu2X::gp2x_tvout_off() { | |
261 | #ifdef TARGET_GP2X | |
262 | void GMenu2X::tvout_off() { | |
263 | #ifdef PLATFORM_GP2X | |
262 | 264 | /* if (gp2x_mem!=0) { |
263 | 265 | close(cx25874); |
264 | 266 | cx25874 = 0; |
... | ... | |
268 | 270 | } |
269 | 271 | |
270 | 272 | |
271 | GMenu2X::GMenu2X() { | |
273 | GMenu2X::GMenu2X() | |
274 | { | |
275 | #ifdef PLATFORM_GP2X | |
272 | 276 | //Detect firmware version and type |
273 | 277 | if (fileExists("/etc/open2x")) { |
274 | 278 | fwType = "open2x"; |
... | ... | |
277 | 281 | fwType = "gph"; |
278 | 282 | fwVersion = ""; |
279 | 283 | } |
280 | #ifdef TARGET_GP2X | |
281 | f200 = fileExists("/dev/touchscreen/wm97xx"); | |
282 | #else | |
283 | f200 = true; | |
284 | #endif | |
285 | 284 | |
286 | 285 | //open2x |
287 | 286 | savedVolumeMode = 0; |
... | ... | |
297 | 296 | o2x_usb_host_on_boot = false; |
298 | 297 | o2x_usb_hid_on_boot = false; |
299 | 298 | o2x_usb_storage_on_boot = false; |
299 | #endif | |
300 | 300 | |
301 | 301 | usbnet = samba = inet = web = false; |
302 | 302 | useSelectionPng = false; |
303 | 303 | |
304 | 304 | //load config data |
305 | 305 | readConfig(); |
306 | ||
307 | #ifdef PLATFORM_GP2X | |
306 | 308 | if (fwType=="open2x") { |
307 | 309 | readConfigOpen2x(); |
308 | 310 | // VOLUME MODIFIER |
... | ... | |
313 | 315 | } |
314 | 316 | } else |
315 | 317 | readCommonIni(); |
318 | #endif | |
316 | 319 | |
317 | 320 | halfX = resX/2; |
318 | 321 | halfY = resY/2; |
... | ... | |
327 | 330 | usbHandle = 0; |
328 | 331 | acHandle = 0; |
329 | 332 | |
333 | init(); | |
330 | 334 | |
331 | #ifdef TARGET_GP2X | |
332 | gp2x_mem = 0; | |
335 | #ifdef PLATFORM_GP2X | |
333 | 336 | cx25874 = 0; |
334 | gp2x_init(); | |
335 | 337 | |
336 | 338 | //Fix tv-out |
337 | 339 | /* if (gp2x_mem!=0) { |
... | ... | |
403 | 405 | |
404 | 406 | GMenu2X::~GMenu2X() { |
405 | 407 | writeConfig(); |
408 | ||
409 | #ifdef PLATFORM_GP2X | |
406 | 410 | if (fwType=="open2x") writeConfigOpen2x(); |
411 | #endif | |
407 | 412 | |
408 | 413 | quit(); |
409 | 414 | |
... | ... | |
420 | 425 | |
421 | 426 | unsetenv("SDL_FBCON_DONT_CLEAR"); |
422 | 427 | |
423 | #ifdef TARGET_GP2X | |
428 | #ifdef PLATFORM_GP2X | |
424 | 429 | /* if (gp2x_mem!=0) { |
425 | 430 | //Fix tv-out |
426 | 431 | if (gp2x_memregs[0x2800>>1]&0x100) { |
... | ... | |
521 | 526 | //Add virtual links in the setting section |
522 | 527 | else if (menu->getSections()[i]=="settings") { |
523 | 528 | 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"); | |
526 | 529 | menu->addActionLink(i,tr["Skin"],MakeDelegate(this,&GMenu2X::skinMenu),tr["Configure skin"],"skin:icons/skin.png"); |
527 | 530 | 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"); | |
529 | 534 | /* menu->addActionLink(i,"TV",MakeDelegate(this,&GMenu2X::toggleTvOut),tr["Activate/deactivate tv-out"],"skin:icons/tv.png"); |
530 | 535 | menu->addActionLink(i,"USB Sd",MakeDelegate(this,&GMenu2X::activateSdUsb),tr["Activate Usb on SD"],"skin:icons/usb.png"); |
531 | 536 | if (fwType=="gph" && !f200) |
... | ... | |
686 | 691 | ledOff(); |
687 | 692 | } |
688 | 693 | |
689 | ||
694 | #ifdef PLATFORM_GP2X | |
690 | 695 | void GMenu2X::readConfigOpen2x() { |
691 | 696 | string conffile = "/etc/config/open2x.conf"; |
692 | 697 | if (fileExists(conffile)) { |
... | ... | |
735 | 740 | } |
736 | 741 | ledOff(); |
737 | 742 | } |
743 | #endif | |
738 | 744 | |
739 | 745 | void GMenu2X::writeSkinConfig() { |
740 | 746 | ledOn(); |
... | ... | |
776 | 782 | ledOff(); |
777 | 783 | } |
778 | 784 | |
785 | #ifdef PLATFORM_GP2X | |
779 | 786 | void GMenu2X::readCommonIni() { |
780 | 787 | if (fileExists("/usr/gp2x/common.ini")) { |
781 | 788 | ifstream inf("/usr/gp2x/common.ini", ios_base::in); |
... | ... | |
813 | 820 | } |
814 | 821 | |
815 | 822 | void GMenu2X::writeCommonIni() {} |
823 | #endif | |
816 | 824 | |
817 | 825 | void GMenu2X::readTmp() { |
818 | 826 | lastSelectorElement = -1; |
... | ... | |
856 | 864 | } |
857 | 865 | |
858 | 866 | void GMenu2X::initServices() { |
859 | #ifdef TARGET_GP2X | |
867 | #ifdef PLATFORM_GP2X | |
860 | 868 | /* if (usbnet) { |
861 | 869 | string services = "scripts/services.sh "+ip+" "+(inet?"on":"off")+" "+(samba?"on":"off")+" "+(web?"on":"off")+" &"; |
862 | 870 | system(services.c_str()); |
... | ... | |
865 | 873 | } |
866 | 874 | |
867 | 875 | void GMenu2X::ledOn() { |
868 | #ifdef TARGET_GP2X | |
876 | #ifdef PLATFORM_GP2X | |
869 | 877 | // if (gp2x_mem!=0 && !f200) gp2x_memregs[0x106E >> 1] ^= 16; |
870 | 878 | //SDL_SYS_JoystickGp2xSys(joy.joystick, BATT_LED_ON); |
871 | 879 | #endif |
872 | 880 | } |
873 | 881 | |
874 | 882 | void GMenu2X::ledOff() { |
875 | #ifdef TARGET_GP2X | |
883 | #ifdef PLATFORM_GP2X | |
876 | 884 | // if (gp2x_mem!=0 && !f200) gp2x_memregs[0x106E >> 1] ^= 16; |
877 | 885 | //SDL_SYS_JoystickGp2xSys(joy.joystick, BATT_LED_OFF); |
878 | 886 | #endif |
... | ... | |
906 | 914 | uint sectionLinkPadding = (skinConfInt["topBarHeight"] - 32 - font->getLineHeight()) / 3; |
907 | 915 | |
908 | 916 | 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 | |
910 | 923 | uint i; |
911 | 924 | long tickBattery = -60000, tickNow; |
912 | 925 | string batteryIcon = "imgs/battery/0.png"; |
... | ... | |
994 | 1007 | } |
995 | 1008 | } |
996 | 1009 | |
997 | if (f200) { | |
1010 | if (ts.initialized()) { | |
998 | 1011 | btnContextMenu.paint(); |
999 | 1012 | } |
1000 | 1013 | //check battery status every 60 seconds |
... | ... | |
1027 | 1040 | s->write( font, tr["A+VOLUP, A+VOLDOWN: Change volume"], 20, 140 ); |
1028 | 1041 | s->write( font, tr["SELECT: Show contextual menu"], 20, 155 ); |
1029 | 1042 | s->write( font, tr["START: Show options menu"], 20, 170 ); |
1043 | #ifdef PLATFORM_GP2X | |
1030 | 1044 | if (fwType=="open2x") s->write( font, tr["X: Toggle speaker mode"], 20, 185 ); |
1031 | ||
1045 | #endif | |
1032 | 1046 | } |
1033 | 1047 | |
1034 | 1048 | #ifdef WITH_DEBUG |
... | ... | |
1047 | 1061 | s->flip(); |
1048 | 1062 | |
1049 | 1063 | //touchscreen |
1050 | if (f200) { | |
1064 | if (ts.initialized()) { | |
1051 | 1065 | ts.poll(); |
1052 | 1066 | btnContextMenu.handleTS(); |
1053 | 1067 | re.x = 0; re.y = 0; re.h = skinConfInt["topBarHeight"]; re.w = resX; |
... | ... | |
1074 | 1088 | } |
1075 | 1089 | } |
1076 | 1090 | |
1077 | //#ifdef TARGET_GP2X | |
1078 | ||
1079 | 1091 | switch (input.waitForPressedButton()) { |
1080 | 1092 | case ACCEPT: |
1081 | 1093 | if (menu->selLink() != NULL) menu->selLink()->run(); |
... | ... | |
1183 | 1195 | if (fd.exec()) { |
1184 | 1196 | if (confInt["saveSelection"] && (confInt["section"]!=menu->selSectionIndex() || confInt["link"]!=menu->selLinkIndex())) |
1185 | 1197 | writeConfig(); |
1198 | #ifdef PLATFORM_GP2X | |
1186 | 1199 | if (fwType == "open2x" && savedVolumeMode != volumeMode) |
1187 | 1200 | writeConfigOpen2x(); |
1201 | #endif | |
1188 | 1202 | |
1189 | 1203 | //string command = cmdclean(fd.path()+"/"+fd.file) + "; sync & cd "+cmdclean(getExePath())+"; exec ./gmenu2x"; |
1190 | 1204 | string command = cmdclean(fd.getPath()+"/"+fd.getFile()); |
... | ... | |
1253 | 1267 | } |
1254 | 1268 | } |
1255 | 1269 | |
1270 | #ifdef PLATFORM_GP2X | |
1256 | 1271 | void GMenu2X::settingsOpen2x() { |
1257 | 1272 | SettingsDialog sd(this, input, ts, tr["Open2x Settings"]); |
1258 | 1273 | 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)); |
... | ... | |
1277 | 1292 | setVolume(confInt["globalVolume"]); |
1278 | 1293 | } |
1279 | 1294 | } |
1295 | #endif | |
1280 | 1296 | |
1281 | 1297 | void GMenu2X::skinMenu() { |
1282 | 1298 | FileLister fl_sk(getHome() + "/skins", true, false); |
... | ... | |
1307 | 1323 | } |
1308 | 1324 | |
1309 | 1325 | void GMenu2X::toggleTvOut() { |
1310 | #ifdef TARGET_GP2X | |
1326 | #ifdef PLATFORM_GP2X | |
1311 | 1327 | /* if (cx25874!=0) |
1312 | 1328 | gp2x_tvout_off(); |
1313 | 1329 | else |
... | ... | |
1501 | 1517 | s->flip(); |
1502 | 1518 | |
1503 | 1519 | //touchscreen |
1504 | if (f200) { | |
1520 | if (ts.initialized()) { | |
1505 | 1521 | ts.poll(); |
1506 | 1522 | if (ts.released()) { |
1507 | 1523 | if (!ts.inRect(box)) |
... | ... | |
1763 | 1779 | |
1764 | 1780 | uint lineY = 42; |
1765 | 1781 | |
1766 | #ifdef _TARGET_PANDORA | |
1782 | #ifdef PLATFORM_PANDORA | |
1767 | 1783 | //char *configpath = pnd_conf_query_searchpath(); |
1768 | 1784 | #else |
1769 | 1785 | if (confInt["menuClock"]<430) { |
... | ... | |
1782 | 1798 | vector<string> files; |
1783 | 1799 | scanPath(CARD_ROOT, &files); |
1784 | 1800 | |
1801 | const char *nandpath = NULL; | |
1802 | ||
1803 | #if defined(PLATFORM_GP2X) | |
1785 | 1804 | //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) { | |
1787 | 1812 | scanbg.write(font,tr["Scanning NAND filesystem..."],5,lineY); |
1788 | 1813 | scanbg.blit(s,0,0); |
1789 | 1814 | s->flip(); |
1790 | 1815 | lineY += 26; |
1791 | scanPath("/boot/local/nand",&files); | |
1816 | scanPath(nandpath, &files); | |
1792 | 1817 | } |
1793 | */ | |
1818 | ||
1794 | 1819 | stringstream ss; |
1795 | 1820 | ss << files.size(); |
1796 | 1821 | string str = ""; |
... | ... | |
1873 | 1898 | scanPath(filepath, files); |
1874 | 1899 | if (statRet != -1) { |
1875 | 1900 | 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") | |
1878 | 1905 | #else |
1879 | 1906 | if (ext==".pxml") |
1880 | 1907 | #endif |
... | ... | |
1886 | 1913 | } |
1887 | 1914 | |
1888 | 1915 | unsigned short GMenu2X::getBatteryLevel() { |
1889 | #ifdef TARGET_GP2X | |
1916 | #ifdef PLATFORM_GP2X | |
1890 | 1917 | /* if (batteryHandle<=0) return 0; |
1891 | 1918 | |
1892 | 1919 | if (f200) { |
... | ... | |
1919 | 1946 | if (battval>690) return 2; |
1920 | 1947 | if (battval>680) return 1; |
1921 | 1948 | }*/ |
1949 | ||
1950 | #else | |
1922 | 1951 | if (!batteryHandle) return 0; |
1923 | 1952 | int battval = 0; |
1924 | 1953 | char battvalcstr[5]; |
... | ... | |
1964 | 1993 | } |
1965 | 1994 | |
1966 | 1995 | void GMenu2X::applyRamTimings() { |
1967 | #ifdef TARGET_GP2X | |
1996 | #ifdef PLATFORM_GP2X | |
1968 | 1997 | // 6 4 1 1 1 2 2 |
1969 | 1998 | /* if (gp2x_mem!=0) { |
1970 | 1999 | int tRC = 5, tRAS = 3, tWR = 0, tMRD = 0, tRFC = 0, tRP = 1, tRCD = 1; |
... | ... | |
1975 | 2004 | } |
1976 | 2005 | |
1977 | 2006 | void GMenu2X::applyDefaultTimings() { |
1978 | #ifdef TARGET_GP2X | |
2007 | #ifdef PLATFORM_GP2X | |
1979 | 2008 | // 8 16 3 8 8 8 8 |
1980 | 2009 | /* if (gp2x_mem!=0) { |
1981 | 2010 | int tRC = 7, tRAS = 15, tWR = 2, tMRD = 7, tRFC = 7, tRP = 7, tRCD = 7; |
... | ... | |
1989 | 2018 | |
1990 | 2019 | void GMenu2X::setClock(unsigned mhz) { |
1991 | 2020 | mhz = constrain(mhz, 30, confInt["maxClock"]); |
1992 | #ifdef TARGET_GP2X | |
2021 | #if defined(PLATFORM_DINGUX) || defined(PLATFORM_NANONOTE) | |
1993 | 2022 | jz_cpuspeed(mhz); |
1994 | 2023 | #endif |
1995 | 2024 | } |
1996 | 2025 | |
1997 | 2026 | void GMenu2X::setGamma(int /*gamma*/) { |
1998 | #ifdef TARGET_GP2X | |
2027 | #ifdef PLATFORM_GP2X | |
1999 | 2028 | /* float fgamma = (float)constrain(gamma,1,100)/10; |
2000 | 2029 | fgamma = 1 / fgamma; |
2001 | 2030 | MEM_REG[0x2880>>1]&=~(1<<12); |
src/gmenu2x.h | ||
---|---|---|
136 | 136 | string ip, defaultgw, lastSelectorDir; |
137 | 137 | int lastSelectorElement; |
138 | 138 | void readConfig(); |
139 | void readConfigOpen2x(); | |
140 | 139 | void readTmp(); |
141 | void readCommonIni(); | |
142 | void writeCommonIni(); | |
143 | 140 | |
144 | 141 | void initServices(); |
145 | 142 | void initFont(); |
146 | 143 | void initMenu(); |
147 | 144 | |
148 | #ifdef TARGET_GP2X | |
145 | #ifdef PLATFORM_GP2X | |
146 | void readConfigOpen2x(); | |
147 | void readCommonIni(); | |
148 | void writeCommonIni(); | |
149 | ||
149 | 150 | unsigned long gp2x_mem; |
150 | 151 | unsigned short *gp2x_memregs; |
151 | 152 | volatile unsigned short *MEM_REG; |
152 | 153 | int cx25874; //tv-out |
153 | 154 | #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(); | |
158 | 160 | void toggleTvOut(); |
159 | 161 | |
160 | 162 | public: |
... | ... | |
191 | 193 | //Configuration settings |
192 | 194 | bool useSelectionPng; |
193 | 195 | void setSkin(const string &skin, bool setWallpaper = true); |
196 | ||
197 | #ifdef PLATFORM_GP2X | |
194 | 198 | //firmware type and version |
195 | 199 | string fwType, fwVersion; |
196 | //gp2x type | |
197 | bool f200; | |
200 | ||
201 | bool isF200() { return ts.initialized(); } | |
198 | 202 | |
199 | 203 | // Open2x settings --------------------------------------------------------- |
200 | 204 | 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; |
201 | 205 | string o2x_usb_net_ip; |
202 | 206 | int volumeMode, savedVolumeMode; // just use the const int scale values at top of source |
207 | #endif | |
203 | 208 | |
204 | 209 | // Volume scaling values to store from config files |
205 | 210 | int volumeScalerPhones; |
... | ... | |
214 | 219 | //Status functions |
215 | 220 | void main(); |
216 | 221 | void options(); |
222 | #ifdef PLATFORM_GP2X | |
217 | 223 | void settingsOpen2x(); |
224 | #endif | |
218 | 225 | void skinMenu(); |
226 | /* | |
219 | 227 | void activateSdUsb(); |
220 | 228 | void activateNandUsb(); |
221 | 229 | void activateRootUsb(); |
230 | */ | |
222 | 231 | void about(); |
223 | 232 | void viewLog(); |
224 | 233 | void contextMenu(); |
... | ... | |
241 | 250 | void setInputSpeed(); |
242 | 251 | |
243 | 252 | void writeConfig(); |
253 | #ifdef PLATFORM_GP2X | |
244 | 254 | void writeConfigOpen2x(); |
255 | #endif | |
245 | 256 | void writeSkinConfig(); |
246 | 257 | void writeTmp(int selelem=-1, const string &selectordir=""); |
247 | 258 |
src/inputdialog.cpp | ||
---|---|---|
160 | 160 | |
161 | 161 | if (caretOn) gmenu2x->s->box(box.x+box.w-12, box.y+3, 8, box.h-6, gmenu2x->skinConfColors[COLOR_SELECTION_BG]); |
162 | 162 | |
163 | if (gmenu2x->f200) ts.poll(); | |
163 | if (ts.initialized()) ts.poll(); | |
164 | 164 | action = drawVirtualKeyboard(); |
165 | 165 | gmenu2x->s->flip(); |
166 | 166 | |
... | ... | |
311 | 311 | SDL_Rect re = {kbLeft+xc*KEY_WIDTH-1, KB_TOP+l*KEY_HEIGHT, KEY_WIDTH-1, KEY_HEIGHT-2}; |
312 | 312 | |
313 | 313 | //if ts on rect, change selection |
314 | if (gmenu2x->f200 && ts.pressed() && ts.inRect(re)) { | |
314 | if (ts.initialized() && ts.pressed() && ts.inRect(re)) { | |
315 | 315 | selCol = xc; |
316 | 316 | selRow = l; |
317 | 317 | } |
... | ... | |
325 | 325 | //Ok/Cancel |
326 | 326 | SDL_Rect re = {kbLeft-1, KB_TOP+kb->size()*KEY_HEIGHT, kbLength*KEY_WIDTH/2-1, KEY_HEIGHT-1}; |
327 | 327 | 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)) { | |
329 | 329 | selCol = 0; |
330 | 330 | selRow = kb->size(); |
331 | 331 | } |
... | ... | |
333 | 333 | |
334 | 334 | re.x = kbLeft+kbLength*KEY_WIDTH/2-1; |
335 | 335 | 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)) { | |
337 | 337 | selCol = 1; |
338 | 338 | selRow = kb->size(); |
339 | 339 | } |
340 | 340 | 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); |
341 | 341 | |
342 | 342 | //if ts released |
343 | if (gmenu2x->f200 && ts.released() && ts.inRect(kbRect)) { | |
343 | if (ts.initialized() && ts.released() && ts.inRect(kbRect)) { | |
344 | 344 | action = ID_ACTION_SELECT; |
345 | 345 | } |
346 | 346 |
src/linkapp.cpp | ||
---|---|---|
215 | 215 | } |
216 | 216 | // /G |
217 | 217 | |
218 | bool LinkApp::targetExists() { | |
219 | #ifndef TARGET_GP2X | |
220 | return true; //For displaying elements during testing on pc | |
221 | #endif | |
222 | ||
218 | bool LinkApp::targetExists() | |
219 | { | |
223 | 220 | string target = exec; |
224 | 221 | if (!exec.empty() && exec[0]!='/' && !workdir.empty()) |
225 | 222 | target = workdir + "/" + exec; |
... | ... | |
417 | 414 | void LinkApp::launch(const string &selectedFile, const string &selectedDir) { |
418 | 415 | drawRun(); |
419 | 416 | save(); |
420 | #ifndef TARGET_GP2X | |
421 | //delay for testing | |
422 | SDL_Delay(1000); | |
423 | #endif | |
424 | 417 | |
425 | 418 | //Set correct working directory |
426 | 419 | string wd = workdir; |
... | ... | |
491 | 484 | } else { |
492 | 485 | if (gmenu2x->confInt["saveSelection"] && (gmenu2x->confInt["section"]!=gmenu2x->menu->selSectionIndex() || gmenu2x->confInt["link"]!=gmenu2x->menu->selLinkIndex())) |
493 | 486 | gmenu2x->writeConfig(); |
487 | ||
488 | #ifdef PLATFORM_GP2X | |
494 | 489 | if (gmenu2x->fwType == "open2x" && gmenu2x->savedVolumeMode != gmenu2x->volumeMode) |
495 | 490 | gmenu2x->writeConfigOpen2x(); |
491 | #endif | |
492 | ||
496 | 493 | if (selectedFile=="") |
497 | 494 | gmenu2x->writeTmp(); |
498 | 495 | gmenu2x->quit(); |
src/menusettingint.cpp | ||
---|---|---|
111 | 111 | |
112 | 112 | void MenuSettingInt::adjustInput() |
113 | 113 | { |
114 | #ifdef TARGET_GP2X | |
114 | #ifdef PLATFORM_GP2X | |
115 | 115 | // gmenu2x->input.setInterval(30, ACTION_LEFT ); |
116 | 116 | // gmenu2x->input.setInterval(30, ACTION_RIGHT); |
117 | 117 | #endif |
src/menusettingrgba.cpp | ||
---|---|---|
191 | 191 | |
192 | 192 | void MenuSettingRGBA::adjustInput() |
193 | 193 | { |
194 | #ifdef TARGET_GP2X | |
194 | #ifdef PLATFORM_GP2X | |
195 | 195 | /* |
196 | 196 | gmenu2x->input.setInterval(30, ACTION_Y ); |
197 | 197 | gmenu2x->input.setInterval(30, ACTION_X ); |
src/messagebox.cpp | ||
---|---|---|
105 | 105 | |
106 | 106 | bevent_t event; |
107 | 107 | while (result<0) { |
108 | ||
109 | #ifdef PLATFORM_GP2X | |
108 | 110 | //touchscreen |
109 | 111 | if (gmenu2x->f200) { |
110 | 112 | if (gmenu2x->ts.poll()) { |
... | ... | |
115 | 117 | } |
116 | 118 | } |
117 | 119 | } |
120 | #endif | |
121 | ||
118 | 122 | /* |
119 | 123 | gmenu2x->input.update(); |
120 | 124 | for (uint i=0; i<buttons.size(); i++) |
src/settingsdialog.cpp | ||
---|---|---|
59 | 59 | |
60 | 60 | while (!close) { |
61 | 61 | action = SD_NO_ACTION; |
62 | if (gmenu2x->f200) ts.poll(); | |
62 | if (ts.initialized()) ts.poll(); | |
63 | 63 | |
64 | 64 | bg.blit(gmenu2x->s,0,0); |
65 | 65 | |
... | ... | |
86 | 86 | |
87 | 87 | gmenu2x->s->setClipRect(clipRect); |
88 | 88 | 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; | |
90 | 90 | for (i=firstElement; i<voices.size() && i<firstElement+numRows; i++) { |
91 | 91 | iY = i-firstElement; |
92 | 92 | 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)) { | |
94 | 94 | ts_pressed = true; |
95 | 95 | sel = i; |
96 | 96 | } |
src/touchscreen.cpp | ||
---|---|---|
26 | 26 | using namespace std; |
27 | 27 | |
28 | 28 | Touchscreen::Touchscreen() { |
29 | wm97xx = 0; | |
29 | ts_fd = 0; | |
30 | 30 | calibrated = false; |
31 | 31 | wasPressed = false; |
32 | 32 | _handled = false; |
... | ... | |
40 | 40 | } |
41 | 41 | |
42 | 42 | Touchscreen::~Touchscreen() { |
43 | if (wm97xx) deinit(); | |
43 | deinit(); | |
44 | 44 | } |
45 | 45 | |
46 | 46 | bool 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); | |
49 | 49 | #endif |
50 | 50 | return initialized(); |
51 | 51 | } |
52 | 52 | |
53 | bool Touchscreen::initialized() { | |
54 | #ifdef TARGET_GP2X | |
55 | return wm97xx>0; | |
56 | #else | |
57 | return true; | |
58 | #endif | |
59 | } | |
60 | ||
61 | void Touchscreen::deinit() { | |
62 | #ifdef TARGET_GP2X | |
63 | close(wm97xx); | |
64 | wm97xx = 0; | |
65 | #endif | |
53 | void Touchscreen::deinit() | |
54 | { | |
55 | if (ts_fd) close(ts_fd); | |
56 | ts_fd = 0; | |
66 | 57 | } |
67 | 58 | |
68 | 59 | void Touchscreen::calibrate() { |
... | ... | |
75 | 66 | |
76 | 67 | bool Touchscreen::poll() { |
77 | 68 | 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)); | |
80 | 71 | if (!calibrated) calibrate(); |
81 | 72 | |
82 | 73 | if (event.pressure>0) { |
src/touchscreen.h | ||
---|---|---|
36 | 36 | |
37 | 37 | class Touchscreen { |
38 | 38 | private: |
39 | int wm97xx; | |
39 | int ts_fd; | |
40 | 40 | bool calibrated, _handled; |
41 | 41 | TS_EVENT event; |
42 | 42 | int calibX, calibY; |
... | ... | |
50 | 50 | ~Touchscreen(); |
51 | 51 | |
52 | 52 | bool init(); |
53 | bool initialized(); | |
54 | 53 | void deinit(); |
55 | 54 | |
55 | bool initialized() { | |
56 | #ifdef PLATFORM_GP2X | |
57 | return ts_fd>0; | |
58 | #endif | |
59 | return false; | |
60 | } | |
61 | ||
56 | 62 | bool poll(); |
57 | 63 | bool pressed(); |
58 | 64 | bool released(); |
Branches:
install_locations
master
opkrun
packages