1
0
Fork 0
forked from len0rd/rockbox

Patch #4913 by David Rothenberger with some changes by me: add only backlight on first keypress to the lcd remotes, too.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9253 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Hristo Kovachev 2006-03-25 19:16:45 +00:00
parent 7b9ab84e7d
commit a70c6b9b1e
9 changed files with 180 additions and 10 deletions

View file

@ -297,11 +297,18 @@ static const struct bit_entry rtc_bits[] =
#endif
#ifdef CONFIG_BACKLIGHT
{1, S_O(bl_filter_first_keypress),
#ifdef HAVE_LCD_COLOR
{1, S_O(bl_filter_first_keypress), true, "backlight filters first keypress", off_on },
true,
#else
{1, S_O(bl_filter_first_keypress), false, "backlight filters first keypress", off_on },
false,
#endif
"backlight filters first keypress", off_on },
#ifdef HAVE_REMOTE_LCD
{1, S_O(remote_bl_filter_first_keypress), false,
"backlight filters first remote keypress", off_on },
#endif
#endif
/* new stuff to be added here */
@ -1126,6 +1133,9 @@ void settings_apply(void)
#ifdef CONFIG_BACKLIGHT
set_backlight_filter_keypress(global_settings.bl_filter_first_keypress);
#ifdef HAVE_REMOTE_LCD
set_remote_backlight_filter_keypress(global_settings.remote_bl_filter_first_keypress);
#endif
#endif
}

View file

@ -475,6 +475,9 @@ struct user_settings
#ifdef CONFIG_BACKLIGHT
bool bl_filter_first_keypress; /* filter first keypress when dark? */
#ifdef HAVE_REMOTE_LCD
bool remote_bl_filter_first_keypress; /* filter first remote keypress when remote dark? */
#endif
#endif
};

View file

@ -1082,6 +1082,15 @@ static bool set_bl_filter_first_keypress(void)
set_backlight_filter_keypress(global_settings.bl_filter_first_keypress);
return result;
}
#ifdef HAVE_REMOTE_LCD
static bool set_remote_bl_filter_first_keypress(void)
{
bool result = set_bool( str(LANG_BACKLIGHT_FILTER_FIRST_KEYPRESS),
&global_settings.remote_bl_filter_first_keypress );
set_remote_backlight_filter_keypress(global_settings.remote_bl_filter_first_keypress);
return result;
}
#endif
#endif
static bool ff_rewind_accel(void)
@ -1694,6 +1703,7 @@ static bool lcd_remote_settings_menu(void)
remote_backlight_timer_plugged },
#endif
{ ID2P(LANG_CAPTION_BACKLIGHT), remote_caption_backlight },
{ ID2P(LANG_BACKLIGHT_FILTER_FIRST_KEYPRESS), set_remote_bl_filter_first_keypress },
{ ID2P(LANG_CONTRAST), remote_contrast },
{ ID2P(LANG_INVERT), remote_invert },
{ ID2P(LANG_FLIP_DISPLAY), remote_flip_display },

View file

@ -187,3 +187,4 @@ Fredrik Öhrn
Nicolas Pennequin
Ralf Herz
Michael DiFebbo
David Rothenberger

View file

@ -597,6 +597,32 @@ void remote_backlight_set_timeout_plugged(int index)
remote_backlight_on();
}
#endif
/* return value in ticks; 0 means always on, <0 means always off */
int remote_backlight_get_current_timeout(void)
{
#ifdef HAVE_CHARGING
if (charger_inserted()
#ifdef HAVE_USB_POWER
|| usb_powered()
#endif
)
return remote_backlight_timeout_plugged;
else
return remote_backlight_timeout;
#else
return remote_backlight_timeout;
#endif
}
bool is_remote_backlight_on(void)
{
if (remote_backlight_timer != 0 || !remote_backlight_get_current_timeout())
return true;
else
return false;
}
#endif /* HAVE_REMOTE_LCD */
#else /* no backlight, empty dummy functions */
@ -620,6 +646,7 @@ bool is_backlight_on(void) {return true;}
void remote_backlight_on(void) {}
void remote_backlight_off(void) {}
void remote_backlight_set_timeout(int index) {(void)index;}
bool is_remote_backlight_on(void) {return true;}
#endif
#endif /* #ifdef CONFIG_BACKLIGHT */

View file

