mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 05:05:20 -05:00
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:
parent
bf3d60b25e
commit
29c06f6c63
1 changed files with 18 additions and 9 deletions
|
|
@ -69,8 +69,8 @@ void button_init_device(void)
|
||||||
static void scrollwheel(unsigned short dbop_din)
|
static void scrollwheel(unsigned short dbop_din)
|
||||||
{
|
{
|
||||||
/* current wheel values, parsed from dbop and the resulting button */
|
/* current wheel values, parsed from dbop and the resulting button */
|
||||||
unsigned wheel_value = 0;
|
unsigned wheel_value = 0;
|
||||||
unsigned btn = BUTTON_NONE;
|
unsigned btn = BUTTON_NONE;
|
||||||
/* old wheel values */
|
/* old wheel values */
|
||||||
static unsigned old_wheel_value = 0;
|
static unsigned old_wheel_value = 0;
|
||||||
static unsigned old_btn = BUTTON_NONE;
|
static unsigned old_btn = BUTTON_NONE;
|
||||||
|
|
@ -80,7 +80,7 @@ static void scrollwheel(unsigned short dbop_din)
|
||||||
* posted to the button_queue last, and if it was recent enough, generate
|
* posted to the button_queue last, and if it was recent enough, generate
|
||||||
* BUTTON_REPEAT
|
* BUTTON_REPEAT
|
||||||
*/
|
*/
|
||||||
static long last_wheel_post = 0;
|
static long last_wheel_post = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Providing wheel acceleration works as follows: We increment accel
|
* Providing wheel acceleration works as follows: We increment accel
|
||||||
|
|
@ -88,14 +88,17 @@ static void scrollwheel(unsigned short dbop_din)
|
||||||
* (no matter if it was turned), that means: the longer and faster you turn,
|
* (no matter if it was turned), that means: the longer and faster you turn,
|
||||||
* the higher accel will be. accel>>2 will actually posted to the button_queue
|
* the higher accel will be. accel>>2 will actually posted to the button_queue
|
||||||
*/
|
*/
|
||||||
static int accel = 0;
|
static int accel = 0;
|
||||||
/* We only post every 4th action, as this matches better with the physical
|
/* We only post every 4th action, as this matches better with the physical
|
||||||
* clicks of the wheel */
|
* clicks of the wheel */
|
||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
/* Read wheel
|
/* Read wheel
|
||||||
* Bits 13 and 14 of DBOP_DIN change as follows:
|
* Bits 13 and 14 of DBOP_DIN change as follows:
|
||||||
* Clockwise rotation 00 -> 01 -> 11 -> 10 -> 00
|
* Clockwise rotation 00 -> 01 -> 11 -> 10 -> 00
|
||||||
* Counter-clockwise 00 -> 10 -> 11 -> 01 -> 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] =
|
static const unsigned char wheel_tbl[2][4] =
|
||||||
{
|
{
|
||||||
|
|
@ -109,18 +112,24 @@ static void scrollwheel(unsigned short dbop_din)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wheel_value = dbop_din & (1<<13|1<<14);
|
wheel_value = (dbop_din >> 13) & (1<<1|1<<0);
|
||||||
wheel_value >>= 13;
|
|
||||||
|
|
||||||
if (old_wheel_value == wheel_tbl[0][wheel_value])
|
if (old_wheel_value == wheel_tbl[0][wheel_value])
|
||||||
btn = BUTTON_SCROLL_FWD;
|
btn = BUTTON_SCROLL_FWD;
|
||||||
else if (old_wheel_value == wheel_tbl[1][wheel_value])
|
else if (old_wheel_value == wheel_tbl[1][wheel_value])
|
||||||
btn = BUTTON_SCROLL_BACK;
|
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 != 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 */
|
/* direction reversals nullify acceleration and counters */
|
||||||
old_btn = btn;
|
old_btn = btn;
|
||||||
accel = counter = 0;
|
accel = counter = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue