Index: apps/plugins/lamp.c =================================================================== --- apps/plugins/lamp.c (Revision 19940) +++ apps/plugins/lamp.c (Arbeitskopie) @@ -28,29 +28,41 @@ PLUGIN_HEADER #if defined(HAVE_BACKLIGHT) -/* variable button definitions - only targets with a colour display */ -#if defined(HAVE_LCD_COLOR) + +/* Variable button definitions. All targets should define LAMP_QUIT (and + LAMP_R_QUIT, if a remote is available) to quit. + Targets with a colour display should also define LAMP_LEFT and LAMP_RIGHT + to switch the colour back and forth. If there are other buttons to switch + the colour, LAMP_PREV and LAMP_NEXT can be defined. + */ + #if (CONFIG_KEYPAD == IRIVER_H300_PAD) # define LAMP_LEFT BUTTON_LEFT # define LAMP_RIGHT BUTTON_RIGHT +# define LAMP_QUIT BUTTON_OFF +# define LAMP_R_QUIT BUTTON_RC_STOP #elif (CONFIG_KEYPAD == IPOD_4G_PAD) # define LAMP_LEFT BUTTON_LEFT # define LAMP_RIGHT BUTTON_RIGHT # define LAMP_NEXT BUTTON_SCROLL_FWD # define LAMP_PREV BUTTON_SCROLL_BACK +# define LAMP_QUIT BUTTON_MENU #elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD) # define LAMP_LEFT BUTTON_LEFT # define LAMP_RIGHT BUTTON_RIGHT +# define LAMP_QUIT BUTTON_POWER #elif (CONFIG_KEYPAD == GIGABEAT_PAD) # define LAMP_LEFT BUTTON_LEFT # define LAMP_RIGHT BUTTON_RIGHT +# define LAMP_QUIT BUTTON_POWER #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) # define LAMP_LEFT BUTTON_LEFT # define LAMP_RIGHT BUTTON_RIGHT +# define LAMP_QUIT BUTTON_BACK #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \ (CONFIG_KEYPAD == SANSA_FUZE_PAD) @@ -58,35 +70,63 @@ # define LAMP_RIGHT BUTTON_RIGHT # define LAMP_NEXT BUTTON_SCROLL_FWD # define LAMP_PREV BUTTON_SCROLL_BACK +# define LAMP_QUIT BUTTON_POWER #elif (CONFIG_KEYPAD == SANSA_C200_PAD) # define LAMP_LEFT BUTTON_LEFT # define LAMP_RIGHT BUTTON_RIGHT +# define LAMP_QUIT BUTTON_POWER #elif (CONFIG_KEYPAD == IRIVER_H10_PAD) # define LAMP_LEFT BUTTON_LEFT # define LAMP_RIGHT BUTTON_RIGHT # define LAMP_NEXT BUTTON_SCROLL_UP # define LAMP_PREV BUTTON_SCROLL_DOWN +# define LAMP_QUIT BUTTON_POWER #elif CONFIG_KEYPAD == MROBE500_PAD # define LAMP_LEFT BUTTON_LEFT # define LAMP_RIGHT BUTTON_RIGHT +# define LAMP_QUIT BUTTON_POWER #elif CONFIG_KEYPAD == COWOND2_PAD +# define LAMP_QUIT BUTTON_POWER #elif CONFIG_KEYPAD == IAUDIO67_PAD # define LAMP_LEFT BUTTON_LEFT # define LAMP_RIGHT BUTTON_RIGHT +# define LAMP_QUIT BUTTON_STOP #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD # define LAMP_LEFT BUTTON_LEFT # define LAMP_RIGHT BUTTON_RIGHT +# define LAMP_QUIT BUTTON_POWER + +/* Targets without colour LCD but with backlight */ +#elif (CONFIG_KEYPAD == IPOD_3G_PAD) || \ + (CONFIG_KEYPAD == IPOD_1G2G_PAD) +# define LAMP_QUIT BUTTON_MENU +#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) +# define LAMP_QUIT BUTTON_OFF +# define LAMP_R_QUIT BUTTON_RC_STOP + +#elif (CONFIG_KEYPAD == RECORDER_PAD) +# define LAMP_QUIT BUTTON_OFF + +#elif (CONFIG_KEYPAD == MROBE100_PAD) +# define LAMP_QUIT BUTTON_POWER + +#elif (CONFIG_KEYPAD == IAUDIO_M3_PAD) +# define LAMP_QUIT BUTTON_RC_REC +# define LAMP_R_QUIT BUTTON_REC + +#elif (CONFIG_KEYPAD == ONDIO_PAD) +# define LAMP_QUIT BUTTON_OFF + #else # error Missing key definitions for this keypad #endif -#endif #ifdef HAVE_TOUCHSCREEN # ifndef LAMP_LEFT @@ -115,10 +155,11 @@ { long button; (void)parameter; + bool quit = false; + bool usb_detected = false; #ifdef HAVE_LCD_COLOR int cs = 0; - bool quit = false; #endif /* HAVE_LCD_COLOR */ #ifdef HAVE_BACKLIGHT_BRIGHTNESS @@ -157,9 +198,9 @@ buttonlight_force_on(); #endif /* HAVE_BUTTON_LIGHT */ -#ifdef HAVE_LCD_COLOR do { +#ifdef HAVE_LCD_COLOR if(cs < 0) cs = NUM_COLORSETS-1; if(cs >= NUM_COLORSETS) @@ -169,9 +210,21 @@ colorset[cs][2] ) ); rb->lcd_clear_display(); rb->lcd_update(); +#endif /* HAVE_LCD_COLOR */ switch((button = rb->button_get(true))) { + case LAMP_QUIT: +#ifdef LAMP_R_QUIT + case LAMP_R_QUIT: +#endif /* LAMP_R_QUIT */ + quit = true; + break; + +#ifdef HAVE_LCD_COLOR + +/* If we have a colour display, let the user to switch the colour */ + case LAMP_RIGHT: #ifdef LAMP_NEXT case LAMP_NEXT: @@ -199,27 +252,20 @@ case (LAMP_PREV|BUTTON_REL): #endif /* LAMP_PREV */ /* eat these... */ - break; + break; + +#endif /* HAVE_LCD_COLOR */ + default: - if (IS_SYSEVENT(button)) + if(rb->default_event_handler(button) == SYS_USB_CONNECTED) + { + usb_detected = true; quit = true; + } } } while (!quit); -#else /* HAVE_LCD_COLOR */ - rb->lcd_clear_display(); - rb->lcd_update(); - /* wait */ - do - { - button = rb->button_get(false); - if (button && !IS_SYSEVENT(button)) - break; - rb->yield(); - } while (1); -#endif /*HAVE_LCD_COLOR */ - /* restore */ backlight_use_settings(); #ifdef HAVE_BUTTON_LIGHT @@ -240,6 +286,6 @@ #if LCD_DEPTH > 1 rb->lcd_set_background(bg_color); #endif - return PLUGIN_OK; + return (usb_detected ? PLUGIN_USB_CONNECTED : PLUGIN_OK); } #endif