summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-07-22 21:02:24 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-07-22 21:02:24 +0000
commit873e0fd1ef2ad0e8e1d74a9c9a3b0ed0cdfee35e (patch)
tree29ca956fb87b7f8c17cb5061d3afcfda70c44e4c /apps
parent3213d4a0f5d3aea725bb9ddf34ae0ec38ca4b097 (diff)
downloadrockbox-873e0fd1ef2ad0e8e1d74a9c9a3b0ed0cdfee35e.zip
rockbox-873e0fd1ef2ad0e8e1d74a9c9a3b0ed0cdfee35e.tar.gz
rockbox-873e0fd1ef2ad0e8e1d74a9c9a3b0ed0cdfee35e.tar.bz2
rockbox-873e0fd1ef2ad0e8e1d74a9c9a3b0ed0cdfee35e.tar.xz
Wheel acceleration for e200. A general acceleration interface intended for use on any scroll target and by any code. A general interface to obtain data associated with most recently dequeued button presses and actions. Use #define HAVE_SCROLLWHEEL and set appropriate constants, values in the scroller driver that feel right.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13959 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/action.c8
-rw-r--r--apps/action.h6
-rw-r--r--apps/gui/list.c18
-rw-r--r--apps/lang/english.lang6
-rw-r--r--apps/menus/display_menu.c4
-rw-r--r--apps/settings.h2
-rw-r--r--apps/settings_list.c4
7 files changed, 45 insertions, 3 deletions
diff --git a/apps/action.c b/apps/action.c
index 826f376..9afdf37 100644
--- a/apps/action.c
+++ b/apps/action.c
@@ -31,6 +31,7 @@
static int last_button = BUTTON_NONE|BUTTON_REL; /* allow the ipod wheel to
work on startup */
+static intptr_t last_data = 0;
static int last_action = ACTION_NONE;
static bool repeated = false;
@@ -113,6 +114,7 @@ static int get_action_worker(int context, int timeout,
else
button = button_get_w_tmo(timeout);
+ /* Data from sys events can be pulled with button_get_data */
if (button == BUTTON_NONE || button&SYS_EVENT)
{
return button;
@@ -201,6 +203,7 @@ static int get_action_worker(int context, int timeout,
last_button = button;
last_action = ret;
+ last_data = button_get_data();
last_action_tick = current_tick;
return ret;
}
@@ -230,6 +233,11 @@ bool is_keys_locked(void)
}
#endif
+intptr_t get_action_data(void)
+{
+ return last_data;
+}
+
int get_action_statuscode(int *button)
{
int ret = 0;
diff --git a/apps/action.h b/apps/action.h
index 7acaf9c..5beacaa 100644
--- a/apps/action.h
+++ b/apps/action.h
@@ -253,6 +253,8 @@ bool is_keys_locked(void);
#define ACTION_REPEAT 0x2 /* action was repeated (NOT button) */
int get_action_statuscode(int *button);
+/* returns the data value associated with the last action that is not
+ BUTTON_NONE or flagged with SYS_EVENT */
+intptr_t get_action_data(void);
-
-#endif
+#endif /* __ACTION_H__ */
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 2fb531b..0cc3257 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -887,15 +887,22 @@ static void gui_synclist_scroll_left(struct gui_synclist * lists)
}
#endif /* HAVE_LCD_BITMAP */
+extern intptr_t get_action_data(void);
+
unsigned gui_synclist_do_button(struct gui_synclist * lists,
unsigned button,enum list_wrap wrap)
{
#ifdef HAVE_LCD_BITMAP
static bool scrolling_left = false;
#endif
+ int i;
+
+#ifdef HAVE_SCROLLWHEEL
+ int next_item_modifier = button_apply_acceleration(get_action_data(),
+ WHEEL_ACCELERATION_FACTOR);
+#else
static int next_item_modifier = 1;
static int last_accel_tick = 0;
- int i;
if (global_settings.list_accel_start_delay)
{
@@ -919,6 +926,7 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists,
last_accel_tick = 0;
}
}
+#endif
switch (wrap)
{
@@ -953,8 +961,12 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists,
case ACTION_STD_PREVREPEAT:
FOR_NB_SCREENS(i)
gui_list_select_at_offset(&(lists->gui_list[i]), -next_item_modifier);
+#ifndef HAVE_SCROLLWHEEL
if (queue_count(&button_queue) < FRAMEDROP_TRIGGER)
+#endif
+ {
gui_synclist_draw(lists);
+ }
yield();
return ACTION_STD_PREV;
@@ -962,8 +974,12 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists,
case ACTION_STD_NEXTREPEAT:
FOR_NB_SCREENS(i)
gui_list_select_at_offset(&(lists->gui_list[i]), next_item_modifier);
+#ifndef HAVE_SCROLLWHEEL
if (queue_count(&button_queue) < FRAMEDROP_TRIGGER)
+#endif
+ {
gui_synclist_draw(lists);
+ }
yield();
return ACTION_STD_NEXT;
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index f4577d9..ca15076 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -10955,12 +10955,15 @@
desc: Delay before list starts accelerating
user:
<source>
+ e200: ""
*: "List Acceleration Start Delay"
</source>
<dest>
+ e200: ""
*: "List Acceleration Start Delay"
</dest>
<voice>
+ e200: ""
*: "List Acceleration Start Delay"
</voice>
</phrase>
@@ -10969,12 +10972,15 @@
desc: list acceleration speed
user:
<source>
+ e200: ""
*: "List Acceleration Speed"
</source>
<dest>
+ e200: ""
*: "List Acceleration Speed"
</dest>
<voice>
+ e200: ""
*: "List Acceleration Speed"
</voice>
</phrase>
diff --git a/apps/menus/display_menu.c b/apps/menus/display_menu.c
index 5114fea..92afc30 100644
--- a/apps/menus/display_menu.c
+++ b/apps/menus/display_menu.c
@@ -313,9 +313,11 @@ MENUITEM_SETTING(jump_scroll, &global_settings.jump_scroll, NULL);
MENUITEM_SETTING(jump_scroll_delay, &global_settings.jump_scroll_delay, NULL);
#endif
/* list acceleration */
+#ifndef HAVE_SCROLLWHEEL
MENUITEM_SETTING(list_accel_start_delay,
&global_settings.list_accel_start_delay, NULL);
MENUITEM_SETTING(list_accel_wait, &global_settings.list_accel_wait, NULL);
+#endif /* HAVE_SCROLLWHEEL */
#ifdef HAVE_LCD_BITMAP
int screenscroll_callback(int action,const struct menu_item_ex *this_item)
{
@@ -350,7 +352,9 @@ MAKE_MENU(scroll_settings_menu, ID2P(LANG_SCROLL_MENU), 0, Icon_NOICON,
&offset_out_of_view, &screen_scroll_step,
#endif
&scroll_paginated,
+#ifndef HAVE_SCROLLWHEEL
&list_accel_start_delay, &list_accel_wait
+#endif
);
/* SCROLL MENU */
/***********************************/
diff --git a/apps/settings.h b/apps/settings.h
index e901814..f9ee1df 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -731,8 +731,10 @@ struct user_settings
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
int buttonlight_brightness;
#endif
+#ifndef HAVE_SCROLLWHEEL
int list_accel_start_delay; /* ms before we start increaseing step size */
int list_accel_wait; /* ms between increases */
+#endif
};
/** global variables **/
diff --git a/apps/settings_list.c b/apps/settings_list.c
index ae32735..76a3e41 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -274,6 +274,7 @@ static void poweroff_idle_timer_formatter(char *buffer, int buffer_size,
snprintf(buffer, buffer_size, "%dm", poweroff_idle_timer_times[val]);
}
+#ifndef HAVE_SCROLLWHEEL
static long listaccel_getlang(int value)
{
if (value == 0)
@@ -289,6 +290,7 @@ static void listaccel_formatter(char *buffer, int buffer_size,
else
snprintf(buffer, buffer_size, "%d ms", 5*HZ*val);
}
+#endif /* HAVE_SCROLLWHEEL */
#if CONFIG_CODEC == SWCODEC
static void crossfeed_format(char* buffer, int buffer_size, int value,
@@ -1235,12 +1237,14 @@ const struct settings_list settings[] = {
"button light brightness",UNIT_INT, MIN_BRIGHTNESS_SETTING, MAX_BRIGHTNESS_SETTING, 1,
NULL, NULL, buttonlight_set_brightness),
#endif
+#ifndef HAVE_SCROLLWHEEL
INT_SETTING(0, list_accel_start_delay, LANG_LISTACCEL_START_DELAY,
2, "list_accel_start_delay", UNIT_MS, 0, 10, 1,
listaccel_formatter, listaccel_getlang, NULL),
INT_SETTING(0, list_accel_wait, LANG_LISTACCEL_ACCEL_SPEED,
3, "list_accel_wait", UNIT_SEC, 1, 10, 1,
scanaccel_formatter, scanaccel_getlang, NULL),
+#endif /* HAVE_SCROLLWHEEL */
};
const int nb_settings = sizeof(settings)/sizeof(*settings);