Index: apps/lang/english.lang =================================================================== --- apps/lang/english.lang (revision 21148) +++ apps/lang/english.lang (working copy) @@ -12468,3 +12468,20 @@ *: "Prevent Track Skipping" + + id: LANG_USB_CHARGE_ONLY + desc: in Settings -> System Settings + user: core + + *: none + usb_charging: "Only charge on USB insert" + + + *: none + usb_charging: "Only charge on USB insert" + + + *: none + usb_charging: "Only charge on U S B insert" + + Index: apps/settings.h =================================================================== --- apps/settings.h (revision 21148) +++ apps/settings.h (working copy) @@ -620,7 +620,9 @@ #ifdef HAVE_USB_CHARGING_ENABLE bool usb_charging; #endif - +#ifdef HAVE_USB_POWER + bool usb_charge_only; +#endif /* device settings */ #ifdef HAVE_LCD_CONTRAST int contrast; /* lcd contrast */ Index: apps/menus/settings_menu.c =================================================================== --- apps/menus/settings_menu.c (revision 21148) +++ apps/menus/settings_menu.c (working copy) @@ -156,6 +156,7 @@ } MENUITEM_SETTING(usb_charging, &global_settings.usb_charging, usbcharging_callback); #endif /* HAVE_USB_CHARGING_ENABLE */ + MAKE_MENU(battery_menu, ID2P(LANG_BATTERY_MENU), 0, Icon_NOICON, #if BATTERY_CAPACITY_INC > 0 &battery_capacity, @@ -167,6 +168,9 @@ &usb_charging, #endif ); +#ifdef HAVE_USB_POWER +MENUITEM_SETTING(usb_charge_only_item, &global_settings.usb_charge_only, NULL); +#endif /* Disk */ #ifdef HAVE_DISK_STORAGE MENUITEM_SETTING(disk_spindown, &global_settings.disk_spindown, NULL); @@ -303,6 +307,9 @@ #ifdef HAVE_ACCESSORY_SUPPLY &accessory_supply, #endif +#ifdef HAVE_USB_POWER + &usb_charge_only_item, +#endif #ifdef HAVE_BUTTON_LIGHT &buttonlight_timeout, #endif Index: apps/settings_list.c =================================================================== --- apps/settings_list.c (revision 21148) +++ apps/settings_list.c (working copy) @@ -42,6 +42,7 @@ #include "lcd-remote.h" #include "list.h" #include "rbunicode.h" +#include "usb.h" #ifdef HAVE_LCD_BITMAP #include "peakmeter.h" #endif @@ -1328,6 +1329,10 @@ #ifdef HAVE_USB_CHARGING_ENABLE OFFON_SETTING(0,usb_charging,LANG_USB_CHARGING,false,"usb charging",NULL), #endif +#ifdef HAVE_USB_POWER + OFFON_SETTING(0, usb_charge_only, LANG_USB_CHARGE_ONLY, false, + "usb charge only", usb_set_charge_setting), +#endif OFFON_SETTING(F_BANFROMQS,cuesheet,LANG_CUESHEET_ENABLE,false,"cuesheet support", NULL), TABLE_SETTING(F_ALLOW_ARBITRARY_VALS, skip_length, Index: apps/features.txt =================================================================== --- apps/features.txt (revision 21148) +++ apps/features.txt (working copy) @@ -179,10 +179,10 @@ #if CONFIG_CHARGING charging +#endif #if defined(HAVE_USB_POWER) usb_charging #endif -#endif #if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB) usbstack Index: firmware/export/usb.h =================================================================== --- firmware/export/usb.h (revision 21148) +++ firmware/export/usb.h (working copy) @@ -54,41 +54,6 @@ USB_QUIT, /* Event */ }; -#ifdef HAVE_USB_POWER -#if CONFIG_KEYPAD == RECORDER_PAD -#define USBPOWER_BUTTON BUTTON_F1 -#define USBPOWER_BTN_IGNORE BUTTON_ON -#elif CONFIG_KEYPAD == ONDIO_PAD -#define USBPOWER_BUTTON BUTTON_MENU -#define USBPOWER_BTN_IGNORE BUTTON_OFF -#elif (CONFIG_KEYPAD == IPOD_4G_PAD) -#define USBPOWER_BUTTON BUTTON_MENU -#define USBPOWER_BTN_IGNORE BUTTON_PLAY -#elif CONFIG_KEYPAD == IRIVER_H300_PAD -#define USBPOWER_BUTTON BUTTON_MODE -#define USBPOWER_BTN_IGNORE BUTTON_ON -#elif CONFIG_KEYPAD == GIGABEAT_PAD -#define USBPOWER_BUTTON BUTTON_MENU -#define USBPOWER_BTN_IGNORE BUTTON_POWER -#elif (CONFIG_KEYPAD == IRIVER_H10_PAD) || \ - (CONFIG_KEYPAD == MROBE100_PAD) -#define USBPOWER_BUTTON BUTTON_RIGHT -#define USBPOWER_BTN_IGNORE BUTTON_POWER -#elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \ - (CONFIG_KEYPAD == SANSA_C200_PAD) || \ - (CONFIG_KEYPAD == SANSA_CLIP_PAD) || \ - (CONFIG_KEYPAD == SANSA_FUZE_PAD) || \ - (CONFIG_KEYPAD == PHILIPS_SA9200_PAD) -#define USBPOWER_BUTTON BUTTON_SELECT -#define USBPOWER_BTN_IGNORE BUTTON_POWER -#elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD -#define USBPOWER_BUTTON BUTTON_PLAYLIST -#define USBPOWER_BTN_IGNORE BUTTON_POWER -#elif CONFIG_KEYPAD == SAMSUNG_YH_PAD -#define USBPOWER_BUTTON BUTTON_RIGHT -#define USBPOWER_BTN_IGNORE BUTTON_LEFT -#endif -#endif /* HAVE_USB_POWER */ #ifdef HAVE_USBSTACK /* USB class drivers */ @@ -124,6 +89,8 @@ void usb_status_event(int current_status); #ifdef HAVE_USB_POWER bool usb_powered(void); +void usb_set_charge_setting(bool charge_only); +bool usb_charge_only(void); #ifdef CONFIG_CHARGING bool usb_charging_enable(bool on); bool usb_charging_enabled(void); Index: firmware/usb.c =================================================================== --- firmware/usb.c (revision 21148) +++ firmware/usb.c (working copy) @@ -195,19 +195,21 @@ #endif /* HAVE_USBSTACK */ #ifdef HAVE_USB_POWER -static inline bool usb_power_button(void) +static bool usb_charge_only_setting = false; +bool usb_charge_only(void) { -#if (defined(IRIVER_H10) || defined (IRIVER_H10_5GB)) && !defined(USE_ROCKBOX_USB) - return (button_status() & ~USBPOWER_BTN_IGNORE) != USBPOWER_BUTTON; -#else - return (button_status() & ~USBPOWER_BTN_IGNORE) == USBPOWER_BUTTON; -#endif + bool button = button_status() != BUTTON_NONE; + return (usb_charge_only_setting && !button) || + (!usb_charge_only_setting && button); +} +void usb_set_charge_setting(bool charge_only) +{ + usb_charge_only_setting = charge_only; } - #ifdef USB_FIREWIRE_HANDLING static inline bool usb_reboot_button(void) { - return (button_status() & ~USBPOWER_BTN_IGNORE) != USBPOWER_BUTTON; + return button_status()!=BUTTON_NULL; } #endif #endif /* HAVE_USB_POWER */ @@ -265,7 +267,7 @@ } #endif #ifdef HAVE_USB_POWER - if(usb_power_button()) + if(usb_charge_only()) { /* Only charging is desired */ usb_state = USB_POWERED; Index: manual/configure_rockbox/system_options.tex =================================================================== --- manual/configure_rockbox/system_options.tex (revision 21148) +++ manual/configure_rockbox/system_options.tex (working copy) @@ -159,6 +159,17 @@ this option \setting{On}. If it is not required, then turning this setting \setting{Off} will save battery and therefore result in better runtime. } +\opt{usb_charging}{ +\subsection{Only charge on USB insert} +When this is \setting{Off}, if a USB cable is inserted that is connected to a PC, Hub, +or certain types of chargers the player will attempt to enter USB disk mode and +connect while charging. If any button is held down, the player will instead +simply charge while making no attempt to connect. During this charging, +music may still be played and the player may be used as normal. If this +setting is set to \setting{On} the player will only charge by default, and +not attempt to enter USB disk mode unless a button is held down as the +USB cable is inserted. +} \opt{HAVE_BUTTON_LIGHTS}{ \opt{e200}{