Index: settings.c =================================================================== RCS file: /cvsroot/rockbox/apps/settings.c,v retrieving revision 1.250 diff -u -b -r1.250 settings.c --- settings.c 28 Dec 2004 22:16:06 -0000 1.250 +++ settings.c 11 Jan 2005 20:32:15 -0000 @@ -343,6 +343,7 @@ {9, S_O(mdb_shape), 0, "mdb shape", NULL}, {1, S_O(mdb_enable), 0, "mdb enable", off_on}, {1, S_O(id3_v1_first), 0, "id3 tag priority", "v2-v1,v1-v2"}, + {1, S_O(autoloadconfig), false, "autoloadconfig", off_on }, /* new stuff to be added at the end */ Index: settings.h =================================================================== RCS file: /cvsroot/rockbox/apps/settings.h,v retrieving revision 1.126 diff -u -b -r1.126 settings.h --- settings.h 19 Nov 2004 10:54:59 -0000 1.126 +++ settings.h 11 Jan 2005 20:32:16 -0000 @@ -215,6 +215,7 @@ int peak_meter_min; /* range minimum */ int peak_meter_max; /* range maximum */ bool car_adapter_mode; /* 0=off 1=on */ + bool autoloadconfig; /* 0=off 1=on */ /* show status bar */ bool statusbar; /* 0=hide, 1=show */ Index: settings_menu.c =================================================================== RCS file: /cvsroot/rockbox/apps/settings_menu.c,v retrieving revision 1.165 diff -u -b -r1.165 settings_menu.c --- settings_menu.c 18 Dec 2004 10:29:47 -0000 1.165 +++ settings_menu.c 11 Jan 2005 20:32:19 -0000 @@ -527,6 +527,11 @@ names, 4, NULL ); } +static bool autoloadconfig(void) +{ + return set_bool( str(LANG_AUTOLOADCONFIG), &global_settings.autoloadconfig ); +} + static bool autocreatebookmark(void) { bool retval = false; @@ -1318,6 +1323,7 @@ { ID2P(LANG_FIRMWARE), firmware_browse }, { ID2P(LANG_RESET), reset_settings }, { ID2P(LANG_SAVE_SETTINGS), settings_save_config }, + { ID2P(LANG_AUTOLOADCONFIG), autoloadconfig }, }; m=menu_init( items, sizeof(items) / sizeof(*items), NULL, Index: tree.c =================================================================== RCS file: /cvsroot/rockbox/apps/tree.c,v retrieving revision 1.280 diff -u -b -r1.280 tree.c --- tree.c 2 Jan 2005 12:08:34 -0000 1.280 +++ tree.c 11 Jan 2005 20:32:26 -0000 @@ -742,10 +742,36 @@ return filesindir; } +#if defined(HAVE_LCD_BITMAP) && (CONFIG_KEYPAD != RECORDER_PAD) +/* slightly adapted version of button bar drawer, for ondios */ +static void draw_buttonbar_flex(int num, const char* caption, int numberbuttons) { + int xpos, ypos, button_width, text_width; + int fw, fh; + + lcd_setfont(FONT_SYSFIXED); + lcd_getstringsize("M", &fw, &fh); + + button_width = LCD_WIDTH/numberbuttons; + xpos = num * button_width; + ypos = LCD_HEIGHT - fh; + + if(caption) + { + /* center the text */ + text_width = fw * strlen(caption); + lcd_putsxy(xpos + (button_width - text_width)/2, ypos, caption); + } + + lcd_invertrect(xpos, ypos, button_width - 1, fh); +} +#endif + + static bool ask_resume(bool ask_once) { int button; bool stop = false; + bool dontstop = false; static bool ignore_power = true; #ifdef HAVE_LCD_CHARCELLS @@ -758,10 +784,15 @@ } /* always resume? */ - if ( global_settings.resume == RESUME_ON ) + if ( (global_settings.resume == RESUME_ON) && + (!global_settings.autoloadconfig) ) return true; lcd_clear_display(); + + if ( (global_settings.resume == RESUME_ASK) || + ((global_settings.resume == RESUME_ASK_ONCE) + && ask_once) ) { lcd_puts(0,0,str(LANG_RESUME_ASK)); #ifdef HAVE_LCD_CHARCELLS status_draw(false); @@ -770,10 +801,148 @@ lcd_puts(0,1,str(LANG_CONFIRM_WITH_PLAY_RECORDER)); lcd_puts(0,2,str(LANG_CANCEL_WITH_ANY_RECORDER)); #endif + } + +#ifdef HAVE_LCD_CHARCELLS + if (((global_settings.resume != RESUME_ASK) && + ((global_settings.resume == RESUME_ASK_ONCE) + ^ ask_once)) && global_settings.autoloadconfig) { + /* show left / right texts on player too, when there is room enough */ + lcd_puts(0,0,"left right"); + lcd_puts(0,1,".cfg .cfg"); + } + +#else + +#if CONFIG_KEYPAD == RECORDER_PAD + if (global_settings.autoloadconfig) { + buttonbar_set("f1.cfg","f2.cfg","f3.cfg"); + buttonbar_draw(); + } +#else +#if CONFIG_KEYPAD == ONDIO_PAD + if (global_settings.autoloadconfig) { + draw_buttonbar_flex(0,"up.cfg",2); + draw_buttonbar_flex(1,"down.cfg",2); + } +#else /* for other devices, use left/right */ + if (global_settings.autoloadconfig) { + draw_buttonbar_flex(0,"left.cfg",2); + draw_buttonbar_flex(1,"right.cfg",2); + } +#endif +#endif + +#endif + lcd_update(); while (!stop) { button = button_get(true); + + if (global_settings.autoloadconfig) { + switch (button) { +#if CONFIG_KEYPAD == RECORDER_PAD + /* load config files */ + case BUTTON_F1: + if (settings_load_config(ROCKBOX_DIR "/f1.cfg")) + splash(HZ,true,"f1.cfg loaded"); + else + splash(HZ,true,str(LANG_READ_FAILED),"f1.cfg"); + if (((global_settings.resume != RESUME_ASK) && + ((global_settings.resume == RESUME_ASK_ONCE) + ^ ask_once)) && global_settings.autoloadconfig) { + ignore_power = false; + stop = true; + } + dontstop = true; + break; + case BUTTON_F2: + if (settings_load_config(ROCKBOX_DIR "/f2.cfg")) + splash(HZ,true,"f2.cfg loaded"); + else + splash(HZ,true,str(LANG_READ_FAILED),"f2.cfg"); + if (((global_settings.resume != RESUME_ASK) && + ((global_settings.resume == RESUME_ASK_ONCE) + ^ ask_once)) && global_settings.autoloadconfig) { + ignore_power = false; + stop = true; + } + dontstop = true; + break; + case BUTTON_F3: + if (settings_load_config(ROCKBOX_DIR "/f3.cfg")) + splash(HZ,true,"f3.cfg loaded"); + else + splash(HZ,true,str(LANG_READ_FAILED),"f3.cfg"); + if (((global_settings.resume != RESUME_ASK) && + ((global_settings.resume == RESUME_ASK_ONCE) + ^ ask_once)) && global_settings.autoloadconfig) { + ignore_power = false; + stop = true; + } + dontstop = true; + break; +#else +#if CONFIG_KEYPAD == ONDIO_PAD + case BUTTON_UP: + if (settings_load_config(ROCKBOX_DIR "/up.cfg")) + splash(HZ,true,"up.cfg loaded"); + else + splash(HZ,true,str(LANG_READ_FAILED),"up.cfg"); + if (((global_settings.resume != RESUME_ASK) && + ((global_settings.resume == RESUME_ASK_ONCE) + ^ ask_once)) && global_settings.autoloadconfig) { + ignore_power = false; + stop = true; + } + dontstop = true; + break; + case BUTTON_DOWN: + if (settings_load_config(ROCKBOX_DIR "/down.cfg")) + splash(HZ,true,"down.cfg loaded"); + else + splash(HZ,true,str(LANG_READ_FAILED),"down.cfg"); + if (((global_settings.resume != RESUME_ASK) && + ((global_settings.resume == RESUME_ASK_ONCE) + ^ ask_once)) && global_settings.autoloadconfig) { + ignore_power = false; + stop = true; + } + dontstop = true; + break; +#else /* if not recorder && not ondio */ + case BUTTON_LEFT: + if (settings_load_config(ROCKBOX_DIR "/left.cfg")) + splash(HZ,true,"left.cfg loaded"); + else + splash(HZ,true,str(LANG_READ_FAILED),"left.cfg"); + if (((global_settings.resume != RESUME_ASK) && + ((global_settings.resume == RESUME_ASK_ONCE) + ^ ask_once)) && global_settings.autoloadconfig) { + ignore_power = false; + stop = true; + } + dontstop = true; + break; + case BUTTON_RIGHT: + if (settings_load_config(ROCKBOX_DIR "/right.cfg")) + splash(HZ,true,"right.cfg loaded"); + else + splash(HZ,true,str(LANG_READ_FAILED),"right.cfg"); + if (((global_settings.resume != RESUME_ASK) && + ((global_settings.resume == RESUME_ASK_ONCE) + ^ ask_once)) && global_settings.autoloadconfig) { + ignore_power = false; + stop = true; + } + dontstop = true; + break; +#endif /* ondio */ +#endif /* recorder */ + } + } + switch (button) { #ifdef TREE_RUN_PRE case TREE_RUN_PRE: /* catch the press, not the release */ @@ -783,9 +952,14 @@ #ifdef TREE_RC_RUN case TREE_RC_RUN: #endif + if ( (global_settings.resume == RESUME_ASK) || + ((global_settings.resume == RESUME_ASK_ONCE) + && ask_once) + ) { ignore_power = false; /* Don't ignore the power button for subsequent calls */ return true; + } #ifdef TREE_POWER_BTN /* Initially ignore the button which powers on the box. It @@ -803,10 +977,12 @@ #endif /* Handle sys events, ignore button releases */ default: - if(default_event_handler(button) || !(button & BUTTON_REL)) + if((default_event_handler(button) || !(button & BUTTON_REL)) + && !dontstop) stop = true; break; } + dontstop = false; } if ( global_settings.resume == RESUME_ASK_ONCE && ask_once) { @@ -855,8 +1031,9 @@ static void start_resume(bool ask_once) { - if ( global_settings.resume && - global_settings.resume_index != -1 ) { + if ( ( global_settings.resume && + global_settings.resume_index != -1 ) + || global_settings.autoloadconfig ) { DEBUGF("Resume index %X offset %X\n", global_settings.resume_index, global_settings.resume_offset); @@ -951,8 +1128,10 @@ memcpy(currdir,root,sizeof(currdir)); - if (*dirfilter < NUM_FILTER_MODES) + if (*dirfilter < NUM_FILTER_MODES) { + /* this is _only_ the startup resume screen, not the normal on-press screen */ start_resume(true); + } numentries = showdir(currdir, dirstart, dirfilter); if (numentries == -1) @@ -1411,6 +1590,7 @@ } else { + /* this is the non-startup, press-on-while-browsing resume screen */ start_resume(false); restore = true; } Index: lang/english.lang =================================================================== RCS file: /cvsroot/rockbox/apps/lang/english.lang,v retrieving revision 1.135 diff -u -b -r1.135 english.lang --- lang/english.lang 24 Oct 2004 02:52:19 -0000 1.135 +++ lang/english.lang 11 Jan 2005 20:32:32 -0000 @@ -2860,3 +2860,8 @@ voice: " " new: +id: LANG_AUTOLOADCONFIG +desc: auto load config menu name +eng: "Auto load config menu" +voice: "Auto load config menu" +new: