summaryrefslogtreecommitdiffstats
path: root/apps/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/main.c')
-rw-r--r--apps/main.c126
1 files changed, 89 insertions, 37 deletions
diff --git a/apps/main.c b/apps/main.c
index 3c549a8e63..1e012efb3c 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -21,6 +21,7 @@
#include "config.h"
#include "system.h"
+#include "version.h"
#include "gcc_extensions.h"
#include "storage.h"
#include "disk.h"
@@ -31,15 +32,15 @@
#include "led.h"
#include "../kernel-internal.h"
#include "button.h"
+#include "core_keymap.h"
#include "tree.h"
#include "filetypes.h"
#include "panic.h"
#include "menu.h"
#include "usb.h"
+#include "wifi.h"
#include "powermgmt.h"
-#if !defined(DX50) && !defined(DX90)
#include "adc.h"
-#endif
#include "i2c.h"
#ifndef DEBUG
#include "serial.h"
@@ -70,7 +71,6 @@
#include "string.h"
#include "splash.h"
#include "eeprom_settings.h"
-#include "scrobbler.h"
#include "icon.h"
#include "viewport.h"
#include "skin_engine/skin_engine.h"
@@ -168,7 +168,7 @@ int main(void)
screens[i].update();
}
list_init();
- tree_gui_init();
+ tree_init();
/* Keep the order of this 3
* Must be done before any code uses the multi-screen API */
#ifdef HAVE_USBSTACK
@@ -176,6 +176,15 @@ int main(void)
usb_start_monitoring();
#endif
+#if !defined(DISABLE_ACTION_REMAP) && defined(CORE_KEYREMAP_FILE)
+ if (file_exists(CORE_KEYREMAP_FILE))
+ {
+ int mapct = core_load_key_remap(CORE_KEYREMAP_FILE);
+ if (mapct <= 0)
+ splashf(HZ, "key remap failed: %d, %s", mapct, CORE_KEYREMAP_FILE);
+ }
+#endif
+
#ifdef AUTOROCK
{
char filename[MAX_PATH];
@@ -200,6 +209,50 @@ int main(void)
root_menu();
}
+/* The disk isn't ready at boot, rblogo is stored in bin and erased after boot */
+int show_logo_boot( void ) INIT_ATTR;
+int show_logo_boot( void )
+{
+ unsigned char version[32];
+ int font_h, ver_w;
+ snprintf(version, sizeof(version), "Ver. %s", rbversion);
+ ver_w = font_getstringsize(version, NULL, &font_h, FONT_SYSFIXED);
+ lcd_clear_display();
+ lcd_setfont(FONT_SYSFIXED);
+#if defined(SANSA_CLIP) || defined(SANSA_CLIPV2) || defined(SANSA_CLIPPLUS)
+ /* display the logo in the blue area of the screen (bottom 48 pixels) */
+ if (ver_w > LCD_WIDTH)
+ lcd_putsxy(0, 0, rbversion);
+ else
+ lcd_putsxy((LCD_WIDTH/2) - (ver_w/2), 0, version);
+ lcd_bmp(&bm_rockboxlogo, (LCD_WIDTH - BMPWIDTH_rockboxlogo) / 2, 16);
+#else
+ lcd_bmp(&bm_rockboxlogo, (LCD_WIDTH - BMPWIDTH_rockboxlogo) / 2, 10);
+ if (ver_w > LCD_WIDTH)
+ lcd_putsxy(0, LCD_HEIGHT-font_h, rbversion);
+ else
+ lcd_putsxy((LCD_WIDTH/2) - (ver_w/2), LCD_HEIGHT-font_h, version);
+#endif
+ lcd_setfont(FONT_UI);
+ lcd_update();
+#ifdef HAVE_REMOTE_LCD
+ lcd_remote_clear_display();
+ lcd_remote_bmp(&bm_remote_rockboxlogo, 0, 10);
+ lcd_remote_setfont(FONT_SYSFIXED);
+ if (ver_w > LCD_REMOTE_WIDTH)
+ lcd_remote_putsxy(0, LCD_REMOTE_HEIGHT-font_h, rbversion);
+ else
+ lcd_remote_putsxy((LCD_REMOTE_WIDTH/2) - (ver_w/2),
+ LCD_REMOTE_HEIGHT-font_h, version);
+ lcd_remote_setfont(FONT_UI);
+ lcd_remote_update();
+#endif
+#ifdef SIMULATOR
+ sleep(HZ); /* sim is too fast to see logo */
+#endif
+ return 0;
+}
+
#ifdef HAVE_DIRCACHE
static int INIT_ATTR init_dircache(bool preinit)
{
@@ -233,7 +286,7 @@ static int INIT_ATTR init_dircache(bool preinit)
splash(0, str(LANG_SCANNING_DISK));
dircache_wait();
backlight_on();
- show_logo();
+ show_logo_boot();
}
struct dircache_info info;
@@ -280,13 +333,15 @@ static void init_tagcache(void)
#endif
if (lang_is_rtl())
{
- splashf(0, "[%d/%d] %s", ret, tagcache_get_max_commit_step(),
- str(LANG_TAGCACHE_INIT));
+ splash_progress(ret, tagcache_get_max_commit_step(),
+ "[%d/%d] %s", ret, tagcache_get_max_commit_step(),
+ str(LANG_TAGCACHE_INIT));
}
else
{
- splashf(0, "%s [%d/%d]", str(LANG_TAGCACHE_INIT), ret,
- tagcache_get_max_commit_step());
+ splash_progress(ret, tagcache_get_max_commit_step(),
+ "%s [%d/%d]", str(LANG_TAGCACHE_INIT), ret,
+ tagcache_get_max_commit_step());
}
clear = true;
}
@@ -297,7 +352,7 @@ static void init_tagcache(void)
if (clear)
{
backlight_on();
- show_logo();
+ show_logo_boot();
}
}
#endif /* HAVE_TAGCACHE */
@@ -320,11 +375,7 @@ static void init(void)
FOR_NB_SCREENS(i)
global_status.font_id[i] = FONT_SYSFIXED;
font_init();
- show_logo();
-#ifndef USB_NONE
- usb_init();
- usb_start_monitoring();
-#endif
+ show_logo_boot();
button_init();
powermgmt_init();
backlight_init();
@@ -368,12 +419,16 @@ static void init(void)
playlist_init();
shortcuts_init();
- if (global_settings.audioscrobbler)
- scrobbler_init();
-
audio_init();
talk_announce_voice_invalid(); /* notify user w/ voice prompt if voice file invalid */
settings_apply_skins();
+
+/* do USB last so prompt (if enabled) can work correctly if USB was inserted with device off,
+ * also doesn't hurt that it will display the nice pretty backdrop this way too. */
+#ifndef USB_NONE
+ usb_init();
+ usb_start_monitoring();
+#endif
}
#else /* CONFIG_PLATFORM & PLATFORM_HOSTED */
@@ -424,7 +479,7 @@ static void init(void)
settings_reset();
CHART(">show_logo");
- show_logo();
+ show_logo_boot();
CHART("<show_logo");
lang_init(core_language_builtin, language_strings,
LANG_LAST_INDEX_IN_ARRAY);
@@ -440,11 +495,6 @@ static void init(void)
#if CONFIG_RTC
rtc_init();
#endif
-#ifdef HAVE_RTC_RAM
- CHART(">settings_load(RTC)");
- settings_load(SETTINGS_RTC); /* early load parts of global_settings */
- CHART("<settings_load(RTC)");
-#endif
adc_init();
@@ -563,27 +613,28 @@ static void init(void)
pcm_init();
dsp_init();
-#if defined(SETTINGS_RESET) || (CONFIG_KEYPAD == IPOD_4G_PAD) || \
+ CHART(">settings_load(ALL)");
+ settings_load(SETTINGS_ALL);
+ CHART("<settings_load(ALL)");
+
+#if defined(BUTTON_REC) || \
+ (CONFIG_KEYPAD == GIGABEAT_PAD) || \
+ (CONFIG_KEYPAD == IPOD_4G_PAD) || \
(CONFIG_KEYPAD == IRIVER_H10_PAD)
+ if (global_settings.clear_settings_on_hold &&
#ifdef SETTINGS_RESET
/* Reset settings if holding the reset button. (Rec on Archos,
A on Gigabeat) */
- if ((button_status() & SETTINGS_RESET) == SETTINGS_RESET)
+ ((button_status() & SETTINGS_RESET) == SETTINGS_RESET))
#else
/* Reset settings if the hold button is turned on */
- if (button_hold())
+ (button_hold()))
#endif
{
splash(HZ*2, str(LANG_RESET_DONE_CLEAR));
settings_reset();
}
- else
#endif
- {
- CHART(">settings_load(ALL)");
- settings_load(SETTINGS_ALL);
- CHART("<settings_load(ALL)");
- }
#ifdef HAVE_DIRCACHE
CHART(">init_dircache(true)");
@@ -591,7 +642,7 @@ static void init(void)
CHART("<init_dircache(true)");
#ifdef HAVE_TAGCACHE
if (rc < 0)
- remove(TAGCACHE_STATEFILE);
+ tagcache_remove_statefile();
#endif /* HAVE_TAGCACHE */
#endif /* HAVE_DIRCACHE */
@@ -623,9 +674,6 @@ static void init(void)
tree_mem_init();
filetype_init();
- if (global_settings.audioscrobbler)
- scrobbler_init();
-
shortcuts_init();
CHART(">audio_init");
@@ -633,6 +681,10 @@ static void init(void)
CHART("<audio_init");
talk_announce_voice_invalid(); /* notify user w/ voice prompt if voice file invalid */
+#ifdef HAVE_WIFI
+ wifi_init();
+#endif
+
/* runtime database has to be initialized after audio_init() */
cpu_boost(false);