summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-03-05 09:07:03 +0000
committerJens Arnold <amiconn@rockbox.org>2006-03-05 09:07:03 +0000
commit8c50ff27887105a209f91448bc4ed067f40fef03 (patch)
tree0eb2e1d60e419147e27c988cc547e7d330b4bbef
parent4ec9dbdd18f6d5365198cfb2925ea0b4b77fe8f9 (diff)
More efficient button_read() for archos recorders and Ondios.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8908 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/button.c67
1 files changed, 41 insertions, 26 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 0b41fb10fe..e2a4e82a58 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -1028,16 +1028,21 @@ static int button_read(void)
/* check F1..F3 and UP */
data = adc_read(ADC_BUTTON_ROW1);
-
- if (data >= LEVEL4)
- btn |= BUTTON_F3;
- else if (data >= LEVEL3)
- btn |= BUTTON_UP;
- else if (data >= LEVEL2)
- btn |= BUTTON_F2;
- else if (data >= LEVEL1)
- btn |= BUTTON_F1;
-
+
+ if (data >= LEVEL1)
+ {
+ if (data >= LEVEL3)
+ if (data >= LEVEL4)
+ btn |= BUTTON_F3;
+ else
+ btn |= BUTTON_UP;
+ else
+ if (data >= LEVEL2)
+ btn |= BUTTON_F2;
+ else
+ btn |= BUTTON_F1;
+ }
+
/* Some units have mushy keypads, so pressing UP also activates
the Left/Right buttons. Let's combat that by skipping the AN5
checks when UP is pressed. */
@@ -1046,14 +1051,19 @@ static int button_read(void)
/* check DOWN, PLAY, LEFT, RIGHT */
data = adc_read(ADC_BUTTON_ROW2);
- if (data >= LEVEL4)
- btn |= BUTTON_DOWN;
- else if (data >= LEVEL3)
- btn |= ROW2_BUTTON3;
- else if (data >= LEVEL2)
- btn |= BUTTON_LEFT;
- else if (data >= LEVEL1)
- btn |= ROW2_BUTTON1;
+ if (data >= LEVEL1)
+ {
+ if (data >= LEVEL3)
+ if (data >= LEVEL4)
+ btn |= BUTTON_DOWN;
+ else
+ btn |= ROW2_BUTTON3;
+ else
+ if (data >= LEVEL2)
+ btn |= BUTTON_LEFT;
+ else
+ btn |= ROW2_BUTTON1;
+ }
}
#elif CONFIG_KEYPAD == PLAYER_PAD
@@ -1085,14 +1095,19 @@ static int button_read(void)
/* Check the 4 direction keys */
data = adc_read(ADC_BUTTON_ROW1);
- if (data >= LEVEL4)
- btn |= BUTTON_LEFT;
- else if (data >= LEVEL3)
- btn |= BUTTON_RIGHT;
- else if (data >= LEVEL2)
- btn |= BUTTON_UP;
- else if (data >= LEVEL1)
- btn |= BUTTON_DOWN;
+ if (data >= LEVEL1)
+ {
+ if (data >= LEVEL3)
+ if (data >= LEVEL4)
+ btn |= BUTTON_LEFT;
+ else
+ btn |= BUTTON_RIGHT;
+ else
+ if (data >= LEVEL2)
+ btn |= BUTTON_UP;
+ else
+ btn |= BUTTON_DOWN;
+ }
#elif CONFIG_KEYPAD == GMINI100_PAD