Index: trunk/firmware/target/arm/sandisk/sansa-e200/button-e200.c =================================================================== --- trunk.orig/firmware/target/arm/sandisk/sansa-e200/button-e200.c +++ trunk/firmware/target/arm/sandisk/sansa-e200/button-e200.c @@ -280,6 +280,9 @@ int button_read_device(void) } #endif /* BOOTLOADER */ + if (hold_button) + int_btn |= BUTTON_HOLD_ON; + /* The int_btn variable is set in the button interrupt handler */ return int_btn; } Index: trunk/firmware/drivers/button.c =================================================================== --- trunk.orig/firmware/drivers/button.c +++ trunk/firmware/drivers/button.c @@ -54,6 +54,9 @@ static intptr_t button_data; /* data val #ifdef HAVE_LCD_BITMAP static bool flipped; /* buttons can be flipped to match the LCD flip */ #endif +#ifdef HAS_POWEROFF_NOW_BUTTON +static bool do_poweroff_on_hold = false; +#endif #ifdef HAVE_BACKLIGHT static bool filter_first_keypress; #ifdef HAVE_REMOTE_LCD @@ -88,6 +91,9 @@ static void button_tick(void) static bool skip_remote_release = false; #endif #endif +#ifdef HAS_POWEROFF_NOW_BUTTON + static long shutdown_tick = 0; +#endif int diff; int btn; @@ -119,6 +125,20 @@ static void button_tick(void) btn = button_read(); +#ifdef HAS_POWEROFF_NOW_BUTTON + if((btn & POWEROFF_NOW_BUTTON) && do_poweroff_on_hold +#if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING) + && !charger_inserted() +#endif + && shutdown_tick == 0) + { + shutdown_tick = current_tick; + sys_poweroff(); + } else if(shutdown_tick && TIME_AFTER(current_tick, shutdown_tick +10*HZ)) + /* Safety net */ + power_off(); +#endif + /* Find out if a key has been released */ diff = btn ^ lastbtn; if(diff && (btn & diff) == 0) @@ -447,6 +467,13 @@ void button_set_flip(bool flip) } #endif /* HAVE_LCD_BITMAP */ +#ifdef HAS_POWEROFF_NOW_BUTTON +void set_poweroff_on_hold(bool yesno) +{ + do_poweroff_on_hold = yesno; +} +#endif + #ifdef HAVE_BACKLIGHT void set_backlight_filter_keypress(bool value) { Index: trunk/firmware/target/arm/sandisk/sansa-e200/button-target.h =================================================================== --- trunk.orig/firmware/target/arm/sandisk/sansa-e200/button-target.h +++ trunk/firmware/target/arm/sandisk/sansa-e200/button-target.h @@ -24,6 +24,7 @@ #include "config.h" #define HAS_BUTTON_HOLD +#define HAS_POWEROFF_NOW_BUTTON bool button_hold(void); void button_init_device(void); @@ -43,6 +44,8 @@ int button_read_device(void); #define BUTTON_SCROLL_UP 0x00000080 #define BUTTON_SCROLL_DOWN 0x00000100 +#define BUTTON_HOLD_ON 0x00000200 + #define BUTTON_MAIN 0x00000fff /* No Remote control */ @@ -50,5 +53,6 @@ int button_read_device(void); #define POWEROFF_BUTTON BUTTON_POWER #define POWEROFF_COUNT 10 +#define POWEROFF_NOW_BUTTON BUTTON_HOLD_ON #endif /* _BUTTON_TARGET_H_ */ Index: trunk/apps/menus/settings_menu.c =================================================================== --- trunk.orig/apps/menus/settings_menu.c +++ trunk/apps/menus/settings_menu.c @@ -334,6 +334,9 @@ MENUITEM_SETTING(line_in, &global_settin #if CONFIG_CHARGING MENUITEM_SETTING(car_adapter_mode, &global_settings.car_adapter_mode, NULL); #endif +#ifdef HAS_POWEROFF_NOW_BUTTON +MENUITEM_SETTING(poweroff_on_hold, &global_settings.poweroff_on_hold, NULL); +#endif MENUITEM_SETTING(start_screen, &global_settings.start_in_screen, NULL); #ifdef HAVE_BUTTON_LIGHT @@ -370,6 +373,9 @@ MAKE_MENU(system_menu, ID2P(LANG_SYSTEM) #if CONFIG_CHARGING &car_adapter_mode, #endif +#ifdef HAS_POWEROFF_NOW_BUTTON + &poweroff_on_hold, +#endif #ifdef HAVE_BUTTON_LIGHT &buttonlight_timeout, #endif Index: trunk/apps/settings.c =================================================================== --- trunk.orig/apps/settings.c +++ trunk/apps/settings.c @@ -727,6 +727,9 @@ void settings_apply(void) #if BATTERY_TYPES_COUNT > 1 set_battery_type(global_settings.battery_type); #endif +#ifdef POWEROFF_NOW_BUTTON + set_poweroff_on_hold(global_settings.poweroff_on_hold); +#endif #ifdef HAVE_LCD_BITMAP lcd_set_invert_display(global_settings.invert); Index: trunk/apps/settings.h =================================================================== --- trunk.orig/apps/settings.h +++ trunk/apps/settings.h @@ -472,6 +472,9 @@ struct user_settings bool peak_meter_clipcounter; /* clipping count indicator */ #endif bool car_adapter_mode; /* 0=off 1=on */ +#ifdef HAS_POWEROFF_NOW_BUTTON + bool poweroff_on_hold; /* 0=no 1=yes */ +#endif /* show status bar */ bool statusbar; /* 0=hide, 1=show */ Index: trunk/apps/settings_list.c =================================================================== --- trunk.orig/apps/settings_list.c +++ trunk/apps/settings_list.c @@ -518,6 +518,10 @@ const struct settings_list settings[] = OFFON_SETTING(NVRAM(1), car_adapter_mode, LANG_CAR_ADAPTER_MODE, false, "car adapter mode", NULL), #endif +#ifdef HAS_POWEROFF_NOW_BUTTON + OFFON_SETTING(0, poweroff_on_hold, LANG_POWEROFF_ON_HOLD, false, + "poweroff on hold", set_poweroff_on_hold), +#endif /* tuner */ #if CONFIG_TUNER OFFON_SETTING(0,fm_force_mono, LANG_FM_MONO_MODE, Index: trunk/firmware/export/button.h =================================================================== --- trunk.orig/firmware/export/button.h +++ trunk/firmware/export/button.h @@ -37,6 +37,9 @@ void button_clear_queue(void); #ifdef HAVE_LCD_BITMAP void button_set_flip(bool flip); /* turn 180 degrees */ #endif +#ifdef HAS_POWEROFF_NOW_BUTTON +void set_poweroff_on_hold(bool yesno); +#endif #ifdef HAVE_BACKLIGHT void set_backlight_filter_keypress(bool value); #ifdef HAVE_REMOTE_LCD Index: trunk/apps/features.txt =================================================================== --- trunk.orig/apps/features.txt +++ trunk/apps/features.txt @@ -156,3 +156,7 @@ usb_charging #if defined(HAVE_USBSTACK) usbstack #endif + +#ifdef HAS_POWEROFF_NOW_BUTTON +poweroff_now_button +#endif Index: trunk/apps/lang/english.lang =================================================================== --- trunk.orig/apps/lang/english.lang +++ trunk/apps/lang/english.lang @@ -12476,3 +12476,20 @@ *: "unknown char" + + id: LANG_POWEROFF_ON_HOLD + desc: system setting + user: + + *: none + poweroff_now_button: "Poweroff on ohld" + + + *: none + poweroff_now_button: "Poweroff on ohld" + + + *: none + poweroff_now_button: "Power off on hold" + + Index: trunk/firmware/target/coldfire/iaudio/button-target.h =================================================================== --- trunk.orig/firmware/target/coldfire/iaudio/button-target.h +++ trunk/firmware/target/coldfire/iaudio/button-target.h @@ -24,6 +24,7 @@ #define HAS_BUTTON_HOLD #define HAS_REMOTE_BUTTON_HOLD +#define HAS_POWEROFF_NOW_BUTTON bool button_hold(void); bool remote_button_hold(void); @@ -46,8 +47,10 @@ bool button_scan_enabled(void); #define BUTTON_PLAY 0x00000040 #define BUTTON_SELECT 0x00000080 +#define BUTTON_HOLD_ON 0x00000100 + #define BUTTON_MAIN (BUTTON_POWER|BUTTON_PLAY|BUTTON_LEFT|BUTTON_RIGHT\ - |BUTTON_UP|BUTTON_DOWN|BUTTON_REC|BUTTON_SELECT) + |BUTTON_UP|BUTTON_DOWN|BUTTON_REC|BUTTON_SELECT|BUTTON_HOLD_ON) /* Remote control's buttons */ #define BUTTON_RC_PLAY 0x00100000 @@ -67,6 +70,7 @@ bool button_scan_enabled(void); |BUTTON_RC_REC|BUTTON_RC_MENU|BUTTON_RC_MODE) #define POWEROFF_BUTTON BUTTON_POWER +#define POWEROFF_NOW_BUTTON BUTTON_HOLD_ON #define RC_POWEROFF_BUTTON BUTTON_RC_PLAY #define POWEROFF_COUNT 30 Index: trunk/firmware/target/coldfire/iaudio/m5/button-m5.c =================================================================== --- trunk.orig/firmware/target/coldfire/iaudio/m5/button-m5.c +++ trunk/firmware/target/coldfire/iaudio/m5/button-m5.c @@ -156,5 +156,8 @@ int button_read_device(void) if (!remote_hold_button && !(data & 0x02000000)) btn |= BUTTON_RC_PLAY; + if (hold_button) + btn |= BUTTON_HOLD_ON; + return btn; } Index: trunk/firmware/target/coldfire/iaudio/x5/button-x5.c =================================================================== --- trunk.orig/firmware/target/coldfire/iaudio/x5/button-x5.c +++ trunk/firmware/target/coldfire/iaudio/x5/button-x5.c @@ -156,5 +156,8 @@ int button_read_device(void) if (!remote_hold_button && !(data & 0x02000000)) btn |= BUTTON_RC_PLAY; + if (hold_button) + btn |= BUTTON_HOLD_ON; + return btn; }