Index: apps/lang/english.lang =================================================================== --- apps/lang/english.lang (revision 25345) +++ apps/lang/english.lang (working copy) @@ -13394,3 +13394,20 @@ lineout_poweroff: "Line Out" + + id: LANG_REVERSE_USB_HANDLING + desc: in settings -> system menu + user: core + + *: none + charging: "Reverse USB handling" + + + *: none + charging: "Reverse USB handling" + + + *: none + charging: "Reverse U S B handling" + + Index: apps/settings.h =================================================================== --- apps/settings.h (revision 25345) +++ apps/settings.h (working copy) @@ -540,6 +540,7 @@ bool audioscrobbler; /* Audioscrobbler logging */ bool cuesheet; bool car_adapter_mode; /* 0=off 1=on */ + bool reverse_usb_handling; /* 0=off 1=on */ int start_in_screen; #if defined(HAVE_RTC_ALARM) && \ (defined(HAVE_RECORDING) || CONFIG_TUNER) Index: apps/menus/settings_menu.c =================================================================== --- apps/menus/settings_menu.c (revision 25345) +++ apps/menus/settings_menu.c (working copy) @@ -245,6 +245,10 @@ #if CONFIG_CHARGING MENUITEM_SETTING(car_adapter_mode, &global_settings.car_adapter_mode, NULL); #endif +#ifdef HAVE_USB_POWER +MENUITEM_SETTING(reverse_usb_handling, &global_settings.reverse_usb_handling, + NULL); +#endif #ifdef IPOD_ACCESSORY_PROTOCOL MENUITEM_SETTING(serial_bitrate, &global_settings.serial_bitrate, NULL); #endif @@ -296,6 +300,9 @@ #if CONFIG_CHARGING &car_adapter_mode, #endif +#ifdef HAVE_USB_POWER + &reverse_usb_handling, +#endif #ifdef IPOD_ACCESSORY_PROTOCOL &serial_bitrate, #endif Index: apps/settings_list.c =================================================================== --- apps/settings_list.c (revision 25345) +++ apps/settings_list.c (working copy) @@ -690,6 +690,11 @@ OFFON_SETTING(NVRAM(1), car_adapter_mode, LANG_CAR_ADAPTER_MODE, false, "car adapter mode", NULL), #endif +#ifdef HAVE_USB_POWER + OFFON_SETTING(0, reverse_usb_handling,LANG_REVERSE_USB_HANDLING, + false, "reverse usb handling", + set_reverse_usb_handling), +#endif #ifdef IPOD_ACCESSORY_PROTOCOL CHOICE_SETTING(0, serial_bitrate, LANG_SERIAL_BITRATE, 0, "serial bitrate", "auto,9600,19200,38400,57600", iap_bitrate_set, 5, ID2P(LANG_SERIAL_BITRATE_AUTO), Index: firmware/export/usb.h =================================================================== --- firmware/export/usb.h (revision 25345) +++ firmware/export/usb.h (working copy) @@ -146,6 +146,7 @@ void usb_status_event(int current_status); #ifdef HAVE_USB_POWER bool usb_powered(void); +void set_reverse_usb_handling(bool usb_mode); #ifdef CONFIG_CHARGING bool usb_charging_enable(bool on); bool usb_charging_enabled(void); Index: firmware/usb.c =================================================================== --- firmware/usb.c (revision 25345) +++ firmware/usb.c (working copy) @@ -56,6 +56,10 @@ #define USB_FULL_INIT #endif +#ifdef HAVE_USB_POWER +static bool reverse_usb_handling = false; +#endif + #ifdef HAVE_LCD_BITMAP bool do_screendump_instead_of_usb = false; #endif @@ -201,12 +205,29 @@ #endif /* HAVE_USBSTACK */ #ifdef HAVE_USB_POWER +void set_reverse_usb_handling(bool usb_mode) +{ + reverse_usb_handling = usb_mode; +} + static inline bool usb_power_button(void) { #if (defined(IRIVER_H10) || defined (IRIVER_H10_5GB)) && !defined(USE_ROCKBOX_USB) - return (button_status() & ~USBPOWER_BTN_IGNORE) != USBPOWER_BUTTON; + if (reverse_usb_handling) + { + /* Reverse USB handling: inverse power button state */ + return !((button_status() & ~USBPOWER_BTN_IGNORE) != USBPOWER_BUTTON) + } + /* Default behaviour: return real status of power button */ + return ((button_status() & ~USBPOWER_BTN_IGNORE) != USBPOWER_BUTTON); #else - return (button_status() & ~USBPOWER_BTN_IGNORE) == USBPOWER_BUTTON; + if (reverse_usb_handling) + { + /* Reverse USB handling: inverse power button state */ + return !((button_status() & ~USBPOWER_BTN_IGNORE) == USBPOWER_BUTTON); + } + /* Default behaviour: return real status of power button */ + return ((button_status() & ~USBPOWER_BTN_IGNORE) == USBPOWER_BUTTON); #endif } Index: manual/rockbox_interface/main.tex =================================================================== --- manual/rockbox_interface/main.tex (revision 25345) +++ manual/rockbox_interface/main.tex (working copy) @@ -722,9 +722,10 @@ properly.} } +\label{sec:usb_charging} \nopt{ondio}{ \opt{usb_power}{ - \section{USB Charging} + \section{\label{sec:usb_power}USB Charging} The \dap{} can be charged over USB without connecting to your computer by holding \ActionStdUsbCharge{} while plugging in. This @@ -733,7 +734,7 @@ } \opt{ondio}{ - \section{USB Power} + \section{\label{sec:usb_power}USB Power} The \dap{} can be powered over USB without connecting to your computer by holding \ActionStdUsbCharge{} while plugging in. This Index: manual/configure_rockbox/system_options.tex =================================================================== --- manual/configure_rockbox/system_options.tex (revision 25345) +++ manual/configure_rockbox/system_options.tex (working copy) @@ -151,6 +151,18 @@ playback. } +\opt{usb_power}{ +\subsection{Reverse USB Handling} +This option reverses the way Rockbox chooses to handle USB cable +conections to your \dap{}, depending on the status of your +\ActionStdUsbCharge{} button. Normally, when a USB connection is +detected by Rockbox, a data connection will be made automatically (See +\reference{sec:usb_power}), unless \ActionStdUsbCharge{} button is +pressed. Setting this option to \setting{On} allows you to continue +using the player normally when the connection is made, unless +that button is pressed. +} + \opt{accessory_supply}{ \subsection{Accessory Power Supply} This option turns the accessory power supply \setting{On} and \setting{Off}.