@ -40,8 +40,7 @@
#include "system.h"
#include "powermgmt.h"
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) \
|| (CONFIG_KEYPAD == IRIVER_H300_PAD)
#ifdef HAVE_REMOTE_LCD
#include "lcd-remote.h"
#endif
@ -54,6 +53,9 @@ static bool flipped; /* buttons can be flipped to match the LCD flip */
#endif
#ifdef CONFIG_BACKLIGHT
static bool filter_first_keypress;
#ifdef HAVE_REMOTE_LCD
static bool remote_filter_first_keypress;
#endif
#endif
/* how often we check to see if a button is pressed */
@ -403,6 +405,12 @@ static void button_tick(void)
static int repeat_count = 0;
static bool repeat = false;
static bool post = false;
#ifdef CONFIG_BACKLIGHT
static bool skip_release = false;
#ifdef HAVE_REMOTE_LCD
static bool skip_remote_release = false;
#endif
#endif
int diff;
int btn;
@ -425,7 +433,22 @@ static void button_tick(void)
diff = btn ^ lastbtn;
if(diff && (btn & diff) == 0)
{
#ifdef CONFIG_BACKLIGHT
#ifdef HAVE_REMOTE_LCD
if(diff & BUTTON_REMOTE)
if(!skip_remote_release)
queue_post(&button_queue, BUTTON_REL | diff, NULL);
else
skip_remote_release = false;
else
#endif
if(!skip_release)
queue_post(&button_queue, BUTTON_REL | diff, NULL);
else
skip_release = false;
#else
queue_post(&button_queue, BUTTON_REL | diff, NULL);
#endif
}
else
{
@ -502,15 +525,44 @@ static void button_tick(void)
{
queue_post(
&button_queue, BUTTON_REPEAT | btn, NULL);
#ifdef CONFIG_BACKLIGHT
#ifdef HAVE_REMOTE_LCD
if(btn & BUTTON_REMOTE)
{
if(skip_remote_release)
skip_remote_release = false;
}
else
#endif
if(skip_release)
skip_release = false;
#endif
post = false;
}
}
else
{
#ifdef CONFIG_BACKLIGHT
if ( !filter_first_keypress || is_backlight_on())
#ifdef HAVE_REMOTE_LCD
if (btn & BUTTON_REMOTE) {
if (!remote_filter_first_keypress || is_remote_backlight_on()
#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
||(remote_type()==REMOTETYPE_H300_NONLCD)
#endif
)
queue_post(&button_queue, btn, NULL);
else
skip_remote_release = true;
}
else
#endif
if (!filter_first_keypress || is_backlight_on())
queue_post(&button_queue, btn, NULL);
else
skip_release = true;
#else /* no backlight, nothing to skip */
queue_post(&button_queue, btn, NULL);
#endif
post = false;
}
#ifdef HAVE_REMOTE_LCD
@ -637,6 +689,9 @@ void button_init(void)
#endif
#ifdef CONFIG_BACKLIGHT
filter_first_keypress = false;
#ifdef HAVE_REMOTE_LCD
remote_filter_first_keypress = false;
#endif
#endif
}
@ -701,6 +756,12 @@ void set_backlight_filter_keypress(bool value)
{
filter_first_keypress = value;
}
#ifdef HAVE_REMOTE_LCD
void set_remote_backlight_filter_keypress(bool value)
{
remote_filter_first_keypress = value;
}
#endif
#endif
/*

View file

@ -43,6 +43,7 @@ void remote_backlight_on(void);
void remote_backlight_off(void);
void remote_backlight_set_timeout(int index);
void remote_backlight_set_timeout_plugged(int index);
bool is_remote_backlight_on(void);
#endif
#ifdef SIMULATOR

View file

@ -44,6 +44,9 @@ void button_set_flip(bool flip); /* turn 180 degrees */
#endif
#ifdef CONFIG_BACKLIGHT
void set_backlight_filter_keypress(bool value);
#ifdef HAVE_REMOTE_LCD
void set_remote_backlight_filter_keypress(bool value);
#endif
#endif
#ifdef HAS_BUTTON_HOLD

View file

@ -44,6 +44,14 @@ void set_backlight_filter_keypress(bool value)
{
filter_first_keypress = value;
}
#ifdef HAVE_REMOTE_LCD
static bool remote_filter_first_keypress;
void set_remote_backlight_filter_keypress(bool value)
{
remote_filter_first_keypress = value;
}
#endif
#endif
void button_event(int key, bool pressed)
@ -56,6 +64,12 @@ void button_event(int key, bool pressed)
static int repeat_count = 0;
static bool repeat = false;
static bool post = false;
#ifdef CONFIG_BACKLIGHT
static bool skip_release = false;
#ifdef HAVE_REMOTE_LCD
static bool skip_remote_release = false;
#endif
#endif
switch (key)
{
@ -169,11 +183,26 @@ void button_event(int key, bool pressed)
/* Find out if a key has been released */
diff = btn ^ lastbtn;
if(diff && (btn & diff) == 0)
{
#ifdef CONFIG_BACKLIGHT
#ifdef HAVE_REMOTE_LCD
if(diff & BUTTON_REMOTE)
if(!skip_remote_release)
queue_post(&button_queue, BUTTON_REL | diff, NULL);
else
skip_remote_release = false;
else
#endif
if(!skip_release)
queue_post(&button_queue, BUTTON_REL | diff, NULL);
else
skip_release = false;
#else
queue_post(&button_queue, BUTTON_REL | diff, NULL);
#endif
}
else
{
if ( btn )
@ -223,15 +252,40 @@ void button_event(int key, bool pressed)
if (queue_empty(&button_queue))
{
queue_post(&button_queue, BUTTON_REPEAT | btn, NULL);
#ifdef CONFIG_BACKLIGHT
#ifdef HAVE_REMOTE_LCD
if(btn & BUTTON_REMOTE)
{
if(skip_remote_release)
skip_remote_release = false;
}
else
#endif
if(skip_release)
skip_release = false;
#endif
post = false;
}
}
else
{
#ifdef CONFIG_BACKLIGHT
if ( !filter_first_keypress || is_backlight_on())
#endif
#ifdef HAVE_REMOTE_LCD
if (btn & BUTTON_REMOTE) {
if (!remote_filter_first_keypress || is_remote_backlight_on())
queue_post(&button_queue, btn, NULL);
else
skip_remote_release = true;
}
else
#endif
if (!filter_first_keypress || is_backlight_on())
queue_post(&button_queue, btn, NULL);
else
skip_release = true;
#else /* no backlight, nothing to skip */
queue_post(&button_queue, btn, NULL);
#endif
post = false;
}