diff --git a/apps/bookmark.c b/apps/bookmark.c index b2c2713716..4522859f57 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c @@ -659,7 +659,7 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu } action = get_action(CONTEXT_BOOKMARKSCREEN, HZ / 2); - gui_synclist_do_button(&list, action, LIST_WRAP_UNLESS_HELD); + gui_synclist_do_button(&list, &action, LIST_WRAP_UNLESS_HELD); item = gui_synclist_get_sel_pos(&list) / 2; if (bookmarks->show_dont_resume) diff --git a/apps/cuesheet.c b/apps/cuesheet.c index 79a07a73c6..d5fbc54f73 100644 --- a/apps/cuesheet.c +++ b/apps/cuesheet.c @@ -296,7 +296,7 @@ void browse_cuesheet(struct cuesheet *cue) { gui_synclist_draw(&lists); action = get_action(CONTEXT_LIST,TIMEOUT_BLOCK); - if (gui_synclist_do_button(&lists,action,LIST_WRAP_UNLESS_HELD)) + if (gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD)) continue; switch (action) { diff --git a/apps/debug_menu.c b/apps/debug_menu.c index d5c0b8171d..40c0fcc9b0 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -162,7 +162,7 @@ static bool dbg_list(struct action_callback_info *info) { gui_syncstatusbar_draw(&statusbars, true); action = get_action(CONTEXT_STD, HZ/5); - if (gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD)) + if (gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD)) continue; if (info->action_callback) action = info->action_callback(action, info); diff --git a/apps/filetypes.c b/apps/filetypes.c index 21ce17ce40..5e72fca5a1 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c @@ -476,7 +476,7 @@ int filetype_list_viewers(const char* current_file) gui_syncstatusbar_draw(&statusbars, true); action = get_action(CONTEXT_MAINMENU,HZ); if ((action == ACTION_NONE) || - gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD)) + gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD)) continue; else if (action == ACTION_STD_OK) { diff --git a/apps/gui/list.c b/apps/gui/list.c index f12d8a3d91..a8bbce8cda 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -889,9 +889,10 @@ static void gui_synclist_scroll_left(struct gui_synclist * lists) extern intptr_t get_action_data(void); -unsigned gui_synclist_do_button(struct gui_synclist * lists, - unsigned button,enum list_wrap wrap) +bool gui_synclist_do_button(struct gui_synclist * lists, + unsigned *actionptr, enum list_wrap wrap) { + int action = *actionptr; #ifdef HAVE_LCD_BITMAP static bool scrolling_left = false; #endif @@ -937,16 +938,16 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, gui_synclist_limit_scroll(lists, true); break; case LIST_WRAP_UNLESS_HELD: - if (button == ACTION_STD_PREVREPEAT || - button == ACTION_STD_NEXTREPEAT || - button == ACTION_LISTTREE_PGUP || - button == ACTION_LISTTREE_PGDOWN) + if (action == ACTION_STD_PREVREPEAT || + action == ACTION_STD_NEXTREPEAT || + action == ACTION_LISTTREE_PGUP || + action == ACTION_LISTTREE_PGDOWN) gui_synclist_limit_scroll(lists, true); else gui_synclist_limit_scroll(lists, false); break; }; - switch(button) + switch (action) { #ifdef HAVE_VOLUME_IN_LIST case ACTION_LIST_VOLUP: @@ -955,7 +956,7 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, case ACTION_LIST_VOLDOWN: global_settings.volume--; setvol(); - return button; + return true; #endif case ACTION_STD_PREV: case ACTION_STD_PREVREPEAT: @@ -968,7 +969,8 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, gui_synclist_draw(lists); } yield(); - return ACTION_STD_PREV; + *actionptr = ACTION_STD_PREV; + return true; case ACTION_STD_NEXT: case ACTION_STD_NEXTREPEAT: @@ -981,13 +983,14 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, gui_synclist_draw(lists); } yield(); - return ACTION_STD_NEXT; + *actionptr = ACTION_STD_NEXT; + return true; #ifdef HAVE_LCD_BITMAP case ACTION_TREE_PGRIGHT: gui_synclist_scroll_right(lists); gui_synclist_draw(lists); - return ACTION_TREE_PGRIGHT; + return true; case ACTION_TREE_ROOT_INIT: /* After this button press ACTION_TREE_PGLEFT is allowed to skip to root. ACTION_TREE_ROOT_INIT must be defined in the @@ -997,16 +1000,21 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, if (lists->gui_list[0].offset_position == 0) { scrolling_left = false; - return ACTION_STD_CANCEL; + *actionptr = ACTION_STD_CANCEL; + return true; } + *actionptr = ACTION_TREE_PGLEFT; case ACTION_TREE_PGLEFT: if(!scrolling_left && (lists->gui_list[0].offset_position == 0)) - return ACTION_STD_CANCEL; + { + *actionptr = ACTION_STD_CANCEL; + return false; + } gui_synclist_scroll_left(lists); gui_synclist_draw(lists); scrolling_left = true; /* stop ACTION_TREE_PAGE_LEFT skipping to root */ - return ACTION_TREE_PGLEFT; + return true; #endif /* for pgup / pgdown, we are obliged to have a different behaviour depending @@ -1023,8 +1031,9 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, gui_synclist_select_previous_page(lists, screen); gui_synclist_draw(lists); yield(); + *actionptr = ACTION_STD_NEXT; } - return ACTION_STD_NEXT; + return true; case ACTION_LISTTREE_PGDOWN: { @@ -1037,8 +1046,9 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, gui_synclist_select_next_page(lists, screen); gui_synclist_draw(lists); yield(); + *actionptr = ACTION_STD_PREV; } - return ACTION_STD_PREV; + return true; } - return 0; + return false; } diff --git a/apps/gui/list.h b/apps/gui/list.h index d0bc59b7bc..1046492b0d 100644 --- a/apps/gui/list.h +++ b/apps/gui/list.h @@ -218,16 +218,11 @@ extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists, bool hide); /* * Do the action implied by the given button, - * returns the action taken if any, 0 else - * - lists : the synchronized lists - * - button : the keycode of a pressed button - * - specifies weather to allow the list to wrap or not, values at top of page - * returned value : - * - ACTION_STD_NEXT when moving forward (next item or pgup) - * - ACTION_STD_PREV when moving backward (previous item or pgdown) + * returns true if the action was handled. + * NOTE: *action may be changed regardless of return value */ -extern unsigned gui_synclist_do_button(struct gui_synclist * lists, - unsigned button, +extern bool gui_synclist_do_button(struct gui_synclist * lists, + unsigned *action, enum list_wrap); #endif /* _GUI_LIST_H_ */ diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c index 474c459ff1..b8b1cc505b 100644 --- a/apps/gui/option_select.c +++ b/apps/gui/option_select.c @@ -381,7 +381,7 @@ bool option_screen(struct settings_list *setting, action = get_action(CONTEXT_LIST, TIMEOUT_BLOCK); if (action == ACTION_NONE) continue; - if (gui_synclist_do_button(&lists,action, + if (gui_synclist_do_button(&lists, &action, allow_wrap? LIST_WRAP_UNLESS_HELD: LIST_WRAP_OFF)) { selected = gui_synclist_get_sel_pos(&lists); diff --git a/apps/menu.c b/apps/menu.c index 201bbdff0e..e369f4d390 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -345,7 +345,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected) } } - if (gui_synclist_do_button(&lists,action,LIST_WRAP_UNLESS_HELD)) + if (gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD)) { talk_menu_item(menu, &lists); continue; diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c index a85024e3d2..bbc2505a51 100644 --- a/apps/menus/settings_menu.c +++ b/apps/menus/settings_menu.c @@ -491,7 +491,7 @@ int usbdriver_menuitem(void) { gui_syncstatusbar_draw(&statusbars, true); action = get_action(CONTEXT_STD, HZ/5); - if (gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD)) + if (gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD)) continue; if (action == ACTION_STD_CANCEL) { diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c index 266da7cc6f..fda91bb1ee 100644 --- a/apps/playlist_catalog.c +++ b/apps/playlist_catalog.c @@ -249,7 +249,7 @@ static int display_playlists(char* playlist, bool view) int button = get_action(CONTEXT_LIST,HZ/2); char* sel_file; - gui_synclist_do_button(&playlist_lists, button,LIST_WRAP_UNLESS_HELD); + gui_synclist_do_button(&playlist_lists, &button,LIST_WRAP_UNLESS_HELD); sel_file = playlists[gui_synclist_get_sel_pos(&playlist_lists)]; diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index a466b7e730..8452f4369a 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c @@ -605,14 +605,13 @@ bool playlist_viewer_ex(char* filename) /* Timeout so we can determine if play status has changed */ button = get_action(CONTEXT_TREE,HZ/2); - int list_action; - if( (list_action=gui_synclist_do_button(&playlist_lists, button,LIST_WRAP_UNLESS_HELD))!=0 ) + if( (gui_synclist_do_button(&playlist_lists, &button,LIST_WRAP_UNLESS_HELD)) ) { viewer.selected_track=gui_synclist_get_sel_pos(&playlist_lists); if(playlist_buffer_needs_reload(&viewer.buffer, viewer.selected_track)) playlist_buffer_load_entries_screen(&viewer.buffer, - list_action==ACTION_STD_NEXT? + button==ACTION_STD_NEXT? FORWARD : BACKWARD @@ -778,7 +777,7 @@ bool search_playlist(void) while (!exit) { button = get_action(CONTEXT_LIST,TIMEOUT_BLOCK); - if (gui_synclist_do_button(&playlist_lists, button,LIST_WRAP_UNLESS_HELD)) + if (gui_synclist_do_button(&playlist_lists, &button, LIST_WRAP_UNLESS_HELD)) continue; switch (button) { diff --git a/apps/plugin.h b/apps/plugin.h index 2580d43eb0..3971a1357c 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -112,12 +112,12 @@ #define PLUGIN_MAGIC 0x526F634B /* RocK */ /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 73 +#define PLUGIN_API_VERSION 74 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any new function which are "waiting" at the end of the function table) */ -#define PLUGIN_MIN_API_VERSION 73 +#define PLUGIN_MIN_API_VERSION 74 /* plugin return codes */ enum plugin_status { @@ -280,8 +280,8 @@ struct plugin_api { void (*gui_synclist_del_item)(struct gui_synclist * lists); void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll); void (*gui_synclist_flash)(struct gui_synclist * lists); - unsigned (*gui_synclist_do_button)(struct gui_synclist * lists, - unsigned button,enum list_wrap wrap); + bool (*gui_synclist_do_button)(struct gui_synclist * lists, + unsigned *action, enum list_wrap wrap); void (*gui_synclist_set_title)(struct gui_synclist *lists, char* title, int icon); /* button */ diff --git a/apps/plugins/chessbox/chessbox_pgn.c b/apps/plugins/chessbox/chessbox_pgn.c index fb04f6ac38..3780e32466 100644 --- a/apps/plugins/chessbox/chessbox_pgn.c +++ b/apps/plugins/chessbox/chessbox_pgn.c @@ -808,7 +808,7 @@ struct pgn_game_node* pgn_show_game_list(struct plugin_api* api, rb->gui_synclist_draw(&games_list); curr_selection = rb->gui_synclist_get_sel_pos(&games_list); button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); - if (rb->gui_synclist_do_button(&games_list,button,LIST_WRAP_OFF)){ + if (rb->gui_synclist_do_button(&games_list,&button,LIST_WRAP_OFF)){ continue; } switch (button) { diff --git a/apps/plugins/lib/oldmenuapi.c b/apps/plugins/lib/oldmenuapi.c index 742d394a50..07681a0b18 100644 --- a/apps/plugins/lib/oldmenuapi.c +++ b/apps/plugins/lib/oldmenuapi.c @@ -107,7 +107,7 @@ int menu_show(int m) */ if( menus[m].callback != NULL ) key = menus[m].callback(key, m); - rb->gui_synclist_do_button(&(menus[m].synclist), key,LIST_WRAP_UNLESS_HELD); + rb->gui_synclist_do_button(&(menus[m].synclist), &key,LIST_WRAP_UNLESS_HELD); switch( key ) { case ACTION_STD_OK: return rb->gui_synclist_get_sel_pos(&(menus[m].synclist)); diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c index 932e5bc71e..ca18d49f50 100644 --- a/apps/plugins/properties.c +++ b/apps/plugins/properties.c @@ -318,7 +318,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* file) while(!quit) { button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); - if (rb->gui_synclist_do_button(&properties_lists,button,LIST_WRAP_ON)) + if (rb->gui_synclist_do_button(&properties_lists,&button,LIST_WRAP_ON)) continue; switch(button) { diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c index 6ed36c6065..656daeaaf8 100644 --- a/apps/plugins/random_folder_advance_config.c +++ b/apps/plugins/random_folder_advance_config.c @@ -288,7 +288,7 @@ void edit_list(void) { rb->gui_synclist_draw(&lists); button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); - if (rb->gui_synclist_do_button(&lists,button,LIST_WRAP_UNLESS_HELD)) + if (rb->gui_synclist_do_button(&lists,&button,LIST_WRAP_UNLESS_HELD)) continue; selection = rb->gui_synclist_get_sel_pos(&lists); switch (button) diff --git a/apps/plugins/shortcuts/shortcuts_view.c b/apps/plugins/shortcuts/shortcuts_view.c index 3b28b4b34c..f61177f37a 100644 --- a/apps/plugins/shortcuts/shortcuts_view.c +++ b/apps/plugins/shortcuts/shortcuts_view.c @@ -59,7 +59,7 @@ enum sc_list_action_type draw_sc_list(struct gui_synclist gui_sc) rb->gui_syncstatusbar_draw(rb->statusbars, true); /* user input */ button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK); - if (rb->gui_synclist_do_button(&gui_sc, button, + if (rb->gui_synclist_do_button(&gui_sc, &button, LIST_WRAP_UNLESS_HELD)) { /* automatic handling of user input. * _UNLESS_HELD can be _ON or _OFF also diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c index 3ac8cab3f2..dd5f4b7b53 100644 --- a/apps/plugins/text_editor.c +++ b/apps/plugins/text_editor.c @@ -374,7 +374,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) rb->gui_synclist_draw(&lists); cur_sel = rb->gui_synclist_get_sel_pos(&lists); button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); - if (rb->gui_synclist_do_button(&lists,button,LIST_WRAP_UNLESS_HELD)) + if (rb->gui_synclist_do_button(&lists,&button,LIST_WRAP_UNLESS_HELD)) continue; switch (button) { diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index b95bffe696..5042305967 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c @@ -1266,7 +1266,7 @@ static int handle_radio_presets(void) gui_syncstatusbar_draw(&statusbars, true); action = get_action(CONTEXT_STD, HZ); - gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD); + gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD); switch (action) { case ACTION_STD_MENU: diff --git a/apps/screens.c b/apps/screens.c index ee804b2f9b..b725beaa7a 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -1282,7 +1282,7 @@ bool browse_id3(void) gui_syncstatusbar_draw(&statusbars, false); key = get_action(CONTEXT_LIST,HZ/2); if(key!=ACTION_NONE && key!=ACTION_UNKNOWN - && !gui_synclist_do_button(&id3_lists, key,LIST_WRAP_UNLESS_HELD)) + && !gui_synclist_do_button(&id3_lists, &key,LIST_WRAP_UNLESS_HELD)) { return(default_event_handler(key) == SYS_USB_CONNECTED); } @@ -1342,7 +1342,7 @@ bool view_runtime(void) gui_synclist_draw(&lists); gui_syncstatusbar_draw(&statusbars, true); action = get_action(CONTEXT_STD, HZ); - gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD); + gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD); if(action == ACTION_STD_CANCEL) break; if(action == ACTION_STD_OK) { diff --git a/apps/tree.c b/apps/tree.c index 5122f55a82..fb2ed8d320 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -552,7 +552,7 @@ static int dirbrowse() int numentries=0; char buf[MAX_PATH]; int lasti = -1; - unsigned button, returned_button; + unsigned button, oldbutton; bool reload_root = false; int lastfilter = *tc.dirfilter; bool lastsortcase = global_settings.sort_case; @@ -605,12 +605,8 @@ static int dirbrowse() } #endif button = get_action(CONTEXT_TREE,HZ/5); - returned_button = gui_synclist_do_button(&tree_lists, button,LIST_WRAP_UNLESS_HELD); - if (returned_button) - need_update = true; - if (returned_button == ACTION_STD_CANCEL) - button = ACTION_STD_CANCEL; - + oldbutton = button; + need_update = gui_synclist_do_button(&tree_lists, &button,LIST_WRAP_UNLESS_HELD); tc.selected_item = gui_synclist_get_sel_pos(&tree_lists); switch ( button ) { case ACTION_STD_OK: @@ -640,9 +636,11 @@ static int dirbrowse() if ((*tc.dirfilter == SHOW_ID3DB && tc.dirlevel == 0) || ((*tc.dirfilter != SHOW_ID3DB && !strcmp(currdir,"/")))) { - if (returned_button == ACTION_STD_CANCEL) +#ifdef HAVE_LCD_BITMAP /* charcell doesnt have ACTION_TREE_PGLEFT so this isnt needed */ + if (oldbutton == ACTION_TREE_PGLEFT) break; else +#endif return GO_TO_ROOT; }