Index: apps/action.c =================================================================== --- apps/action.c (Revision 18322) +++ apps/action.c (Arbeitskopie) @@ -90,6 +90,14 @@ CONTEXT_STD : items[i].action_code; } + +static bool backlight_on_keypress_oracle(int btn) +{ + /* TODO: check whether the button would fire an action */ + /* If yes, check whether that action should turn on the backlight */ + return true; +} + /* * int get_action_worker(int context, struct button_mapping *user_mappings, int timeout) @@ -115,6 +123,8 @@ int ret = ACTION_UNKNOWN; static int last_context = CONTEXT_STD; + set_backlight_on_keypress_oracle(backlight_on_keypress_oracle); + if (timeout == TIMEOUT_NOBLOCK) button = button_get(false); else if (timeout == TIMEOUT_BLOCK) Index: apps/action.h =================================================================== --- apps/action.h (Revision 18322) +++ apps/action.h (Arbeitskopie) @@ -237,6 +237,7 @@ int action_code; int button_code; int pre_button_code; + bool turn_on_backlight; }; /* use if you want to supply your own button mappings, PLUGINS ONLY */ /* get_context_map is a function which returns a button_mapping* depedning on the given context */ Index: firmware/export/button.h =================================================================== --- firmware/export/button.h (Revision 18322) +++ firmware/export/button.h (Arbeitskopie) @@ -43,6 +43,22 @@ #endif #ifdef HAVE_BACKLIGHT void set_backlight_filter_keypress(bool value); + +/* Callback function to tell whether the backlight should be turned on + * when a key is pressed. Called just after a key press. + * + * @param btn The button that was pressed + * + * Returns true iff the backlight should be turned on on key press. + */ +typedef bool (*backlight_on_keypress_oracle_func)(int btn); + +/* Sets the new 'oracle' to tell whether the backlight should be turned + * on when a key is pressed. Passing NULL as parameter will turn on the BL + * on every key press. + */ +void set_backlight_on_keypress_oracle(backlight_on_keypress_oracle_func func); + #ifdef HAVE_REMOTE_LCD void set_remote_backlight_filter_keypress(bool value); #endif Index: firmware/drivers/button.c =================================================================== --- firmware/drivers/button.c (Revision 18322) +++ firmware/drivers/button.c (Arbeitskopie) @@ -34,6 +34,7 @@ #include "power.h" #include "powermgmt.h" #include "button-target.h" +#include "debug.h" #ifdef HAVE_REMOTE_LCD #include "lcd-remote.h" @@ -58,6 +59,7 @@ #endif #ifdef HAVE_BACKLIGHT static bool filter_first_keypress; +static backlight_on_keypress_oracle_func backlight_on_keypress_oracle = NULL; #ifdef HAVE_REMOTE_LCD static bool remote_filter_first_keypress; #endif @@ -260,7 +262,7 @@ skip_remote_release = true; } else -#endif +#endif /* HAVE_REMOTE_LCD */ if (!filter_first_keypress || is_backlight_on(false) #if BUTTON_REMOTE || (btn & BUTTON_REMOTE) @@ -280,10 +282,24 @@ else #endif { - backlight_on(); + bool bl_on; + if (backlight_on_keypress_oracle != NULL) + { + bl_on = (*backlight_on_keypress_oracle)(btn); + DEBUGF("BL oracle (%d) returned: %d\n", btn, bl_on); + } + else + { + bl_on = true; + DEBUGF("BL callback is NULL -> bl ON\n"); + } + if (bl_on) + { + backlight_on(); #ifdef HAVE_BUTTON_LIGHT - buttonlight_on(); + buttonlight_on(); #endif + } } reset_poweroff_timer(); @@ -403,6 +419,7 @@ #endif #ifdef HAVE_BACKLIGHT filter_first_keypress = false; + set_backlight_on_keypress_oracle(NULL); #ifdef HAVE_REMOTE_LCD remote_filter_first_keypress = false; #endif @@ -488,6 +505,11 @@ { filter_first_keypress = value; } +void set_backlight_on_keypress_oracle(backlight_on_keypress_oracle_func new_value) +{ + backlight_on_keypress_oracle = new_value; +} + #ifdef HAVE_REMOTE_LCD void set_remote_backlight_filter_keypress(bool value) { Index: uisimulator/sdl/button.c =================================================================== --- uisimulator/sdl/button.c (Revision 18322) +++ uisimulator/sdl/button.c (Arbeitskopie) @@ -73,6 +73,13 @@ { filter_first_keypress = value; } +static backlight_on_keypress_oracle_func backlight_on_keypress_oracle = NULL; +void set_backlight_on_keypress_oracle(backlight_on_keypress_oracle_func new_value) +{ + backlight_on_keypress_oracle = new_value; +} + + #ifdef HAVE_REMOTE_LCD static bool remote_filter_first_keypress; @@ -1059,7 +1066,23 @@ remote_backlight_on(); else #endif - backlight_on(); + { + bool bl_on; + if (backlight_on_keypress_oracle != NULL) + { + bl_on = (*backlight_on_keypress_oracle)(btn); + DEBUGF("BL oracle (%d) returned: %d\n", btn, bl_on); + } + else + { + DEBUGF("BL callback is NULL -> bl ON\n"); + bl_on = true; + } + if (bl_on) + { + backlight_on(); + } + } } }