Index: firmware/target/arm/as3525/sansa-e200v2/button-e200v2.c =================================================================== --- firmware/target/arm/as3525/sansa-e200v2/button-e200v2.c (Revision 21183) +++ firmware/target/arm/as3525/sansa-e200v2/button-e200v2.c (Arbeitskopie) @@ -65,9 +65,13 @@ * BUTTON_REPEAT */ static long last_wheel_post = 0; - /* Repeat is used for the scrollwheel acceleration. If high enough then - * jump over some items */ - static unsigned repeat = 0; + /* + * Providing wheel acceleration works as follows: We increment accel + * by 3 if the wheel was turned, and decrement it by 1 each tick + * (no matter if it was turned), that means: the longer and faster you turn, + * the higher accel will be. accel>>1 will actually posted to the button_queue + */ + static unsigned accel = 0; /* we omit 1 of 2 posts to the button_queue, that works better, so count */ static int counter = 0; /* Read wheel @@ -83,7 +87,7 @@ if(hold_button) { - repeat = counter = 0; + accel = counter = 0; return; } @@ -101,7 +105,7 @@ { /* direction reversals nullify repeats */ old_btn = btn; - repeat = counter = 0; + accel = counter = 0; } /* wheel_delta will cause lists to jump over items, * we want this for fast scrolling, but we must keep it accurate @@ -111,10 +115,10 @@ if (TIME_BEFORE(current_tick, last_wheel_post + WHEEL_REPEAT_INTERVAL)) { btn |= BUTTON_REPEAT; - wheel_delta = repeat>>1; + wheel_delta = accel>>1; } - repeat += 3; + accel += 3; /* the wheel is more reliable if we don't send ever change, * every 2th is basically one "physical click" is * 1 item in the rockbox menus */ @@ -128,13 +132,19 @@ last_wheel_post = current_tick; } } - if (repeat > 0 && !read_missed) - repeat--; + if (accel > 0 && !read_missed) + accel--; old_wheel_value = wheel_value; } #endif /* !defined(BOOTLOADER) && defined(HAVE_SCROLLWHEEL) */ +static void button_delay(void) +{ + int i = 10; + while(i--) asm volatile ("nop\n"); +} + unsigned short button_read_dbop(void) { /*write a red pixel */ @@ -145,18 +155,15 @@ if (!read_missed) { /* Set up dbop for input */ - while (!(DBOP_STAT & (1<<10))); /* Wait for fifo to empty */ DBOP_CTRL |= (1<<19); /* Tri-state DBOP on read cycle */ DBOP_CTRL &= ~(1<<16); /* disable output (1:write enabled) */ DBOP_TIMPOL_01 = 0xe167e167; /* Set Timing & Polarity regs 0 & 1 */ DBOP_TIMPOL_23 = 0xe167006e; /* Set Timing & Polarity regs 2 & 3 */ - + + button_delay(); DBOP_CTRL |= (1<<15); /* start read */ while (!(DBOP_STAT & (1<<16))); /* wait for valid data */ - int delay=10; - while(delay--); /* short delay before reading */ - _dbop_din = DBOP_DIN; /* Read dbop data*/ /* Reset dbop for output */