diff options
author | Rafaël Carré <rafael.carre@gmail.com> | 2010-05-15 16:34:14 +0000 |
---|---|---|
committer | Rafaël Carré <rafael.carre@gmail.com> | 2010-05-15 16:34:14 +0000 |
commit | d10bf7ab46e5b6e043507f7eee01b7dd42b87c7a (patch) | |
tree | d10f77f2d670454468e39af872306b0e812ec112 | |
parent | 79cfc221a5f9a46f220875e5222e3143479f1c1f (diff) | |
download | rockbox-d10bf7ab46e5b6e043507f7eee01b7dd42b87c7a.tar.gz rockbox-d10bf7ab46e5b6e043507f7eee01b7dd42b87c7a.zip |
fuzev2: leave at least 3ms between scrollwheel events
fix insane acceleration
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26060 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c index 4486af95b1..f454867cfc 100644 --- a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c +++ b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c | |||
@@ -34,6 +34,7 @@ static bool hold_button = false; | |||
34 | #define TIMER_TICK (KERNEL_TIMER_FREQ/HZ)/* how long a tick lasts */ | 34 | #define TIMER_TICK (KERNEL_TIMER_FREQ/HZ)/* how long a tick lasts */ |
35 | #define TIMER_MS (TIMER_TICK/(1000/HZ))/* how long a ms lasts */ | 35 | #define TIMER_MS (TIMER_TICK/(1000/HZ))/* how long a ms lasts */ |
36 | 36 | ||
37 | #define WHEEL_LOOP_INTERVAL ( 3*TIMER_MS) /* 3 ms */ | ||
37 | #define WHEEL_REPEAT_INTERVAL (300*TIMER_MS) /* 300ms */ | 38 | #define WHEEL_REPEAT_INTERVAL (300*TIMER_MS) /* 300ms */ |
38 | #define WHEEL_FAST_ON_INTERVAL ( 20*TIMER_MS) /* 20ms */ | 39 | #define WHEEL_FAST_ON_INTERVAL ( 20*TIMER_MS) /* 20ms */ |
39 | #define WHEEL_FAST_OFF_INTERVAL ( 60*TIMER_MS) /* 60ms */ | 40 | #define WHEEL_FAST_OFF_INTERVAL ( 60*TIMER_MS) /* 60ms */ |
@@ -76,6 +77,18 @@ static void scrollwheel(unsigned int wheel_value) | |||
76 | { 1, 3, 0, 2 }, /* Counter-clockwise */ | 77 | { 1, 3, 0, 2 }, /* Counter-clockwise */ |
77 | }; | 78 | }; |
78 | 79 | ||
80 | int repeat = 1; /* assume repeat */ | ||
81 | long time = TIMER2_VALUE + current_tick*TIMER_TICK; /* to timer unit */ | ||
82 | long v = (time - last_wheel_post); | ||
83 | if (v < WHEEL_LOOP_INTERVAL) /* avoid too frequent updates */ | ||
84 | return ; | ||
85 | |||
86 | /* interpolate velocity in timer_freq/timer_unit == 1/s */ | ||
87 | if (v) v = TIMER_FREQ / v; | ||
88 | |||
89 | /* accumulate velocities over time with each v */ | ||
90 | wheel_velocity = (7*wheel_velocity + v) / 8; | ||
91 | |||
79 | unsigned int btn = BUTTON_NONE; | 92 | unsigned int btn = BUTTON_NONE; |
80 | 93 | ||
81 | if (old_wheel_value == wheel_tbl[0][wheel_value]) | 94 | if (old_wheel_value == wheel_tbl[0][wheel_value]) |
@@ -89,16 +102,6 @@ static void scrollwheel(unsigned int wheel_value) | |||
89 | return; | 102 | return; |
90 | } | 103 | } |
91 | 104 | ||
92 | int repeat = 1; /* assume repeat */ | ||
93 | long time = TIMER2_VALUE + current_tick*TIMER_TICK; /* to timer unit */ | ||
94 | long v = (time - last_wheel_post); | ||
95 | |||
96 | /* interpolate velocity in timer_freq/timer_unit == 1/s */ | ||
97 | if (v) v = TIMER_FREQ / v; | ||
98 | |||
99 | /* accumulate velocities over time with each v */ | ||
100 | wheel_velocity = (7*wheel_velocity + v) / 8; | ||
101 | |||
102 | if (btn != wheel_repeat) | 105 | if (btn != wheel_repeat) |
103 | { | 106 | { |
104 | /* direction reversals nullify all fast mode states */ | 107 | /* direction reversals nullify all fast mode states */ |