1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-07-04 21:28:54 +03:00

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.
This commit is contained in:
Ayla 2011-07-29 01:13:35 +02:00
parent e066050c11
commit 5f77e3baf7
12 changed files with 138 additions and 100 deletions

View File

@ -29,7 +29,7 @@ noinst_HEADERS = asfont.h button.h cpu.h dirdialog.h FastDelegate.h \
AM_CFLAGS= @CFLAGS@ @SDL_CFLAGS@ AM_CFLAGS= @CFLAGS@ @SDL_CFLAGS@
AM_CXXFLAGS = @CXXFLAGS@ @SDL_CFLAGS@ -DTARGET_GP2X \ AM_CXXFLAGS = @CXXFLAGS@ @SDL_CFLAGS@ \
-fno-exceptions \ -fno-exceptions \
-Wall -Wextra -Wundef -Wunused-macros -Wall -Wextra -Wundef -Wunused-macros

View File

@ -58,7 +58,7 @@ bool BrowseDialog::exec()
selected = 0; selected = 0;
close = false; close = false;
while (!close) { while (!close) {
if (gmenu2x->f200) gmenu2x->ts.poll(); if (gmenu2x->ts.initialized()) gmenu2x->ts.poll();
paint(); paint();
@ -127,7 +127,7 @@ void BrowseDialog::handleInput()
action = getAction(&event); action = getAction(&event);
} }
if (gmenu2x->f200 && gmenu2x->ts.pressed() && !gmenu2x->ts.inRect(touchRect)) ts_pressed = false; if (gmenu2x->ts.initialized() && gmenu2x->ts.pressed() && !gmenu2x->ts.inRect(touchRect)) ts_pressed = false;
if (action == BrowseDialog::ACT_SELECT && (*fl)[selected] == "..") if (action == BrowseDialog::ACT_SELECT && (*fl)[selected] == "..")
action = BrowseDialog::ACT_GOUP; action = BrowseDialog::ACT_GOUP;
@ -262,7 +262,7 @@ void BrowseDialog::paint()
icon->blit(gmenu2x->s, 5, offsetY); icon->blit(gmenu2x->s, 5, offsetY);
gmenu2x->s->write(gmenu2x->font, (*fl)[i], 24, offsetY + 8, ASFont::HAlignLeft, ASFont::VAlignMiddle); gmenu2x->s->write(gmenu2x->font, (*fl)[i], 24, offsetY + 8, ASFont::HAlignLeft, ASFont::VAlignMiddle);
if (gmenu2x->f200 && gmenu2x->ts.pressed() && gmenu2x->ts.inRect(touchRect.x, offsetY + 3, touchRect.w, rowHeight)) { if (gmenu2x->ts.initialized() && gmenu2x->ts.pressed() && gmenu2x->ts.inRect(touchRect.x, offsetY + 3, touchRect.w, rowHeight)) {
ts_pressed = true; ts_pressed = true;
selected = i; selected = i;
} }

View File

