diff options
Diffstat (limited to 'firmware/drivers/button.c')
-rw-r--r-- | firmware/drivers/button.c | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index a368976d6e..b5f4693215 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c | |||
@@ -69,7 +69,9 @@ static void button_tick(void) | |||
69 | int diff; | 69 | int diff; |
70 | int btn; | 70 | int btn; |
71 | 71 | ||
72 | #if !defined(HAVE_MMC) && (CONFIG_KEYPAD != IRIVER_H100_PAD) | 72 | #if !defined(HAVE_MMC) && (CONFIG_KEYPAD != IRIVER_H100_PAD) \ |
73 | && (CONFIG_KEYPAD != GMINI100_PAD) | ||
74 | |||
73 | /* Post events for the remote control */ | 75 | /* Post events for the remote control */ |
74 | btn = remote_control_rx(); | 76 | btn = remote_control_rx(); |
75 | if(btn) | 77 | if(btn) |
@@ -83,7 +85,7 @@ static void button_tick(void) | |||
83 | { | 85 | { |
84 | bool post = false; | 86 | bool post = false; |
85 | btn = button_read(); | 87 | btn = button_read(); |
86 | 88 | ||
87 | /* Find out if a key has been released */ | 89 | /* Find out if a key has been released */ |
88 | diff = btn ^ lastbtn; | 90 | diff = btn ^ lastbtn; |
89 | if(diff && (btn & diff) == 0) | 91 | if(diff && (btn & diff) == 0) |
@@ -100,7 +102,7 @@ static void button_tick(void) | |||
100 | post = true; | 102 | post = true; |
101 | repeat = false; | 103 | repeat = false; |
102 | repeat_speed = REPEAT_INTERVAL_START; | 104 | repeat_speed = REPEAT_INTERVAL_START; |
103 | 105 | ||
104 | } | 106 | } |
105 | else /* repeat? */ | 107 | else /* repeat? */ |
106 | { | 108 | { |
@@ -114,9 +116,9 @@ static void button_tick(void) | |||
114 | if (repeat_speed < REPEAT_INTERVAL_FINISH) | 116 | if (repeat_speed < REPEAT_INTERVAL_FINISH) |
115 | repeat_speed = REPEAT_INTERVAL_FINISH; | 117 | repeat_speed = REPEAT_INTERVAL_FINISH; |
116 | count = repeat_speed; | 118 | count = repeat_speed; |
117 | 119 | ||
118 | repeat_count++; | 120 | repeat_count++; |
119 | 121 | ||
120 | /* Send a SYS_POWEROFF event if we have a device | 122 | /* Send a SYS_POWEROFF event if we have a device |
121 | which doesn't shut down easily with the OFF | 123 | which doesn't shut down easily with the OFF |
122 | key */ | 124 | key */ |
@@ -135,7 +137,7 @@ static void button_tick(void) | |||
135 | repeat = true; | 137 | repeat = true; |
136 | repeat_count = 0; | 138 | repeat_count = 0; |
137 | /* initial repeat */ | 139 | /* initial repeat */ |
138 | count = REPEAT_INTERVAL_START; | 140 | count = REPEAT_INTERVAL_START; |
139 | } | 141 | } |
140 | } | 142 | } |
141 | } | 143 | } |
@@ -146,7 +148,7 @@ static void button_tick(void) | |||
146 | else | 148 | else |
147 | queue_post(&button_queue, btn, NULL); | 149 | queue_post(&button_queue, btn, NULL); |
148 | backlight_on(); | 150 | backlight_on(); |
149 | 151 | ||
150 | reset_poweroff_timer(); | 152 | reset_poweroff_timer(); |
151 | } | 153 | } |
152 | } | 154 | } |
@@ -159,7 +161,7 @@ static void button_tick(void) | |||
159 | lastbtn = btn & ~(BUTTON_REL | BUTTON_REPEAT); | 161 | lastbtn = btn & ~(BUTTON_REL | BUTTON_REPEAT); |
160 | tick = 0; | 162 | tick = 0; |
161 | } | 163 | } |
162 | 164 | ||
163 | backlight_tick(); | 165 | backlight_tick(); |
164 | } | 166 | } |
165 | 167 | ||
@@ -167,7 +169,7 @@ int button_get(bool block) | |||
167 | { | 169 | { |
168 | struct event ev; | 170 | struct event ev; |
169 | 171 | ||
170 | if ( block || !queue_empty(&button_queue) ) | 172 | if ( block || !queue_empty(&button_queue) ) |
171 | { | 173 | { |
172 | queue_wait(&button_queue, &ev); | 174 | queue_wait(&button_queue, &ev); |
173 | return ev.id; | 175 | return ev.id; |
@@ -201,6 +203,8 @@ void button_init(void) | |||
201 | PAIOR &= ~0x0820; /* Inputs */ | 203 | PAIOR &= ~0x0820; /* Inputs */ |
202 | #elif CONFIG_KEYPAD == ONDIO_PAD | 204 | #elif CONFIG_KEYPAD == ONDIO_PAD |
203 | /* nothing to initialize here */ | 205 | /* nothing to initialize here */ |
206 | #elif CONFIG_KEYPAD == GMINI100_PAD | ||
207 | /* nothing to initialize here */ | ||
204 | #endif /* CONFIG_KEYPAD */ | 208 | #endif /* CONFIG_KEYPAD */ |
205 | 209 | ||
206 | queue_init(&button_queue); | 210 | queue_init(&button_queue); |
@@ -221,7 +225,7 @@ static int button_flip(int button) | |||
221 | { | 225 | { |
222 | int newbutton; | 226 | int newbutton; |
223 | 227 | ||
224 | newbutton = button & | 228 | newbutton = button & |
225 | ~(BUTTON_UP | BUTTON_DOWN | 229 | ~(BUTTON_UP | BUTTON_DOWN |
226 | | BUTTON_LEFT | BUTTON_RIGHT | 230 | | BUTTON_LEFT | BUTTON_RIGHT |
227 | #if CONFIG_KEYPAD == RECORDER_PAD | 231 | #if CONFIG_KEYPAD == RECORDER_PAD |
@@ -257,14 +261,14 @@ void button_set_flip(bool flip) | |||
257 | { | 261 | { |
258 | /* avoid race condition with the button_tick() */ | 262 | /* avoid race condition with the button_tick() */ |
259 | int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); | 263 | int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); |
260 | lastbtn = button_flip(lastbtn); | 264 | lastbtn = button_flip(lastbtn); |
261 | flipped = flip; | 265 | flipped = flip; |
262 | set_irq_level(oldlevel); | 266 | set_irq_level(oldlevel); |
263 | } | 267 | } |
264 | } | 268 | } |
265 | #endif /* HAVE_LCD_BITMAP */ | 269 | #endif /* HAVE_LCD_BITMAP */ |
266 | 270 | ||
267 | /* | 271 | /* |
268 | Archos hardware button hookup | 272 | Archos hardware button hookup |
269 | ============================= | 273 | ============================= |
270 | 274 | ||
@@ -288,7 +292,7 @@ void button_set_flip(bool flip) | |||
288 | 292 | ||
289 | STOP: PA11 | 293 | STOP: PA11 |
290 | ON: PA5 | 294 | ON: PA5 |
291 | 295 | ||
292 | All buttons are low active | 296 | All buttons are low active |
293 | 297 | ||
294 | Ondio | 298 | Ondio |
@@ -369,7 +373,7 @@ static int button_read(void) | |||
369 | else | 373 | else |
370 | if (data < 0xf0) | 374 | if (data < 0xf0) |
371 | btn = BUTTON_REC; | 375 | btn = BUTTON_REC; |
372 | 376 | ||
373 | data = GPIO1_READ; | 377 | data = GPIO1_READ; |
374 | if ((data & 0x20) == 0) | 378 | if ((data & 0x20) == 0) |
375 | btn |= BUTTON_ON; | 379 | btn |= BUTTON_ON; |
@@ -409,7 +413,7 @@ static int button_read(void) | |||
409 | { | 413 | { |
410 | /* check DOWN, PLAY, LEFT, RIGHT */ | 414 | /* check DOWN, PLAY, LEFT, RIGHT */ |
411 | data = adc_read(ADC_BUTTON_ROW2); | 415 | data = adc_read(ADC_BUTTON_ROW2); |
412 | 416 | ||
413 | if (data >= LEVEL4) | 417 | if (data >= LEVEL4) |
414 | btn |= BUTTON_DOWN; | 418 | btn |= BUTTON_DOWN; |
415 | else if (data >= LEVEL3) | 419 | else if (data >= LEVEL3) |
@@ -458,6 +462,25 @@ static int button_read(void) | |||
458 | else if (data >= LEVEL1) | 462 | else if (data >= LEVEL1) |
459 | btn |= BUTTON_DOWN; | 463 | btn |= BUTTON_DOWN; |
460 | 464 | ||
465 | #elif CONFIG_KEYPAD == GMINI100_PAD | ||
466 | |||
467 | if (adc_read(7) < 0x80) | ||
468 | btn |= BUTTON_LEFT; | ||
469 | else if (adc_read(7) < 0x168) | ||
470 | btn |= BUTTON_DOWN; | ||
471 | else if (adc_read(7) < 0x260) | ||
472 | btn |= BUTTON_RIGHT; | ||
473 | else if (adc_read(7) < 0x360) | ||
474 | btn |= BUTTON_UP; | ||
475 | |||
476 | if (adc_read(6) < 0x240) | ||
477 | btn |= BUTTON_CANCEL; | ||
478 | else if (adc_read(6) < 0x280) | ||
479 | btn |= BUTTON_PLAY; | ||
480 | else if (adc_read(6) < 0x300) | ||
481 | btn |= BUTTON_MENU; | ||
482 | |||
483 | |||
461 | #endif /* CONFIG_KEYPAD */ | 484 | #endif /* CONFIG_KEYPAD */ |
462 | 485 | ||
463 | 486 | ||