summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-03-04 07:45:12 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-03-04 07:45:12 +0000
commitca701bf62e192ad8cbaea38653e1e44874fede50 (patch)
treec5232585bfabf3601a19f9aa73a165aed67c2d84
parent598629c3bf4bf683812c374af7791f06777873f7 (diff)
downloadrockbox-ca701bf62e192ad8cbaea38653e1e44874fede50.zip
rockbox-ca701bf62e192ad8cbaea38653e1e44874fede50.tar.gz
rockbox-ca701bf62e192ad8cbaea38653e1e44874fede50.tar.bz2
rockbox-ca701bf62e192ad8cbaea38653e1e44874fede50.tar.xz
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
-rw-r--r--apps/action.c23
-rw-r--r--apps/action.h13
-rw-r--r--apps/gui/list.c37
-rw-r--r--apps/keymaps/keymap-h1x0_h3x0.c2
4 files changed, 54 insertions, 21 deletions
diff --git a/apps/action.c b/apps/action.c
index 30eccb8..7667e4d 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 c1026d8..7f476a8 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 286e6f9..9491539 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);
+ {
+ 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:
- 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);
+ {
+ 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;
-#endif
+ }
+ return ACTION_STD_PREV;
}
return 0;
}
diff --git a/apps/keymaps/keymap-h1x0_h3x0.c b/apps/keymaps/keymap-h1x0_h3x0.c
index 7997270..413406d 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 */