@ -79,7 +79,7 @@
#include <sys/mman.h> #include <sys/mman.h>
#ifdef TARGET_PANDORA #ifdef PLATFORM_PANDORA
//#include <pnd_container.h> //#include <pnd_container.h>
//#include <pnd_conf.h> //#include <pnd_conf.h>
//#include <pnd_discovery.h> //#include <pnd_discovery.h>
@ -207,8 +207,8 @@ int main(int /*argc*/, char * /*argv*/[]) {
return 0; return 0;
} }
void GMenu2X::gp2x_init() { void GMenu2X::init() {
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
/* gp2x_mem = open("/dev/mem", O_RDWR); /* gp2x_mem = open("/dev/mem", O_RDWR);
gp2x_memregs=(unsigned short *)mmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, gp2x_mem, 0xc0000000); gp2x_memregs=(unsigned short *)mmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, gp2x_mem, 0xc0000000);
MEM_REG=&gp2x_memregs[0]; MEM_REG=&gp2x_memregs[0];
@ -216,6 +216,7 @@ void GMenu2X::gp2x_init() {
//if wm97xx fails to open, set f200 to false to prevent any further access to the touchscreen //if wm97xx fails to open, set f200 to false to prevent any further access to the touchscreen
f200 = ts.init(); f200 = ts.init();
}*/ }*/
#else
batteryHandle = fopen("/sys/class/power_supply/battery/capacity", "r"); batteryHandle = fopen("/sys/class/power_supply/battery/capacity", "r");
usbHandle = fopen("/sys/class/power_supply/USB/online", "r"); usbHandle = fopen("/sys/class/power_supply/USB/online", "r");
acHandle = fopen("/sys/class/power_supply/ac/online", "r"); acHandle = fopen("/sys/class/power_supply/ac/online", "r");
@ -224,8 +225,8 @@ void GMenu2X::gp2x_init() {
#endif #endif
} }
void GMenu2X::gp2x_deinit() { void GMenu2X::deinit() {
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
/* if (gp2x_mem!=0) { /* if (gp2x_mem!=0) {
gp2x_memregs[0x28DA>>1]=0x4AB; gp2x_memregs[0x28DA>>1]=0x4AB;
gp2x_memregs[0x290C>>1]=640; gp2x_memregs[0x290C>>1]=640;
@ -233,15 +234,16 @@ void GMenu2X::gp2x_deinit() {
} }
if (f200) ts.deinit();*/ if (f200) ts.deinit();*/
#endif #else
if (batteryHandle) fclose(batteryHandle); if (batteryHandle) fclose(batteryHandle);
if (backlightHandle) fclose(backlightHandle); if (backlightHandle) fclose(backlightHandle);
if (usbHandle) fclose(usbHandle); if (usbHandle) fclose(usbHandle);
if (acHandle) fclose(acHandle); if (acHandle) fclose(acHandle);
#endif
} }
void GMenu2X::gp2x_tvout_on(bool /*pal*/) { void GMenu2X::tvout_on(bool /*pal*/) {
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
/* if (gp2x_mem!=0) { /* if (gp2x_mem!=0) {
// Ioctl_Dummy_t *msg; // Ioctl_Dummy_t *msg;
// int TVHandle = ioctl(SDL_videofd, FBMMSP2CTRL, msg); // int TVHandle = ioctl(SDL_videofd, FBMMSP2CTRL, msg);
@ -257,8 +259,8 @@ void GMenu2X::gp2x_tvout_on(bool /*pal*/) {
#endif #endif
} }
void GMenu2X::gp2x_tvout_off() { void GMenu2X::tvout_off() {
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
/* if (gp2x_mem!=0) { /* if (gp2x_mem!=0) {
close(cx25874); close(cx25874);
cx25874 = 0; cx25874 = 0;
@ -268,7 +270,9 @@ void GMenu2X::gp2x_tvout_off() {
} }
GMenu2X::GMenu2X() { GMenu2X::GMenu2X()
{
#ifdef PLATFORM_GP2X
//Detect firmware version and type //Detect firmware version and type
if (fileExists("/etc/open2x")) { if (fileExists("/etc/open2x")) {
fwType = "open2x"; fwType = "open2x";
@ -277,11 +281,6 @@ GMenu2X::GMenu2X() {
fwType = "gph"; fwType = "gph";
fwVersion = ""; fwVersion = "";
} }
#ifdef TARGET_GP2X
f200 = fileExists("/dev/touchscreen/wm97xx");
#else
f200 = true;
#endif
//open2x //open2x
savedVolumeMode = 0; savedVolumeMode = 0;
@ -297,12 +296,15 @@ GMenu2X::GMenu2X() {
o2x_usb_host_on_boot = false; o2x_usb_host_on_boot = false;
o2x_usb_hid_on_boot = false; o2x_usb_hid_on_boot = false;
o2x_usb_storage_on_boot = false; o2x_usb_storage_on_boot = false;
#endif
usbnet = samba = inet = web = false; usbnet = samba = inet = web = false;
useSelectionPng = false; useSelectionPng = false;
//load config data //load config data
readConfig(); readConfig();
#ifdef PLATFORM_GP2X
if (fwType=="open2x") { if (fwType=="open2x") {
readConfigOpen2x(); readConfigOpen2x();
// VOLUME MODIFIER // VOLUME MODIFIER
@ -313,6 +315,7 @@ GMenu2X::GMenu2X() {
} }
} else } else
readCommonIni(); readCommonIni();
#endif
halfX = resX/2; halfX = resX/2;
halfY = resY/2; halfY = resY/2;
@ -327,11 +330,10 @@ GMenu2X::GMenu2X() {
usbHandle = 0; usbHandle = 0;
acHandle = 0; acHandle = 0;
init();
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
gp2x_mem = 0;
cx25874 = 0; cx25874 = 0;
gp2x_init();
//Fix tv-out //Fix tv-out
/* if (gp2x_mem!=0) { /* if (gp2x_mem!=0) {
@ -403,7 +405,10 @@ GMenu2X::GMenu2X() {
GMenu2X::~GMenu2X() { GMenu2X::~GMenu2X() {
writeConfig(); writeConfig();
#ifdef PLATFORM_GP2X
if (fwType=="open2x") writeConfigOpen2x(); if (fwType=="open2x") writeConfigOpen2x();
#endif
quit(); quit();
@ -420,7 +425,7 @@ void GMenu2X::quit() {
unsetenv("SDL_FBCON_DONT_CLEAR"); unsetenv("SDL_FBCON_DONT_CLEAR");
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
/* if (gp2x_mem!=0) { /* if (gp2x_mem!=0) {
//Fix tv-out //Fix tv-out
if (gp2x_memregs[0x2800>>1]&0x100) { if (gp2x_memregs[0x2800>>1]&0x100) {
@ -521,11 +526,11 @@ void GMenu2X::initMenu() {
//Add virtual links in the setting section //Add virtual links in the setting section
else if (menu->getSections()[i]=="settings") { else if (menu->getSections()[i]=="settings") {
menu->addActionLink(i,"GMenu2X",MakeDelegate(this,&GMenu2X::options),tr["Configure GMenu2X's options"],"skin:icons/configure.png"); menu->addActionLink(i,"GMenu2X",MakeDelegate(this,&GMenu2X::options),tr["Configure GMenu2X's options"],"skin:icons/configure.png");
if (fwType=="open2x")
menu->addActionLink(i,"Open2x",MakeDelegate(this,&GMenu2X::settingsOpen2x),tr["Configure Open2x system settings"],"skin:icons/o2xconfigure.png");
menu->addActionLink(i,tr["Skin"],MakeDelegate(this,&GMenu2X::skinMenu),tr["Configure skin"],"skin:icons/skin.png"); menu->addActionLink(i,tr["Skin"],MakeDelegate(this,&GMenu2X::skinMenu),tr["Configure skin"],"skin:icons/skin.png");
menu->addActionLink(i,tr["Wallpaper"],MakeDelegate(this,&GMenu2X::changeWallpaper),tr["Change GMenu2X wallpaper"],"skin:icons/wallpaper.png"); menu->addActionLink(i,tr["Wallpaper"],MakeDelegate(this,&GMenu2X::changeWallpaper),tr["Change GMenu2X wallpaper"],"skin:icons/wallpaper.png");
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
if (fwType=="open2x")
menu->addActionLink(i,"Open2x",MakeDelegate(this,&GMenu2X::settingsOpen2x),tr["Configure Open2x system settings"],"skin:icons/o2xconfigure.png");
/* menu->addActionLink(i,"TV",MakeDelegate(this,&GMenu2X::toggleTvOut),tr["Activate/deactivate tv-out"],"skin:icons/tv.png"); /* menu->addActionLink(i,"TV",MakeDelegate(this,&GMenu2X::toggleTvOut),tr["Activate/deactivate tv-out"],"skin:icons/tv.png");
menu->addActionLink(i,"USB Sd",MakeDelegate(this,&GMenu2X::activateSdUsb),tr["Activate Usb on SD"],"skin:icons/usb.png"); menu->addActionLink(i,"USB Sd",MakeDelegate(this,&GMenu2X::activateSdUsb),tr["Activate Usb on SD"],"skin:icons/usb.png");
if (fwType=="gph" && !f200) if (fwType=="gph" && !f200)
@ -686,7 +691,7 @@ void GMenu2X::writeConfig() {
ledOff(); ledOff();
} }
#ifdef PLATFORM_GP2X
void GMenu2X::readConfigOpen2x() { void GMenu2X::readConfigOpen2x() {
string conffile = "/etc/config/open2x.conf"; string conffile = "/etc/config/open2x.conf";
if (fileExists(conffile)) { if (fileExists(conffile)) {
@ -735,6 +740,7 @@ void GMenu2X::writeConfigOpen2x() {
} }
ledOff(); ledOff();
} }
#endif
void GMenu2X::writeSkinConfig() { void GMenu2X::writeSkinConfig() {
ledOn(); ledOn();
@ -776,6 +782,7 @@ void GMenu2X::writeSkinConfig() {
ledOff(); ledOff();
} }
#ifdef PLATFORM_GP2X
void GMenu2X::readCommonIni() { void GMenu2X::readCommonIni() {
if (fileExists("/usr/gp2x/common.ini")) { if (fileExists("/usr/gp2x/common.ini")) {
ifstream inf("/usr/gp2x/common.ini", ios_base::in); ifstream inf("/usr/gp2x/common.ini", ios_base::in);
@ -813,6 +820,7 @@ void GMenu2X::readCommonIni() {
} }
void GMenu2X::writeCommonIni() {} void GMenu2X::writeCommonIni() {}
#endif
void GMenu2X::readTmp() { void GMenu2X::readTmp() {
lastSelectorElement = -1; lastSelectorElement = -1;
@ -856,7 +864,7 @@ void GMenu2X::writeTmp(int selelem, const string &selectordir) {
} }
void GMenu2X::initServices() { void GMenu2X::initServices() {
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
/* if (usbnet) { /* if (usbnet) {
string services = "scripts/services.sh "+ip+" "+(inet?"on":"off")+" "+(samba?"on":"off")+" "+(web?"on":"off")+" &"; string services = "scripts/services.sh "+ip+" "+(inet?"on":"off")+" "+(samba?"on":"off")+" "+(web?"on":"off")+" &";
system(services.c_str()); system(services.c_str());
@ -865,14 +873,14 @@ void GMenu2X::initServices() {
} }
void GMenu2X::ledOn() { void GMenu2X::ledOn() {
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
// if (gp2x_mem!=0 && !f200) gp2x_memregs[0x106E >> 1] ^= 16; // if (gp2x_mem!=0 && !f200) gp2x_memregs[0x106E >> 1] ^= 16;
//SDL_SYS_JoystickGp2xSys(joy.joystick, BATT_LED_ON); //SDL_SYS_JoystickGp2xSys(joy.joystick, BATT_LED_ON);
#endif #endif
} }
void GMenu2X::ledOff() { void GMenu2X::ledOff() {
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
// if (gp2x_mem!=0 && !f200) gp2x_memregs[0x106E >> 1] ^= 16; // if (gp2x_mem!=0 && !f200) gp2x_memregs[0x106E >> 1] ^= 16;
//SDL_SYS_JoystickGp2xSys(joy.joystick, BATT_LED_OFF); //SDL_SYS_JoystickGp2xSys(joy.joystick, BATT_LED_OFF);
#endif #endif
@ -906,7 +914,12 @@ void GMenu2X::main() {
uint sectionLinkPadding = (skinConfInt["topBarHeight"] - 32 - font->getLineHeight()) / 3; uint sectionLinkPadding = (skinConfInt["topBarHeight"] - 32 - font->getLineHeight()) / 3;
bool quit = false; bool quit = false;
int x,y, offset = menu->sectionLinks()->size()>linksPerPage ? 2 : 6, helpBoxHeight = fwType=="open2x" ? 154 : 139; int x,y, offset = menu->sectionLinks()->size()>linksPerPage ? 2 : 6;
#ifdef PLATFORM_GP2X
int helpBoxHeight = fwType=="open2x" ? 154 : 139;
#else
int helpBoxHeight = 154;
#endif
uint i; uint i;
long tickBattery = -60000, tickNow; long tickBattery = -60000, tickNow;
string batteryIcon = "imgs/battery/0.png"; string batteryIcon = "imgs/battery/0.png";
@ -994,7 +1007,7 @@ void GMenu2X::main() {
} }
} }
if (f200) { if (ts.initialized()) {
btnContextMenu.paint(); btnContextMenu.paint();
} }
//check battery status every 60 seconds //check battery status every 60 seconds
@ -1027,8 +1040,9 @@ void GMenu2X::main() {
s->write( font, tr["A+VOLUP, A+VOLDOWN: Change volume"], 20, 140 ); s->write( font, tr["A+VOLUP, A+VOLDOWN: Change volume"], 20, 140 );
s->write( font, tr["SELECT: Show contextual menu"], 20, 155 ); s->write( font, tr["SELECT: Show contextual menu"], 20, 155 );
s->write( font, tr["START: Show options menu"], 20, 170 ); s->write( font, tr["START: Show options menu"], 20, 170 );
#ifdef PLATFORM_GP2X
if (fwType=="open2x") s->write( font, tr["X: Toggle speaker mode"], 20, 185 ); if (fwType=="open2x") s->write( font, tr["X: Toggle speaker mode"], 20, 185 );
#endif
} }
#ifdef WITH_DEBUG #ifdef WITH_DEBUG
@ -1047,7 +1061,7 @@ void GMenu2X::main() {
s->flip(); s->flip();
//touchscreen //touchscreen
if (f200) { if (ts.initialized()) {
ts.poll(); ts.poll();
btnContextMenu.handleTS(); btnContextMenu.handleTS();
re.x = 0; re.y = 0; re.h = skinConfInt["topBarHeight"]; re.w = resX; re.x = 0; re.y = 0; re.h = skinConfInt["topBarHeight"]; re.w = resX;
@ -1074,8 +1088,6 @@ void GMenu2X::main() {
} }
} }
//#ifdef TARGET_GP2X
switch (input.waitForPressedButton()) { switch (input.waitForPressedButton()) {
case ACCEPT: case ACCEPT:
if (menu->selLink() != NULL) menu->selLink()->run(); if (menu->selLink() != NULL) menu->selLink()->run();
@ -1183,8 +1195,10 @@ void GMenu2X::explorer() {
if (fd.exec()) { if (fd.exec()) {
if (confInt["saveSelection"] && (confInt["section"]!=menu->selSectionIndex() || confInt["link"]!=menu->selLinkIndex())) if (confInt["saveSelection"] && (confInt["section"]!=menu->selSectionIndex() || confInt["link"]!=menu->selLinkIndex()))
writeConfig(); writeConfig();
#ifdef PLATFORM_GP2X
if (fwType == "open2x" && savedVolumeMode != volumeMode) if (fwType == "open2x" && savedVolumeMode != volumeMode)
writeConfigOpen2x(); writeConfigOpen2x();
#endif
//string command = cmdclean(fd.path()+"/"+fd.file) + "; sync & cd "+cmdclean(getExePath())+"; exec ./gmenu2x"; //string command = cmdclean(fd.path()+"/"+fd.file) + "; sync & cd "+cmdclean(getExePath())+"; exec ./gmenu2x";
string command = cmdclean(fd.getPath()+"/"+fd.getFile()); string command = cmdclean(fd.getPath()+"/"+fd.getFile());
@ -1253,6 +1267,7 @@ void GMenu2X::options() {
} }
} }
#ifdef PLATFORM_GP2X
void GMenu2X::settingsOpen2x() { void GMenu2X::settingsOpen2x() {
SettingsDialog sd(this, input, ts, tr["Open2x Settings"]); SettingsDialog sd(this, input, ts, tr["Open2x Settings"]);
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)); 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,6 +1292,7 @@ void GMenu2X::settingsOpen2x() {
setVolume(confInt["globalVolume"]); setVolume(confInt["globalVolume"]);
} }
} }
#endif
void GMenu2X::skinMenu() { void GMenu2X::skinMenu() {
FileLister fl_sk(getHome() + "/skins", true, false); FileLister fl_sk(getHome() + "/skins", true, false);
@ -1307,7 +1323,7 @@ void GMenu2X::skinMenu() {
} }
void GMenu2X::toggleTvOut() { void GMenu2X::toggleTvOut() {
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
/* if (cx25874!=0) /* if (cx25874!=0)
gp2x_tvout_off(); gp2x_tvout_off();
else else
@ -1501,7 +1517,7 @@ void GMenu2X::contextMenu() {
s->flip(); s->flip();
//touchscreen //touchscreen
if (f200) { if (ts.initialized()) {
ts.poll(); ts.poll();
if (ts.released()) { if (ts.released()) {
if (!ts.inRect(box)) if (!ts.inRect(box))
@ -1763,7 +1779,7 @@ void GMenu2X::scanner() {
uint lineY = 42; uint lineY = 42;
#ifdef _TARGET_PANDORA #ifdef PLATFORM_PANDORA
//char *configpath = pnd_conf_query_searchpath(); //char *configpath = pnd_conf_query_searchpath();
#else #else
if (confInt["menuClock"]<430) { if (confInt["menuClock"]<430) {
@ -1782,15 +1798,24 @@ void GMenu2X::scanner() {
vector<string> files; vector<string> files;
scanPath(CARD_ROOT, &files); scanPath(CARD_ROOT, &files);
const char *nandpath = NULL;
#if defined(PLATFORM_GP2X)
//Onyl gph firmware has nand //Onyl gph firmware has nand
/* if (fwType=="gph" && !f200) { if (fwType=="gph" && !isF200())
nandpath = "/boot/local/nand";
#elif defined(PLATFORM_DINGUX)
nandpath = "/media/ccnandb1";
#endif
if (nandpath) {
scanbg.write(font,tr["Scanning NAND filesystem..."],5,lineY); scanbg.write(font,tr["Scanning NAND filesystem..."],5,lineY);
scanbg.blit(s,0,0); scanbg.blit(s,0,0);
s->flip(); s->flip();
lineY += 26; lineY += 26;
scanPath("/boot/local/nand",&files); scanPath(nandpath, &files);
} }
*/
stringstream ss; stringstream ss;
ss << files.size(); ss << files.size();
string str = ""; string str = "";
@ -1873,8 +1898,10 @@ void GMenu2X::scanPath(string path, vector<string> *files) {
scanPath(filepath, files); scanPath(filepath, files);
if (statRet != -1) { if (statRet != -1) {
ext = filepath.substr(filepath.length()-4,4); ext = filepath.substr(filepath.length()-4,4);
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
if (ext==".gpu" || ext==".dge") if (ext==".gpu")
#elif defined(PLATFORM_DINGUX) || defined(PLATFORM_NANONOTE)
if (ext==".dge")
#else #else
if (ext==".pxml") if (ext==".pxml")
#endif #endif
@ -1886,7 +1913,7 @@ void GMenu2X::scanPath(string path, vector<string> *files) {
} }
unsigned short GMenu2X::getBatteryLevel() { unsigned short GMenu2X::getBatteryLevel() {
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
/* if (batteryHandle<=0) return 0; /* if (batteryHandle<=0) return 0;
if (f200) { if (f200) {
@ -1919,6 +1946,8 @@ unsigned short GMenu2X::getBatteryLevel() {
if (battval>690) return 2; if (battval>690) return 2;
if (battval>680) return 1; if (battval>680) return 1;
}*/ }*/
#else
if (!batteryHandle) return 0; if (!batteryHandle) return 0;
int battval = 0; int battval = 0;
char battvalcstr[5]; char battvalcstr[5];
@ -1964,7 +1993,7 @@ void GMenu2X::setInputSpeed() {
} }
void GMenu2X::applyRamTimings() { void GMenu2X::applyRamTimings() {
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
// 6 4 1 1 1 2 2 // 6 4 1 1 1 2 2
/* if (gp2x_mem!=0) { /* if (gp2x_mem!=0) {
int tRC = 5, tRAS = 3, tWR = 0, tMRD = 0, tRFC = 0, tRP = 1, tRCD = 1; int tRC = 5, tRAS = 3, tWR = 0, tMRD = 0, tRFC = 0, tRP = 1, tRCD = 1;
@ -1975,7 +2004,7 @@ void GMenu2X::applyRamTimings() {
} }
void GMenu2X::applyDefaultTimings() { void GMenu2X::applyDefaultTimings() {
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
// 8 16 3 8 8 8 8 // 8 16 3 8 8 8 8
/* if (gp2x_mem!=0) { /* if (gp2x_mem!=0) {
int tRC = 7, tRAS = 15, tWR = 2, tMRD = 7, tRFC = 7, tRP = 7, tRCD = 7; int tRC = 7, tRAS = 15, tWR = 2, tMRD = 7, tRFC = 7, tRP = 7, tRCD = 7;
@ -1989,13 +2018,13 @@ void GMenu2X::applyDefaultTimings() {
void GMenu2X::setClock(unsigned mhz) { void GMenu2X::setClock(unsigned mhz) {
mhz = constrain(mhz, 30, confInt["maxClock"]); mhz = constrain(mhz, 30, confInt["maxClock"]);
#ifdef TARGET_GP2X #if defined(PLATFORM_DINGUX) || defined(PLATFORM_NANONOTE)
jz_cpuspeed(mhz); jz_cpuspeed(mhz);
#endif #endif
} }
void GMenu2X::setGamma(int /*gamma*/) { void GMenu2X::setGamma(int /*gamma*/) {
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
/* float fgamma = (float)constrain(gamma,1,100)/10; /* float fgamma = (float)constrain(gamma,1,100)/10;
fgamma = 1 / fgamma; fgamma = 1 / fgamma;
MEM_REG[0x2880>>1]&=~(1<<12); MEM_REG[0x2880>>1]&=~(1<<12);

View File

@ -136,25 +136,27 @@ private:
string ip, defaultgw, lastSelectorDir; string ip, defaultgw, lastSelectorDir;
int lastSelectorElement; int lastSelectorElement;
void readConfig(); void readConfig();
void readConfigOpen2x();
void readTmp(); void readTmp();
void readCommonIni();
void writeCommonIni();
void initServices(); void initServices();
void initFont(); void initFont();
void initMenu(); void initMenu();
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
void readConfigOpen2x();
void readCommonIni();
void writeCommonIni();
unsigned long gp2x_mem; unsigned long gp2x_mem;
unsigned short *gp2x_memregs; unsigned short *gp2x_memregs;
volatile unsigned short *MEM_REG; volatile unsigned short *MEM_REG;
int cx25874; //tv-out int cx25874; //tv-out
#endif #endif
void gp2x_tvout_on(bool pal);
void gp2x_tvout_off(); void tvout_on(bool pal);
void gp2x_init(); void tvout_off();
void gp2x_deinit(); void init();
void deinit();
void toggleTvOut(); void toggleTvOut();
public: public:
@ -191,15 +193,18 @@ public:
//Configuration settings //Configuration settings
bool useSelectionPng; bool useSelectionPng;
void setSkin(const string &skin, bool setWallpaper = true); void setSkin(const string &skin, bool setWallpaper = true);
#ifdef PLATFORM_GP2X
//firmware type and version //firmware type and version
string fwType, fwVersion; string fwType, fwVersion;
//gp2x type
bool f200; bool isF200() { return ts.initialized(); }
// Open2x settings --------------------------------------------------------- // Open2x settings ---------------------------------------------------------
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; 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;
string o2x_usb_net_ip; string o2x_usb_net_ip;
int volumeMode, savedVolumeMode; // just use the const int scale values at top of source int volumeMode, savedVolumeMode; // just use the const int scale values at top of source
#endif
// Volume scaling values to store from config files // Volume scaling values to store from config files
int volumeScalerPhones; int volumeScalerPhones;
@ -214,11 +219,15 @@ public:
//Status functions //Status functions
void main(); void main();
void options(); void options();
#ifdef PLATFORM_GP2X
void settingsOpen2x(); void settingsOpen2x();
#endif
void skinMenu(); void skinMenu();
/*
void activateSdUsb(); void activateSdUsb();
void activateNandUsb(); void activateNandUsb();
void activateRootUsb(); void activateRootUsb();
*/
void about(); void about();
void viewLog(); void viewLog();
void contextMenu(); void contextMenu();
@ -241,7 +250,9 @@ public:
void setInputSpeed(); void setInputSpeed();
void writeConfig(); void writeConfig();
#ifdef PLATFORM_GP2X
void writeConfigOpen2x(); void writeConfigOpen2x();
#endif
void writeSkinConfig(); void writeSkinConfig();
void writeTmp(int selelem=-1, const string &selectordir=""); void writeTmp(int selelem=-1, const string &selectordir="");

View File

@ -160,7 +160,7 @@ bool InputDialog::exec() {
if (caretOn) gmenu2x->s->box(box.x+box.w-12, box.y+3, 8, box.h-6, gmenu2x->skinConfColors[COLOR_SELECTION_BG]); if (caretOn) gmenu2x->s->box(box.x+box.w-12, box.y+3, 8, box.h-6, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
if (gmenu2x->f200) ts.poll(); if (ts.initialized()) ts.poll();
action = drawVirtualKeyboard(); action = drawVirtualKeyboard();
gmenu2x->s->flip(); gmenu2x->s->flip();
@ -311,7 +311,7 @@ int InputDialog::drawVirtualKeyboard() {
SDL_Rect re = {kbLeft+xc*KEY_WIDTH-1, KB_TOP+l*KEY_HEIGHT, KEY_WIDTH-1, KEY_HEIGHT-2}; SDL_Rect re = {kbLeft+xc*KEY_WIDTH-1, KB_TOP+l*KEY_HEIGHT, KEY_WIDTH-1, KEY_HEIGHT-2};
//if ts on rect, change selection //if ts on rect, change selection
if (gmenu2x->f200 && ts.pressed() && ts.inRect(re)) { if (ts.initialized() && ts.pressed() && ts.inRect(re)) {
selCol = xc; selCol = xc;
selRow = l; selRow = l;
} }
@ -325,7 +325,7 @@ int InputDialog::drawVirtualKeyboard() {
//Ok/Cancel //Ok/Cancel
SDL_Rect re = {kbLeft-1, KB_TOP+kb->size()*KEY_HEIGHT, kbLength*KEY_WIDTH/2-1, KEY_HEIGHT-1}; SDL_Rect re = {kbLeft-1, KB_TOP+kb->size()*KEY_HEIGHT, kbLength*KEY_WIDTH/2-1, KEY_HEIGHT-1};
gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]); gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
if (gmenu2x->f200 && ts.pressed() && ts.inRect(re)) { if (ts.initialized() && ts.pressed() && ts.inRect(re)) {
selCol = 0; selCol = 0;
selRow = kb->size(); selRow = kb->size();
} }
@ -333,14 +333,14 @@ int InputDialog::drawVirtualKeyboard() {
re.x = kbLeft+kbLength*KEY_WIDTH/2-1; re.x = kbLeft+kbLength*KEY_WIDTH/2-1;
gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]); gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
if (gmenu2x->f200 && ts.pressed() && ts.inRect(re)) { if (ts.initialized() && ts.pressed() && ts.inRect(re)) {
selCol = 1; selCol = 1;
selRow = kb->size(); selRow = kb->size();
} }
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); 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);
//if ts released //if ts released
if (gmenu2x->f200 && ts.released() && ts.inRect(kbRect)) { if (ts.initialized() && ts.released() && ts.inRect(kbRect)) {
action = ID_ACTION_SELECT; action = ID_ACTION_SELECT;
} }

View File

@ -215,11 +215,8 @@ void LinkApp::setGamma(int gamma) {
} }
// /G // /G
bool LinkApp::targetExists() { bool LinkApp::targetExists()
#ifndef TARGET_GP2X {
return true; //For displaying elements during testing on pc
#endif
string target = exec; string target = exec;
if (!exec.empty() && exec[0]!='/' && !workdir.empty()) if (!exec.empty() && exec[0]!='/' && !workdir.empty())
target = workdir + "/" + exec; target = workdir + "/" + exec;
@ -417,10 +414,6 @@ void LinkApp::selector(int startSelection, const string &selectorDir) {
void LinkApp::launch(const string &selectedFile, const string &selectedDir) { void LinkApp::launch(const string &selectedFile, const string &selectedDir) {
drawRun(); drawRun();
save(); save();
#ifndef TARGET_GP2X
//delay for testing
SDL_Delay(1000);
#endif
//Set correct working directory //Set correct working directory
string wd = workdir; string wd = workdir;
@ -491,8 +484,12 @@ void LinkApp::launch(const string &selectedFile, const string &selectedDir) {
} else { } else {
if (gmenu2x->confInt["saveSelection"] && (gmenu2x->confInt["section"]!=gmenu2x->menu->selSectionIndex() || gmenu2x->confInt["link"]!=gmenu2x->menu->selLinkIndex())) if (gmenu2x->confInt["saveSelection"] && (gmenu2x->confInt["section"]!=gmenu2x->menu->selSectionIndex() || gmenu2x->confInt["link"]!=gmenu2x->menu->selLinkIndex()))
gmenu2x->writeConfig(); gmenu2x->writeConfig();
#ifdef PLATFORM_GP2X
if (gmenu2x->fwType == "open2x" && gmenu2x->savedVolumeMode != gmenu2x->volumeMode) if (gmenu2x->fwType == "open2x" && gmenu2x->savedVolumeMode != gmenu2x->volumeMode)
gmenu2x->writeConfigOpen2x(); gmenu2x->writeConfigOpen2x();
#endif
if (selectedFile=="") if (selectedFile=="")
gmenu2x->writeTmp(); gmenu2x->writeTmp();
gmenu2x->quit(); gmenu2x->quit();

View File

@ -111,7 +111,7 @@ int MenuSettingInt::value()
void MenuSettingInt::adjustInput() void MenuSettingInt::adjustInput()
{ {
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
// gmenu2x->input.setInterval(30, ACTION_LEFT ); // gmenu2x->input.setInterval(30, ACTION_LEFT );
// gmenu2x->input.setInterval(30, ACTION_RIGHT); // gmenu2x->input.setInterval(30, ACTION_RIGHT);
#endif #endif

View File

@ -191,7 +191,7 @@ unsigned short MenuSettingRGBA::getSelPart()
void MenuSettingRGBA::adjustInput() void MenuSettingRGBA::adjustInput()
{ {
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
/* /*
gmenu2x->input.setInterval(30, ACTION_Y ); gmenu2x->input.setInterval(30, ACTION_Y );
gmenu2x->input.setInterval(30, ACTION_X ); gmenu2x->input.setInterval(30, ACTION_X );

View File

@ -105,6 +105,8 @@ int MessageBox::exec() {
bevent_t event; bevent_t event;
while (result<0) { while (result<0) {
#ifdef PLATFORM_GP2X
//touchscreen //touchscreen
if (gmenu2x->f200) { if (gmenu2x->f200) {
if (gmenu2x->ts.poll()) { if (gmenu2x->ts.poll()) {
@ -115,6 +117,8 @@ int MessageBox::exec() {
} }
} }
} }
#endif
/* /*
gmenu2x->input.update(); gmenu2x->input.update();
for (uint i=0; i<buttons.size(); i++) for (uint i=0; i<buttons.size(); i++)

View File

@ -59,7 +59,7 @@ bool SettingsDialog::exec() {
while (!close) { while (!close) {
action = SD_NO_ACTION; action = SD_NO_ACTION;
if (gmenu2x->f200) ts.poll(); if (ts.initialized()) ts.poll();
bg.blit(gmenu2x->s,0,0); bg.blit(gmenu2x->s,0,0);
@ -86,11 +86,11 @@ bool SettingsDialog::exec() {
gmenu2x->s->setClipRect(clipRect); gmenu2x->s->setClipRect(clipRect);
if (ts_pressed && !ts.pressed()) ts_pressed = false; if (ts_pressed && !ts.pressed()) ts_pressed = false;
if (gmenu2x->f200 && ts.pressed() && !ts.inRect(touchRect)) ts_pressed = false; if (ts.initialized() && ts.pressed() && !ts.inRect(touchRect)) ts_pressed = false;
for (i=firstElement; i<voices.size() && i<firstElement+numRows; i++) { for (i=firstElement; i<voices.size() && i<firstElement+numRows; i++) {
iY = i-firstElement; iY = i-firstElement;
voices[i]->draw(iY*rowHeight+gmenu2x->skinConfInt["topBarHeight"]+2); voices[i]->draw(iY*rowHeight+gmenu2x->skinConfInt["topBarHeight"]+2);
if (gmenu2x->f200 && ts.pressed() && ts.inRect(touchRect.x, touchRect.y+(iY*rowHeight), touchRect.w, rowHeight)) { if (ts.initialized() && ts.pressed() && ts.inRect(touchRect.x, touchRect.y+(iY*rowHeight), touchRect.w, rowHeight)) {
ts_pressed = true; ts_pressed = true;
sel = i; sel = i;
} }

View File

@ -26,7 +26,7 @@
using namespace std; using namespace std;
Touchscreen::Touchscreen() { Touchscreen::Touchscreen() {
wm97xx = 0; ts_fd = 0;
calibrated = false; calibrated = false;
wasPressed = false; wasPressed = false;
_handled = false; _handled = false;
@ -40,29 +40,20 @@ Touchscreen::Touchscreen() {
} }
Touchscreen::~Touchscreen() { Touchscreen::~Touchscreen() {
if (wm97xx) deinit(); deinit();
} }
bool Touchscreen::init() { bool Touchscreen::init() {
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
wm97xx = open("/dev/touchscreen/wm97xx", O_RDONLY|O_NOCTTY); ts_fd = open("/dev/touchscreen/wm97xx", O_RDONLY|O_NOCTTY);
#endif #endif
return initialized(); return initialized();
} }
bool Touchscreen::initialized() { void Touchscreen::deinit()
#ifdef TARGET_GP2X {
return wm97xx>0; if (ts_fd) close(ts_fd);
#else ts_fd = 0;
return true;
#endif
}
void Touchscreen::deinit() {
#ifdef TARGET_GP2X
close(wm97xx);
wm97xx = 0;
#endif
} }
void Touchscreen::calibrate() { void Touchscreen::calibrate() {
@ -75,8 +66,8 @@ void Touchscreen::calibrate() {
bool Touchscreen::poll() { bool Touchscreen::poll() {
wasPressed = pressed(); wasPressed = pressed();
#ifdef TARGET_GP2X #ifdef PLATFORM_GP2X
read(wm97xx, &event, sizeof(TS_EVENT)); read(ts_fd, &event, sizeof(TS_EVENT));
if (!calibrated) calibrate(); if (!calibrated) calibrate();
if (event.pressure>0) { if (event.pressure>0) {

View File

@ -36,7 +36,7 @@ typedef struct {
class Touchscreen { class Touchscreen {
private: private:
int wm97xx; int ts_fd;
bool calibrated, _handled; bool calibrated, _handled;
TS_EVENT event; TS_EVENT event;
int calibX, calibY; int calibX, calibY;
@ -50,9 +50,15 @@ public:
~Touchscreen(); ~Touchscreen();
bool init(); bool init();
bool initialized();
void deinit(); void deinit();
bool initialized() {
#ifdef PLATFORM_GP2X
return ts_fd>0;
#endif
return false;
}
bool poll(); bool poll();
bool pressed(); bool pressed();
bool released(); bool released();