From ca701bf62e192ad8cbaea38653e1e44874fede50 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Sun, 4 Mar 2007 07:45:12 +0000 Subject: [PATCH] Add a function to get the actual button that was pressed (and some status codes) instead of the action. Use this to figure out which screen to do prev/next page on in the lists git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12580 a1c6a512-1295-4272-9138-f99709370657 --- apps/action.c | 23 +++++++++++++++- apps/action.h | 13 +++++++-- apps/gui/list.c | 47 ++++++++++++++++++--------------- apps/keymaps/keymap-h1x0_h3x0.c | 2 +- 4 files changed, 59 insertions(+), 26 deletions(-) diff --git a/apps/action.c b/apps/action.c index 30eccb8d81..7667e4dd12 100644 --- a/apps/action.c +++ b/apps/action.c @@ -31,6 +31,8 @@ static bool ignore_until_release = false; static int last_button = BUTTON_NONE; +static int last_action = ACTION_NONE; +static bool repeated = false; /* software keylock stuff */ #ifndef HAS_BUTTON_HOLD @@ -107,7 +109,6 @@ static int get_action_worker(int context, int timeout, else button = button_get_w_tmo(timeout); - if (button == BUTTON_NONE || button&SYS_EVENT) { return button; @@ -185,6 +186,11 @@ static int get_action_worker(int context, int timeout, return ACTION_REDRAW; } #endif + if (ret == last_action) + repeated = true; + else + repeated = false; + last_button = button; return ret; } @@ -224,3 +230,18 @@ bool is_keys_locked(void) return (screen_has_lock && (keys_locked == true)); } #endif + +int get_action_statuscode(int *button) +{ + int ret = 0; + if (button) + *button = last_button; + + if (last_button&BUTTON_REMOTE) + ret |= ACTION_REMOTE; + if (repeated) + ret |= ACTION_REPEAT; + if (ignore_until_release) + ret |= ACTION_IGNORING; + return ret; +} diff --git a/apps/action.h b/apps/action.h index c1026d8885..7f476a8a88 100644 --- a/apps/action.h +++ b/apps/action.h @@ -123,8 +123,6 @@ enum { /* list and tree page up/down */ ACTION_LISTTREE_PGUP,/* optional */ ACTION_LISTTREE_PGDOWN,/* optional */ - ACTION_LISTTREE_RC_PGUP,/* optional */ - ACTION_LISTTREE_RC_PGDOWN,/* optional */ /* tree */ ACTION_TREE_ROOT_INIT, @@ -248,4 +246,15 @@ const struct button_mapping* get_context_mapping(int context); #ifndef HAS_BUTTON_HOLD bool is_keys_locked(void); #endif + +/* returns the status code variable from action.c for the button just pressed + If button != NULL it will be set to the actual button code */ +#define ACTION_REMOTE 0x1 /* remote was pressed */ +#define ACTION_REPEAT 0x2 /* action was repeated (NOT button) */ +#define ACTION_IGNORING 0x4 /* action_signalscreenchange() was called \ + waiting for BUTTON_REL */ +int get_action_statuscode(int *button); + + + #endif diff --git a/apps/gui/list.c b/apps/gui/list.c index 286e6f9e59..94915391ee 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -886,29 +886,32 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, * on the screen for which the user pressed the key since for example, remote * and main screen doesn't have the same number of lines */ case ACTION_LISTTREE_PGUP: - gui_synclist_select_previous_page(lists, SCREEN_MAIN); - gui_synclist_draw(lists); - yield(); - return ACTION_STD_NEXT; - - case ACTION_LISTTREE_PGDOWN: - gui_synclist_select_next_page(lists, SCREEN_MAIN); - gui_synclist_draw(lists); - yield(); - return ACTION_STD_PREV; -#ifdef REMOTE_BUTTON - case ACTION_LISTTREE_RC_PGUP: - gui_synclist_select_previous_page(lists, SCREEN_REMOTE); - gui_synclist_draw(lists); - yield(); - return ACTION_STD_NEXT; - - case ACTION_LISTTREE_RC_PGDOWN: - gui_synclist_select_next_page(lists, SCREEN_REMOTE); - gui_synclist_draw(lists); - yield(); - return ACTION_STD_PREV; + { + int screen = +#if BUTTON_REMOTE + get_action_statuscode(NULL)&ACTION_REMOTE ? + SCREEN_REMOTE : #endif + SCREEN_MAIN; + gui_synclist_select_previous_page(lists, screen); + gui_synclist_draw(lists); + yield(); + } + return ACTION_STD_NEXT; + + case ACTION_LISTTREE_PGDOWN: + { + int screen = +#if BUTTON_REMOTE + get_action_statuscode(NULL)&ACTION_REMOTE ? + SCREEN_REMOTE : +#endif + SCREEN_MAIN; + gui_synclist_select_next_page(lists, screen); + gui_synclist_draw(lists); + yield(); + } + return ACTION_STD_PREV; } return 0; } diff --git a/apps/keymaps/keymap-h1x0_h3x0.c b/apps/keymaps/keymap-h1x0_h3x0.c index 7997270a3b..413406d8e7 100644 --- a/apps/keymaps/keymap-h1x0_h3x0.c +++ b/apps/keymaps/keymap-h1x0_h3x0.c @@ -725,7 +725,7 @@ static const struct button_mapping button_context_menu_remote[] = { { ACTION_MENU_STOP, BUTTON_RC_STOP, BUTTON_NONE }, { ACTION_MENU_WPS, BUTTON_RC_ON, BUTTON_NONE }, - LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST|CONTEXT_REMOTE) }; /* the actual used tables */