summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2012-01-12 22:28:36 +1100
committerJonathan Gordon <rockbox@jdgordon.info>2012-01-12 22:28:36 +1100
commiteb2ea7f9ad4c4e2cce390f8fe73e17698fa9a906 (patch)
tree64cd1f227d75a5758b52d9b49ae7bdf23f6dbf83
parent5ef27368f1bcbe31fb27072983d7a29df8de6845 (diff)
downloadrockbox-eb2ea7f9ad4c4e2cce390f8fe73e17698fa9a906.tar.gz
rockbox-eb2ea7f9ad4c4e2cce390f8fe73e17698fa9a906.zip
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
-rw-r--r--apps/action.c12
-rw-r--r--apps/gui/list.c22
-rw-r--r--apps/gui/list.h4
-rw-r--r--apps/menu.c3
-rw-r--r--apps/misc.c20
-rw-r--r--apps/misc.h4
-rw-r--r--apps/tree.c3
7 files changed, 59 insertions, 9 deletions
diff --git a/apps/action.c b/apps/action.c
index e192daae4e..44980cdd9e 100644
--- a/apps/action.c
+++ b/apps/action.c
@@ -246,12 +246,6 @@ static int get_action_worker(int context, int timeout,
246 return ACTION_NONE; 246 return ACTION_NONE;
247 } 247 }
248 248
249
250#if CONFIG_CODEC == SWCODEC
251 /* Produce keyclick */
252 keyclick_click(button);
253#endif
254
255 if ((context != last_context) && ((last_button & BUTTON_REL) == 0) 249 if ((context != last_context) && ((last_button & BUTTON_REL) == 0)
256#ifdef HAVE_SCROLLWHEEL 250#ifdef HAVE_SCROLLWHEEL
257 /* Scrollwheel doesn't generate release events */ 251 /* Scrollwheel doesn't generate release events */
@@ -371,6 +365,12 @@ static int get_action_worker(int context, int timeout,
371 last_action = ret; 365 last_action = ret;
372 last_data = button_get_data(); 366 last_data = button_get_data();
373 last_action_tick = current_tick; 367 last_action_tick = current_tick;
368
369#if CONFIG_CODEC == SWCODEC
370 /* Produce keyclick */
371 keyclick_click(ret);
372#endif
373
374 return ret; 374 return ret;
375} 375}
376 376
diff --git a/apps/gui/list.c b/apps/gui/list.c
index c53a1f559c..d1b2748a60 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -576,6 +576,25 @@ static void gui_synclist_scroll_left(struct gui_synclist * lists)
576} 576}
577#endif /* HAVE_LCD_BITMAP */ 577#endif /* HAVE_LCD_BITMAP */
578 578
579#if CONFIG_CODEC == SWCODEC
580bool gui_synclist_keyclick_callback(int action, void* data)
581{
582 struct gui_synclist *lists = (struct gui_synclist *)data;
583
584 /* block the beep if we are at the end of the list and we are not wrapping.
585 * CAVEAT: mosts lists don't set limit_scroll untill it sees a repeat
586 * press at the end of the list so this can cause an extra beep.
587 */
588 if (lists->limit_scroll == false)
589 return true;
590 if (lists->selected_item == 0)
591 return (action != ACTION_STD_PREV && action != ACTION_STD_PREVREPEAT);
592 if (lists->selected_item == lists->nb_items - lists->selected_size)
593 return (action != ACTION_STD_NEXT && action != ACTION_STD_NEXTREPEAT);
594
595 return action != ACTION_NONE;
596}
597#endif
579 598
580bool gui_synclist_do_button(struct gui_synclist * lists, 599bool gui_synclist_do_button(struct gui_synclist * lists,
581 int *actionptr, enum list_wrap wrap) 600 int *actionptr, enum list_wrap wrap)
@@ -774,6 +793,9 @@ bool list_do_action(int context, int timeout,
774 do_button, and places the action from get_action in *action. */ 793 do_button, and places the action from get_action in *action. */
775{ 794{
776 timeout = list_do_action_timeout(lists, timeout); 795 timeout = list_do_action_timeout(lists, timeout);
796#if CONFIG_CODEC == SWCODEC
797 keyclick_set_callback(gui_synclist_keyclick_callback, lists);
798#endif
777 *action = get_action(context, timeout); 799 *action = get_action(context, timeout);
778 return gui_synclist_do_button(lists, action, wrap); 800 return gui_synclist_do_button(lists, action, wrap);
779} 801}
diff --git a/apps/gui/list.h b/apps/gui/list.h
index c53604659e..d9df008956 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -165,6 +165,10 @@ extern void gui_synclist_set_title(struct gui_synclist * lists, char * title,
165 enum themable_icons icon); 165 enum themable_icons icon);
166extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists, 166extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists,
167 bool hide); 167 bool hide);
168
169#if CONFIG_CODEC == SWCODEC
170extern bool gui_synclist_keyclick_callback(int action, void* data);
171#endif
168/* 172/*
169 * Do the action implied by the given button, 173 * Do the action implied by the given button,
170 * returns true if the action was handled. 174 * returns true if the action was handled.
diff --git a/apps/menu.c b/apps/menu.c
index a1e32f4625..ae318b2ffc 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -381,6 +381,9 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
381 gui_buttonbar_draw(&buttonbar); 381 gui_buttonbar_draw(&buttonbar);
382#endif 382#endif
383 } 383 }
384#if CONFIG_CODEC == SWCODEC
385 keyclick_set_callback(gui_synclist_keyclick_callback, &lists);
386#endif
384 action = get_action(CONTEXT_MAINMENU, 387 action = get_action(CONTEXT_MAINMENU,
385 list_do_action_timeout(&lists, HZ)); 388 list_do_action_timeout(&lists, HZ));
386 389
diff --git a/apps/misc.c b/apps/misc.c
index 3c55395a42..52e891e0c2 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -876,12 +876,23 @@ void system_sound_play(enum system_sound sound)
876 params->amplitude * *params->setting); 876 params->amplitude * *params->setting);
877 } 877 }
878} 878}
879 879
880static keyclick_callback keyclick_current_callback = NULL;
881static void* keyclick_data = NULL;
882void keyclick_set_callback(keyclick_callback cb, void* data)
883{
884 keyclick_current_callback = cb;
885 keyclick_data = data;
886}
887
880/* Produce keyclick based upon button and global settings */ 888/* Produce keyclick based upon button and global settings */
881void keyclick_click(int button) 889void keyclick_click(int action)
882{ 890{
891 int button;
883 static long last_button = BUTTON_NONE; 892 static long last_button = BUTTON_NONE;
884 bool do_beep = false; 893 bool do_beep = false;
894
895 get_action_statuscode(&button);
885 /* Settings filters */ 896 /* Settings filters */
886 if ( 897 if (
887#ifdef HAVE_HARDWARE_CLICK 898#ifdef HAVE_HARDWARE_CLICK
@@ -915,6 +926,11 @@ void keyclick_click(int button)
915 last_button = button; 926 last_button = button;
916 else 927 else
917 last_button = BUTTON_NONE; 928 last_button = BUTTON_NONE;
929
930 if (do_beep && keyclick_current_callback)
931 do_beep = keyclick_current_callback(action, keyclick_data);
932 keyclick_current_callback = NULL;
933
918 if (do_beep) 934 if (do_beep)
919 { 935 {
920#ifdef HAVE_HARDWARE_CLICK 936#ifdef HAVE_HARDWARE_CLICK
diff --git a/apps/misc.h b/apps/misc.h
index 2206894304..a41a8319ac 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -144,8 +144,10 @@ enum system_sound
144/* Play a standard sound */ 144/* Play a standard sound */
145void system_sound_play(enum system_sound sound); 145void system_sound_play(enum system_sound sound);
146 146
147typedef bool (*keyclick_callback)(int action, void* data);
148void keyclick_set_callback(keyclick_callback cb, void* data);
147/* Produce keyclick based upon button and global settings */ 149/* Produce keyclick based upon button and global settings */
148void keyclick_click(int button); 150void keyclick_click(int action);
149#endif /* CONFIG_CODEC == SWCODEC */ 151#endif /* CONFIG_CODEC == SWCODEC */
150 152
151void push_current_activity(enum current_activity screen); 153void push_current_activity(enum current_activity screen);
diff --git a/apps/tree.c b/apps/tree.c
index 4431db2c4a..cc080ac7fa 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -652,6 +652,9 @@ static int dirbrowse(void)
652 if (tc.dirlevel < 0) 652 if (tc.dirlevel < 0)
653 tc.dirlevel = 0; /* shouldnt be needed.. this code needs work! */ 653 tc.dirlevel = 0; /* shouldnt be needed.. this code needs work! */
654 654
655#if CONFIG_CODEC == SWCODEC
656 keyclick_set_callback(gui_synclist_keyclick_callback, &tree_lists);
657#endif
655 button = get_action(CONTEXT_TREE, 658 button = get_action(CONTEXT_TREE,
656 list_do_action_timeout(&tree_lists, HZ/2)); 659 list_do_action_timeout(&tree_lists, HZ/2));
657#ifdef HAVE_LCD_BITMAP 660#ifdef HAVE_LCD_BITMAP