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
This commit is contained in:
Thomas Martitz 2009-10-01 00:28:03 +00:00
parent bf3d60b25e
commit 29c06f6c63

View file

@ -96,6 +96,9 @@ static void scrollwheel(unsigned short dbop_din)
* Bits 13 and 14 of DBOP_DIN change as follows:
* Clockwise rotation 00 -> 01 -> 11 -> 10 -> 00
* Counter-clockwise 00 -> 10 -> 11 -> 01 -> 00
*
* For easy look-up, actual wheel values act as indicies also,
* which is why the table seems to be not ordered correctly
*/
static const unsigned char wheel_tbl[2][4] =
{
@ -109,18 +112,24 @@ static void scrollwheel(unsigned short dbop_din)
return;
}
wheel_value = dbop_din & (1<<13|1<<14);
wheel_value >>= 13;
wheel_value = (dbop_din >> 13) & (1<<1|1<<0);
if (old_wheel_value == wheel_tbl[0][wheel_value])
btn = BUTTON_SCROLL_FWD;
else if (old_wheel_value == wheel_tbl[1][wheel_value])
btn = BUTTON_SCROLL_BACK;
else if (old_btn != BUTTON_NONE)
{ /* if no button is read, assume old_btn, but only once to not have
* wrong readings */
btn = old_btn;
old_btn = BUTTON_NONE;
}
/* else btn = BUTTON_NONE */
if (btn != BUTTON_NONE)
{
if (btn != old_btn)
{
if (btn != old_btn && old_btn != BUTTON_NONE)
{ /* don't do this if we assumned old_btn */
/* direction reversals nullify acceleration and counters */
old_btn = btn;
accel = counter = 0;