summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrandon Low <lostlogic@rockbox.org>2006-03-19 01:12:28 +0000
committerBrandon Low <lostlogic@rockbox.org>2006-03-19 01:12:28 +0000
commitdd5a85839e24e487ba70cc30aea79c3a29c5e447 (patch)
treecf185130e1bdbe0e18dc5f076d7531baa54d8211
parent5650b70517e2de03a7ab6b07a1532094a52fe0c3 (diff)
downloadrockbox-dd5a85839e24e487ba70cc30aea79c3a29c5e447.tar.gz
rockbox-dd5a85839e24e487ba70cc30aea79c3a29c5e447.zip
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
-rw-r--r--firmware/drivers/button.c61
1 files changed, 32 insertions, 29 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 0502f73c92..d86b8d8d2d 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -138,9 +138,7 @@ static inline int ipod_4g_button_read(void)
if ((status & 0x800000ff) == 0x8000001a) {
static int old_wheel_value IDATA_ATTR = -1;
- /* NB: highest wheel = 0x5F, clockwise increases */
- int new_wheel_value = (status << 9) >> 25;
- int wheel_delta = new_wheel_value - old_wheel_value;
+ static int wheel_repeat = 0;
if (status & 0x100)
btn |= BUTTON_SELECT;
@@ -153,37 +151,40 @@ static inline int ipod_4g_button_read(void)
if (status & 0x1000)
btn |= BUTTON_MENU;
if (status & 0x40000000) {
+ /* NB: highest wheel = 0x5F, clockwise increases */
+ int new_wheel_value = (status << 9) >> 25;
backlight_on();
/* The queue should have no other events when scrolling */
- if (queue_empty(&button_queue)) {
-
- if (old_wheel_value >= 0) {
- /* This is for later = BUTTON_SCROLL_TOUCH;*/
- unsigned long data;
-
- if (wheel_delta < -48)
- wheel_delta += 96; /* Forward wrapping case */
- else if (wheel_delta > 48)
- wheel_delta -= 96; /* Backward wrapping case */
-
- if (wheel_delta > 4) {
- old_wheel_value = new_wheel_value;
- data = (wheel_delta << 16) | new_wheel_value;
- queue_post(&button_queue, BUTTON_SCROLL_FWD,
- (void *)data);
- } else if (wheel_delta < -4) {
- old_wheel_value = new_wheel_value;
- data = (wheel_delta << 16) | new_wheel_value;
- queue_post(&button_queue, BUTTON_SCROLL_BACK,
- (void *)data);
- }
-
- } else
- old_wheel_value = new_wheel_value;
+ if (queue_empty(&button_queue) && old_wheel_value >= 0) {
+
+ /* This is for later = BUTTON_SCROLL_TOUCH;*/
+ int wheel_delta = new_wheel_value - old_wheel_value;
+ unsigned long data;
+ int wheel_keycode;
+
+ if (wheel_delta < -48)
+ wheel_delta += 96; /* Forward wrapping case */
+ else if (wheel_delta > 48)
+ wheel_delta -= 96; /* Backward wrapping case */
+
+ if (wheel_delta > 4) {
+ wheel_keycode = BUTTON_SCROLL_FWD;
+ } else if (wheel_delta < -4) {
+ wheel_keycode = BUTTON_SCROLL_BACK;
+ } else goto wheel_end;
+
+ data = (wheel_delta << 16) | new_wheel_value;
+ queue_post(&button_queue, wheel_keycode | wheel_repeat,
+ (void *)data);
+
+ if (!wheel_repeat) wheel_repeat = BUTTON_REPEAT;
}
- } else if (wheel_delta == 0) {
+
+ old_wheel_value = new_wheel_value;
+ } else if (old_wheel_value >= 0) {
/* scroll wheel up */
old_wheel_value = -1;
+ wheel_repeat = 0;
}
} else if (status == 0xffffffff) {
@@ -191,6 +192,8 @@ static inline int ipod_4g_button_read(void)
}
}
+wheel_end:
+
if ((inl(reg) & 0x8000000) != 0) {
outl(0xffffffff, 0x7000c120);
outl(0xffffffff, 0x7000c124);