From 84b4c46d74d2b757026d425953bf2b033e124016 Mon Sep 17 00:00:00 2001 From: Michael Giacomelli Date: Mon, 16 May 2011 20:27:14 +0000 Subject: [PATCH] Enter USB charging mode on devices that support it if any key is held down during USB insert (except on Archos where certain keys need to be avoided and players like the iRiver H1x0 which do not charge over USB and the iAudios/AMSv2 which do not yet support USB fully). Update the manual to explain the new behavior. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29889 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/usb.h | 45 +++---------------------------- firmware/usb.c | 6 +---- manual/rockbox_interface/main.tex | 6 ++++- 3 files changed, 9 insertions(+), 48 deletions(-) diff --git a/firmware/export/usb.h b/firmware/export/usb.h index a3425dae2f..72315404e3 100644 --- a/firmware/export/usb.h +++ b/firmware/export/usb.h @@ -57,7 +57,6 @@ enum { USB_HANDLED, /* Bootloader status code */ #endif }; - #ifdef HAVE_USB_POWER #if CONFIG_KEYPAD == RECORDER_PAD #define USBPOWER_BUTTON BUTTON_F1 @@ -65,48 +64,10 @@ enum { #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) -#define USBPOWER_BUTTON BUTTON_SELECT -#define USBPOWER_BTN_IGNORE BUTTON_POWER -#elif (CONFIG_KEYPAD == PHILIPS_SA9200_PAD) -#define USBPOWER_BUTTON BUTTON_PLAY -#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 == PHILIPS_HDD6330_PAD -#define USBPOWER_BUTTON BUTTON_LEFT -#define USBPOWER_BTN_IGNORE BUTTON_POWER -#elif CONFIG_KEYPAD == SAMSUNG_YH_PAD -#define USBPOWER_BUTTON BUTTON_RIGHT -#define USBPOWER_BTN_IGNORE BUTTON_LEFT -#elif CONFIG_KEYPAD == COWON_D2_PAD -#define USBPOWER_BUTTON BUTTON_MENU -#define USBPOWER_BTN_IGNORE BUTTON_MINUS -#elif CONFIG_KEYPAD == ONDAVX747_PAD -#define USBPOWER_BUTTON BUTTON_VOL_UP -#define USBPOWER_BTN_IGNORE BUTTON_VOL_DOWN -#elif CONFIG_KEYPAD == PBELL_VIBE500_PAD -#define USBPOWER_BUTTON BUTTON_REC -#define USBPOWER_BTN_IGNORE BUTTON_POWER +#else +#define USBPOWER_BTN_IGNORE 0 +#endif #endif -#endif /* HAVE_USB_POWER */ #ifdef HAVE_USBSTACK /* USB class drivers */ diff --git a/firmware/usb.c b/firmware/usb.c index aada27dfd9..b8e2b5298c 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -341,11 +341,7 @@ static inline void usb_slave_mode(bool on) #ifdef HAVE_USB_POWER 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; -#else - return (button_status() & ~USBPOWER_BTN_IGNORE) == USBPOWER_BUTTON; -#endif + return (button_status() & ~USBPOWER_BTN_IGNORE); } #ifdef USB_FIREWIRE_HANDLING diff --git a/manual/rockbox_interface/main.tex b/manual/rockbox_interface/main.tex index a8022be209..e4de1d654a 100644 --- a/manual/rockbox_interface/main.tex +++ b/manual/rockbox_interface/main.tex @@ -807,10 +807,14 @@ properly.} \opt{usb_power}{ \section{USB Charging} \nopt{clipv2,fuzev2,clipplus}{ - To charge your \dap{} over USB, hold \ActionStdUsbCharge{} while plugging it + To charge your \dap{} over USB, hold any button while plugging it in. This will prevent it from connecting to your computer and let you continue to use it normally. Your \dap{} must already be in Rockbox for this to function. + \note{Be aware that this button may still perform its normal function, so + it is recommended to use a button without harmful side effects, such as + ActionStdUsbCharge{}.} + } \opt{clipv2,fuzev2,clipplus}{ Your \dap{} will automatically charge over USB if the cable is plugged in