The ipod4G scrolling code doesn't check for scrolling if the button
queue is not empty. So far so good.
At line 159:
/* The queue should have no other events when scrolling */
if (queue_empty(&button_queue) && old_wheel_value >= 0) {
If the queue is empty and the loop is entered, the change in the wheel
position is calculated by:
line 163:
int wheel_delta = new_wheel_value - old_wheel_value;
However, the old_wheel_value is set to the new_wheel_value even when
the loop is not entered:
line 185:
old_wheel_value = new_wheel_value;
The result is, if the scrolling is outrunning the consumption of the
queue, the actual wheel position delta isn't calculated.
Here's a sequence the absolute positions and the delta; note that
regardless of the absolute change, in this sample the delta is always
calculated as 3, because of this bug (or feature). (Note that I'm
using 3 (>2, <-2) as the threshold delta for emitting scroll keys, not
5 (>4, <-4) as in the source.)
wheel_delta 3, absolute wheel position (new_wheel_value) 16
wheel_delta 3, absolute wheel position (new_wheel_value) 19
wheel_delta 3, absolute wheel position (new_wheel_value) 22
wheel_delta 3, absolute wheel position (new_wheel_value) 27
wheel_delta 3, absolute wheel position (new_wheel_value) 33
wheel_delta 3, absolute wheel position (new_wheel_value) 40
wheel_delta 3, absolute wheel position (new_wheel_value) 47
wheel_delta 3, absolute wheel position (new_wheel_value) 54
wheel_delta 3, absolute wheel position (new_wheel_value) 60
wheel_delta 3, absolute wheel position (new_wheel_value) 67
wheel_delta 3, absolute wheel position (new_wheel_value) 72
wheel_delta 3, absolute wheel position (new_wheel_value) 77
wheel_delta 3, absolute wheel position (new_wheel_value) 80
wheel_delta 3, absolute wheel position (new_wheel_value) 85
wheel_delta 3, absolute wheel position (new_wheel_value) 91
wheel_delta 3, absolute wheel position (new_wheel_value) 0
wheel_delta 3, absolute wheel position (new_wheel_value) 4
wheel_delta 3, absolute wheel position (new_wheel_value) 8
wheel_delta 3, absolute wheel position (new_wheel_value) 11
wheel_delta 3, absolute wheel position (new_wheel_value) 15
wheel_delta 3, absolute wheel position (new_wheel_value) 18
wheel_delta 3, absolute wheel position (new_wheel_value) 21
wheel_delta -3, absolute wheel position (new_wheel_value) 93
wheel_delta -3, absolute wheel position (new_wheel_value) 92
wheel_delta -3, absolute wheel position (new_wheel_value) 94
So is this a bug or a feature?