keyclick: Add a callback so screens can cancel a click. Add a generic list callback to stop clicks when we are at the end of the list
Change-Id: Iabb44a861dd7506cd883c1bdb0241303fa646746
This commit is contained in:
parent
5ef27368f1
commit
eb2ea7f9ad
7 changed files with 60 additions and 10 deletions
|
@ -246,12 +246,6 @@ static int get_action_worker(int context, int timeout,
|
|||
return ACTION_NONE;
|
||||
}
|
||||
|
||||
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
/* Produce keyclick */
|
||||
keyclick_click(button);
|
||||
#endif
|
||||
|
||||
if ((context != last_context) && ((last_button & BUTTON_REL) == 0)
|
||||
#ifdef HAVE_SCROLLWHEEL
|
||||
/* Scrollwheel doesn't generate release events */
|
||||
|
@ -371,6 +365,12 @@ static int get_action_worker(int context, int timeout,
|
|||
last_action = ret;
|
||||
last_data = button_get_data();
|
||||
last_action_tick = current_tick;
|
||||
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
/* Produce keyclick */
|
||||
keyclick_click(ret);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -576,6 +576,25 @@ static void gui_synclist_scroll_left(struct gui_synclist * lists)
|
|||
}
|
||||
#endif /* HAVE_LCD_BITMAP */
|
||||
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
bool gui_synclist_keyclick_callback(int action, void* data)
|
||||
{
|
||||
struct gui_synclist *lists = (struct gui_synclist *)data;
|
||||
|
||||
/* block the beep if we are at the end of the list and we are not wrapping.
|
||||
* CAVEAT: mosts lists don't set limit_scroll untill it sees a repeat
|
||||
* press at the end of the list so this can cause an extra beep.
|
||||
*/
|
||||
if (lists->limit_scroll == false)
|
||||
return true;
|
||||
if (lists->selected_item == 0)
|
||||
return (action != ACTION_STD_PREV && action != ACTION_STD_PREVREPEAT);
|
||||
if (lists->selected_item == lists->nb_items - lists->selected_size)
|
||||
return (action != ACTION_STD_NEXT && action != ACTION_STD_NEXTREPEAT);
|
||||
|
||||
return action != ACTION_NONE;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool gui_synclist_do_button(struct gui_synclist * lists,
|
||||
int *actionptr, enum list_wrap wrap)
|
||||
|
@ -774,6 +793,9 @@ bool list_do_action(int context, int timeout,
|
|||
do_button, and places the action from get_action in *action. */
|
||||
{
|
||||
timeout = list_do_action_timeout(lists, timeout);
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
keyclick_set_callback(gui_synclist_keyclick_callback, lists);
|
||||
#endif
|
||||
*action = get_action(context, timeout);
|
||||
return gui_synclist_do_button(lists, action, wrap);
|
||||
}
|
||||
|
|
|
@ -165,6 +165,10 @@ extern void gui_synclist_set_title(struct gui_synclist * lists, char * title,
|
|||
enum themable_icons icon);
|
||||
extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists,
|
||||
bool hide);
|
||||
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
extern bool gui_synclist_keyclick_callback(int action, void* data);
|
||||
#endif
|
||||
/*
|
||||
* Do the action implied by the given button,
|
||||
* returns true if the action was handled.
|
||||
|
|
|
@ -381,6 +381,9 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
|
|||
gui_buttonbar_draw(&buttonbar);
|
||||
#endif
|
||||
}
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
keyclick_set_callback(gui_synclist_keyclick_callback, &lists);
|
||||
#endif
|
||||
action = get_action(CONTEXT_MAINMENU,
|
||||
list_do_action_timeout(&lists, HZ));
|
||||
|
||||
|
|
22
apps/misc.c
22
apps/misc.c
|
@ -876,12 +876,23 @@ void system_sound_play(enum system_sound sound)
|
|||
params->amplitude * *params->setting);
|
||||
}
|
||||
}
|
||||
|
||||
/* Produce keyclick based upon button and global settings */
|
||||
void keyclick_click(int button)
|
||||
|
||||
static keyclick_callback keyclick_current_callback = NULL;
|
||||
static void* keyclick_data = NULL;
|
||||
void keyclick_set_callback(keyclick_callback cb, void* data)
|
||||
{
|
||||
keyclick_current_callback = cb;
|
||||
keyclick_data = data;
|
||||
}
|
||||
|
||||
/* Produce keyclick based upon button and global settings */
|
||||
void keyclick_click(int action)
|
||||
{
|
||||
int button;
|
||||
static long last_button = BUTTON_NONE;
|
||||
bool do_beep = false;
|
||||
|
||||
get_action_statuscode(&button);
|
||||
/* Settings filters */
|
||||
if (
|
||||
#ifdef HAVE_HARDWARE_CLICK
|
||||
|
@ -915,6 +926,11 @@ void keyclick_click(int button)
|
|||
last_button = button;
|
||||
else
|
||||
last_button = BUTTON_NONE;
|
||||
|
||||
if (do_beep && keyclick_current_callback)
|
||||
do_beep = keyclick_current_callback(action, keyclick_data);
|
||||
keyclick_current_callback = NULL;
|
||||
|
||||
if (do_beep)
|
||||
{
|
||||
#ifdef HAVE_HARDWARE_CLICK
|
||||
|
|
|
@ -144,8 +144,10 @@ enum system_sound
|
|||
/* Play a standard sound */
|
||||
void system_sound_play(enum system_sound sound);
|
||||
|
||||
typedef bool (*keyclick_callback)(int action, void* data);
|
||||
void keyclick_set_callback(keyclick_callback cb, void* data);
|
||||
/* Produce keyclick based upon button and global settings */
|
||||
void keyclick_click(int button);
|
||||
void keyclick_click(int action);
|
||||
#endif /* CONFIG_CODEC == SWCODEC */
|
||||
|
||||
void push_current_activity(enum current_activity screen);
|
||||
|
|
|
@ -652,6 +652,9 @@ static int dirbrowse(void)
|
|||
if (tc.dirlevel < 0)
|
||||
tc.dirlevel = 0; /* shouldnt be needed.. this code needs work! */
|
||||
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
keyclick_set_callback(gui_synclist_keyclick_callback, &tree_lists);
|
||||
#endif
|
||||
button = get_action(CONTEXT_TREE,
|
||||
list_do_action_timeout(&tree_lists, HZ/2));
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
|
|
Loading…
Reference in a new issue