From 07417e4882242f0499bb31e099bedf728f017a32 Mon Sep 17 00:00:00 2001 From: kugel Date: Tue, 19 Jan 2010 22:07:28 +0000 Subject: [PATCH] Fix FS#10867 and a few more potential issues by imitate target scrollwheel behavior more (although that behavior is suboptimal imo). Also, default for maximum backlight brightness in the sim and move stuff into sim.h. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24289 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/config.h | 6 ++---- firmware/export/config/sim.h | 16 ++++++++++++++++ uisimulator/common/backlight-sim.c | 17 +++++++++++------ uisimulator/sdl/button.c | 7 +++++++ 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/firmware/export/config.h b/firmware/export/config.h index 81e83b09f..a4940a068 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -567,10 +567,8 @@ Lyre prototype 1 */ #define CONFIG_TUNER_MULTI #endif -/* deactivate fading in bootloader/sim */ -#if defined(BOOTLOADER) || (defined(SIMULATOR) && \ - (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_PWM || \ - CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_TARGET)) +/* deactivate fading in bootloader */ +#if defined(BOOTLOADER) #undef CONFIG_BACKLIGHT_FADING #define CONFIG_BACKLIGHT_FADING BACKLIGHT_NO_FADING #endif diff --git a/firmware/export/config/sim.h b/firmware/export/config/sim.h index ec398c8b2..56c3e1822 100644 --- a/firmware/export/config/sim.h +++ b/firmware/export/config/sim.h @@ -79,3 +79,19 @@ #undef HAVE_SPEAKER +#if CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG +#undef CONFIG_BACKLIGHT_FADING + /* simulate SW_SETTING, as we handle sdl very similary */ +#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING + +#elif (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_PWM || \ + CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_TARGET) + /* we don't simulate that yet */ +#undef CONFIG_BACKLIGHT_FADING +#endif + +#ifdef HAVE_BACKLIGHT_BRIGHTNESS +#undef DEFAULT_BRIGHTNESS_SETTING +/* default for 100% in the sim */ +#define DEFAULT_BRIGHTNESS_SETTING MAX_BRIGHTNESS_SETTING +#endif diff --git a/uisimulator/common/backlight-sim.c b/uisimulator/common/backlight-sim.c index 74a715a03..aa8fe8e84 100644 --- a/uisimulator/common/backlight-sim.c +++ b/uisimulator/common/backlight-sim.c @@ -30,7 +30,11 @@ extern void lcd_awake(void); /* in uisimulator/sdl/lcd-bitmap.c and lcd-charcell.c */ extern void sim_backlight(int value); -static int old_val = 100; +static inline int normalize_backlight(int val) +{ + /* normalize to xx% brightness for sdl */ + return ((val - MIN_BRIGHTNESS_SETTING + 1) * 100)/MAX_BRIGHTNESS_SETTING; +} bool _backlight_init(void) { @@ -39,12 +43,16 @@ bool _backlight_init(void) void _backlight_on(void) { - sim_backlight(old_val); #if defined(HAVE_LCD_ENABLE) lcd_enable(true); #elif defined(HAVE_LCD_SLEEP) lcd_awake(); #endif +#if (CONFIG_BACKLIGHT_FADING != BACKLIGHT_FADING_SW_SETTING) + /* if we set the brightness to the settings value, then fading up + * is glitchy */ + sim_backlight(normalize_backlight(backlight_brightness)); +#endif } void _backlight_off(void) @@ -58,10 +66,7 @@ void _backlight_off(void) #ifdef HAVE_BACKLIGHT_BRIGHTNESS void _backlight_set_brightness(int val) { - int normalized = ((val - MIN_BRIGHTNESS_SETTING + 1) * 100) / MAX_BRIGHTNESS_SETTING; - sim_backlight(normalized); - - old_val = normalized; + sim_backlight(normalize_backlight(val)); } #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ #ifdef HAVE_BUTTON_LIGHT diff --git a/uisimulator/sdl/button.c b/uisimulator/sdl/button.c index fdabfcf5a..0f9770dca 100644 --- a/uisimulator/sdl/button.c +++ b/uisimulator/sdl/button.c @@ -29,6 +29,7 @@ #include "misc.h" #include "sim_tasks.h" #include "button-sdl.h" +#include "backlight.h" #include "debug.h" @@ -1275,6 +1276,12 @@ void button_event(int key, bool pressed) * store the scroll forward/back buttons in their button data for * the button_read call. */ +#ifdef HAVE_BACKLIGHT + backlight_on(); +#endif +#ifdef HAVE_BUTTON_LIGHT + buttonlight_on(); +#endif queue_post(&button_queue, new_btn, 1<<24); new_btn &= ~(BUTTON_SCROLL_FWD | BUTTON_SCROLL_BACK); } -- 2.11.4.GIT