summaryrefslogtreecommitdiff
path: root/firmware/drivers/button.c
diff options
context:
space:
mode:
authorBrandon Low <lostlogic@rockbox.org>2006-03-07 04:56:55 +0000
committerBrandon Low <lostlogic@rockbox.org>2006-03-07 04:56:55 +0000
commitb5648000ba63476b99823046a6702881a28fd6c0 (patch)
tree7e43b04aeccb64f62d19fa6e8e2e84f9449df42e /firmware/drivers/button.c
parent40d0d752aa94e162b28a89f1730d989bd9e45aee (diff)
Slight simplification of scroll button driver
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8939 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/button.c')
-rw-r--r--firmware/drivers/button.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index e2a4e82a58..cdbb9f5374 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -128,7 +128,6 @@ static int ipod_4g_button_read(void)
static int clickwheel_down = 0;
static int old_wheel_value = -1;
int wheel_keycode = BUTTON_NONE;
- int wheel_delta, wheel_delta_abs;
int new_wheel_value;
int btn = BUTTON_NONE;
@@ -162,17 +161,16 @@ static int ipod_4g_button_read(void)
clickwheel_down = 1;
backlight_on();
if (old_wheel_value != -1) {
- wheel_delta = new_wheel_value - old_wheel_value;
- wheel_delta_abs = wheel_delta < 0 ? -wheel_delta
- : wheel_delta;
-
- if (wheel_delta_abs > 48) {
- if (old_wheel_value > new_wheel_value)
- /* wrapped around the top going clockwise */
- wheel_delta += 96;
- else if (old_wheel_value < new_wheel_value)
- /* wrapped around the top going counterclockwise */ wheel_delta -= 96;
+ int wheel_delta;
+ if (old_wheel_value > new_wheel_value + 48) {
+ /* Forward wrapping case */
+ wheel_delta = new_wheel_value + 96 - old_wheel_value;
+ } else {
+ wheel_delta = new_wheel_value - old_wheel_value;
+ if (wheel_delta > 48)
+ wheel_delta -= 96; /* Backward wrapping case */
}
+
/* TODO: these thresholds should most definitely be
settings, and we're probably going to want a more
advanced scheme than this anyway. */