summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-10-01 00:28:03 +0000
committerThomas Martitz <kugel@rockbox.org>2009-10-01 00:28:03 +0000
commit29c06f6c63ebcd52ec60ecfa0bbb08a46cfc96fe (patch)
treeda16050c3a9fe2befe98f03c949ab6bc62988351
parentbf3d60b25e38f1a24fc5f71cae9c4939e64b6679 (diff)
downloadrockbox-29c06f6c63ebcd52ec60ecfa0bbb08a46cfc96fe.tar.gz
rockbox-29c06f6c63ebcd52ec60ecfa0bbb08a46cfc96fe.zip
e200v2/Fuze: Improve scrollwheel a little bit by assuming the previous wheel value if no new value was found (which happens if a single wheel value was skipped). Only assume it once to not get wrong readings.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22863 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/as3525/button-e200v2-fuze.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/firmware/target/arm/as3525/button-e200v2-fuze.c b/firmware/target/arm/as3525/button-e200v2-fuze.c
index 8045cea841..edb2aa4a47 100644
--- a/firmware/target/arm/as3525/button-e200v2-fuze.c
+++ b/firmware/target/arm/as3525/button-e200v2-fuze.c
@@ -69,8 +69,8 @@ void button_init_device(void)
69static void scrollwheel(unsigned short dbop_din) 69static void scrollwheel(unsigned short dbop_din)
70{ 70{
71 /* current wheel values, parsed from dbop and the resulting button */ 71 /* current wheel values, parsed from dbop and the resulting button */
72 unsigned wheel_value = 0; 72 unsigned wheel_value = 0;
73 unsigned btn = BUTTON_NONE; 73 unsigned btn = BUTTON_NONE;
74 /* old wheel values */ 74 /* old wheel values */
75 static unsigned old_wheel_value = 0; 75 static unsigned old_wheel_value = 0;
76 static unsigned old_btn = BUTTON_NONE; 76 static unsigned old_btn = BUTTON_NONE;
@@ -80,7 +80,7 @@ static void scrollwheel(unsigned short dbop_din)
80 * posted to the button_queue last, and if it was recent enough, generate 80 * posted to the button_queue last, and if it was recent enough, generate
81 * BUTTON_REPEAT 81 * BUTTON_REPEAT
82 */ 82 */
83 static long last_wheel_post = 0; 83 static long last_wheel_post = 0;
84 84
85 /* 85 /*
86 * Providing wheel acceleration works as follows: We increment accel 86 * Providing wheel acceleration works as follows: We increment accel
@@ -88,14 +88,17 @@ static void scrollwheel(unsigned short dbop_din)
88 * (no matter if it was turned), that means: the longer and faster you turn, 88 * (no matter if it was turned), that means: the longer and faster you turn,
89 * the higher accel will be. accel>>2 will actually posted to the button_queue 89 * the higher accel will be. accel>>2 will actually posted to the button_queue
90 */ 90 */
91 static int accel = 0; 91 static int accel = 0;
92 /* We only post every 4th action, as this matches better with the physical 92 /* We only post every 4th action, as this matches better with the physical
93 * clicks of the wheel */ 93 * clicks of the wheel */
94 static int counter = 0; 94 static int counter = 0;
95 /* Read wheel 95 /* Read wheel
96 * Bits 13 and 14 of DBOP_DIN change as follows: 96 * Bits 13 and 14 of DBOP_DIN change as follows:
97 * Clockwise rotation 00 -> 01 -> 11 -> 10 -> 00 97 * Clockwise rotation 00 -> 01 -> 11 -> 10 -> 00
98 * Counter-clockwise 00 -> 10 -> 11 -> 01 -> 00 98 * Counter-clockwise 00 -> 10 -> 11 -> 01 -> 00
99 *
100 * For easy look-up, actual wheel values act as indicies also,
101 * which is why the table seems to be not ordered correctly
99 */ 102 */
100 static const unsigned char wheel_tbl[2][4] = 103 static const unsigned char wheel_tbl[2][4] =
101 { 104 {
@@ -109,18 +112,24 @@ static void scrollwheel(unsigned short dbop_din)
109 return; 112 return;
110 } 113 }
111 114
112 wheel_value = dbop_din & (1<<13|1<<14); 115 wheel_value = (dbop_din >> 13) & (1<<1|1<<0);
113 wheel_value >>= 13;
114 116
115 if (old_wheel_value == wheel_tbl[0][wheel_value]) 117 if (old_wheel_value == wheel_tbl[0][wheel_value])
116 btn = BUTTON_SCROLL_FWD; 118 btn = BUTTON_SCROLL_FWD;
117 else if (old_wheel_value == wheel_tbl[1][wheel_value]) 119 else if (old_wheel_value == wheel_tbl[1][wheel_value])
118 btn = BUTTON_SCROLL_BACK; 120 btn = BUTTON_SCROLL_BACK;
121 else if (old_btn != BUTTON_NONE)
122 { /* if no button is read, assume old_btn, but only once to not have
123 * wrong readings */
124 btn = old_btn;
125 old_btn = BUTTON_NONE;
126 }
127 /* else btn = BUTTON_NONE */
119 128
120 if (btn != BUTTON_NONE) 129 if (btn != BUTTON_NONE)
121 { 130 {
122 if (btn != old_btn) 131 if (btn != old_btn && old_btn != BUTTON_NONE)
123 { 132 { /* don't do this if we assumned old_btn */
124 /* direction reversals nullify acceleration and counters */ 133 /* direction reversals nullify acceleration and counters */
125 old_btn = btn; 134 old_btn = btn;
126 accel = counter = 0; 135 accel = counter = 0;