forked from len0rd/rockbox
Reduce code size and generally clean up the button driver more! * Add 'wheel repeat' functionality to prevent scrolling past the end of lists in a continuous scroll. Can release and resume scrolling to wrap to the top (4g, 5g, nano).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9110 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
5650b70517
commit
dd5a85839e
1 changed files with 29 additions and 26 deletions
|
|
@ -138,9 +138,7 @@ static inline int ipod_4g_button_read(void)
|
||||||
|
|
||||||
if ((status & 0x800000ff) == 0x8000001a) {
|
if ((status & 0x800000ff) == 0x8000001a) {
|
||||||
static int old_wheel_value IDATA_ATTR = -1;
|
static int old_wheel_value IDATA_ATTR = -1;
|
||||||
/* NB: highest wheel = 0x5F, clockwise increases */
|
static int wheel_repeat = 0;
|
||||||
int new_wheel_value = (status << 9) >> 25;
|
|
||||||
int wheel_delta = new_wheel_value - old_wheel_value;
|
|
||||||
|
|
||||||
if (status & 0x100)
|
if (status & 0x100)
|
||||||
btn |= BUTTON_SELECT;
|
btn |= BUTTON_SELECT;
|
||||||
|
|
@ -153,37 +151,40 @@ static inline int ipod_4g_button_read(void)
|
||||||
if (status & 0x1000)
|
if (status & 0x1000)
|
||||||
btn |= BUTTON_MENU;
|
btn |= BUTTON_MENU;
|
||||||
if (status & 0x40000000) {
|
if (status & 0x40000000) {
|
||||||
|
/* NB: highest wheel = 0x5F, clockwise increases */
|
||||||
|
int new_wheel_value = (status << 9) >> 25;
|
||||||
backlight_on();
|
backlight_on();
|
||||||
/* The queue should have no other events when scrolling */
|
/* The queue should have no other events when scrolling */
|
||||||
if (queue_empty(&button_queue)) {
|
if (queue_empty(&button_queue) && old_wheel_value >= 0) {
|
||||||
|
|
||||||
if (old_wheel_value >= 0) {
|
/* This is for later = BUTTON_SCROLL_TOUCH;*/
|
||||||
/* This is for later = BUTTON_SCROLL_TOUCH;*/
|
int wheel_delta = new_wheel_value - old_wheel_value;
|
||||||
unsigned long data;
|
unsigned long data;
|
||||||
|
int wheel_keycode;
|
||||||
|
|
||||||
if (wheel_delta < -48)
|
if (wheel_delta < -48)
|
||||||
wheel_delta += 96; /* Forward wrapping case */
|
wheel_delta += 96; /* Forward wrapping case */
|
||||||
else if (wheel_delta > 48)
|
else if (wheel_delta > 48)
|
||||||
wheel_delta -= 96; /* Backward wrapping case */
|
wheel_delta -= 96; /* Backward wrapping case */
|
||||||
|
|
||||||
if (wheel_delta > 4) {
|
if (wheel_delta > 4) {
|
||||||
old_wheel_value = new_wheel_value;
|
wheel_keycode = BUTTON_SCROLL_FWD;
|
||||||
data = (wheel_delta << 16) | new_wheel_value;
|
} else if (wheel_delta < -4) {
|
||||||
queue_post(&button_queue, BUTTON_SCROLL_FWD,
|
wheel_keycode = BUTTON_SCROLL_BACK;
|
||||||
(void *)data);
|
} else goto wheel_end;
|
||||||
} else if (wheel_delta < -4) {
|
|
||||||
old_wheel_value = new_wheel_value;
|
data = (wheel_delta << 16) | new_wheel_value;
|
||||||
data = (wheel_delta << 16) | new_wheel_value;
|
queue_post(&button_queue, wheel_keycode | wheel_repeat,
|
||||||
queue_post(&button_queue, BUTTON_SCROLL_BACK,
|
(void *)data);
|
||||||
(void *)data);
|
|
||||||
}
|
if (!wheel_repeat) wheel_repeat = BUTTON_REPEAT;
|
||||||
|
|
||||||
} else
|
|
||||||
old_wheel_value = new_wheel_value;
|
|
||||||
}
|
}
|
||||||
} else if (wheel_delta == 0) {
|
|
||||||
|
old_wheel_value = new_wheel_value;
|
||||||
|
} else if (old_wheel_value >= 0) {
|
||||||
/* scroll wheel up */
|
/* scroll wheel up */
|
||||||
old_wheel_value = -1;
|
old_wheel_value = -1;
|
||||||
|
wheel_repeat = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (status == 0xffffffff) {
|
} else if (status == 0xffffffff) {
|
||||||
|
|
@ -191,6 +192,8 @@ static inline int ipod_4g_button_read(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wheel_end:
|
||||||
|
|
||||||
if ((inl(reg) & 0x8000000) != 0) {
|
if ((inl(reg) & 0x8000000) != 0) {
|
||||||
outl(0xffffffff, 0x7000c120);
|
outl(0xffffffff, 0x7000c120);
|
||||||
outl(0xffffffff, 0x7000c124);
|
outl(0xffffffff, 0x7000c124);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue