summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Low <lostlogic@rockbox.org>2006-03-10 12:55:13 +0000
committerBrandon Low <lostlogic@rockbox.org>2006-03-10 12:55:13 +0000
commit4431ab237ef7a884b1dd6692334a03273cc3970d (patch)
tree89367dc62ddd642e4aa842e3bf388870257fcca3
parentea4dea67aee1081f4f090f0c763623c3aacf1f49 (diff)
downloadrockbox-4431ab237ef7a884b1dd6692334a03273cc3970d.tar.gz
rockbox-4431ab237ef7a884b1dd6692334a03273cc3970d.zip
Code policing
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8989 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/button.c164
1 files changed, 83 insertions, 81 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 08cc23ce3b..49ada65697 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -259,42 +259,42 @@ void handle_scroll_wheel(int new_scroll, int was_hold, int reverse)
259 } 259 }
260 else if (!was_hold) { 260 else if (!was_hold) {
261 switch (scroll_state[prev_scroll][new_scroll]) { 261 switch (scroll_state[prev_scroll][new_scroll]) {
262 case 1: 262 case 1:
263 if (reverse) { 263 if (reverse) {
264 /* 'r' keypress */ 264 /* 'r' keypress */
265 wheel_keycode = BUTTON_SCROLL_FWD; 265 wheel_keycode = BUTTON_SCROLL_FWD;
266 } 266 }
267 else { 267 else {
268 /* 'l' keypress */ 268 /* 'l' keypress */
269 wheel_keycode = BUTTON_SCROLL_BACK; 269 wheel_keycode = BUTTON_SCROLL_BACK;
270 } 270 }
271 break; 271 break;
272 case -1: 272 case -1:
273 if (reverse) { 273 if (reverse) {
274 /* 'l' keypress */ 274 /* 'l' keypress */
275 wheel_keycode = BUTTON_SCROLL_BACK; 275 wheel_keycode = BUTTON_SCROLL_BACK;
276 } 276 }
277 else { 277 else {
278 /* 'r' keypress */ 278 /* 'r' keypress */
279 wheel_keycode = BUTTON_SCROLL_FWD; 279 wheel_keycode = BUTTON_SCROLL_FWD;
280 } 280 }
281 break; 281 break;
282 default: 282 default:
283 /* only happens if we get out of sync */ 283 /* only happens if we get out of sync */
284 break; 284 break;
285 285
286 } 286 }
287 } 287 }
288 if (wheel_keycode != BUTTON_NONE) 288 if (wheel_keycode != BUTTON_NONE)
289 queue_post(&button_queue, wheel_keycode, NULL); 289 queue_post(&button_queue, wheel_keycode, NULL);
290 prev_scroll = new_scroll; 290 prev_scroll = new_scroll;
291} 291}
292#endif 292#endif
293#if (CONFIG_KEYPAD == IPOD_4G_PAD) && (defined(APPLE_IPODMINI)) 293#if (CONFIG_KEYPAD == IPOD_4G_PAD) && (defined(APPLE_IPODMINI))
294static int ipod_mini_button_read(void) 294static int ipod_mini_button_read(void)
295{ 295{
296 unsigned char source, wheel_source, state, wheel_state; 296 unsigned char source, wheel_source, state, wheel_state;
297 int btn = BUTTON_NONE; 297 int btn = BUTTON_NONE;
298 298
299 /* 299 /*
300 * we need some delay for mini, cause hold generates several interrupts, 300 * we need some delay for mini, cause hold generates several interrupts,
@@ -353,63 +353,63 @@ void ipod_mini_button_int(void)
353#if CONFIG_KEYPAD == IPOD_3G_PAD 353#if CONFIG_KEYPAD == IPOD_3G_PAD
354static int ipod_3g_button_read(void) 354static int ipod_3g_button_read(void)
355{ 355{
356 unsigned char source, state; 356 unsigned char source, state;
357 static int was_hold = 0; 357 static int was_hold = 0;
358int btn = BUTTON_NONE; 358 int btn = BUTTON_NONE;
359 /* 359 /*
360 * we need some delay for g3, cause hold generates several interrupts, 360 * we need some delay for g3, cause hold generates several interrupts,
361 * some of them delayed 361 * some of them delayed
362 */ 362 */
363 udelay(250); 363 udelay(250);
364 364
365 /* get source of interupts */ 365 /* get source of interupts */
366 source = GPIOA_INT_STAT; 366 source = GPIOA_INT_STAT;
367 367
368 368
369 /* get current keypad status */ 369 /* get current keypad status */
370 state = GPIOA_INPUT_VAL; 370 state = GPIOA_INPUT_VAL;
371 GPIOA_INT_LEV = ~state; 371 GPIOA_INT_LEV = ~state;
372 372
373 if (was_hold && source == 0x40 && state == 0xbf) { 373 if (was_hold && source == 0x40 && state == 0xbf) {
374 /* ack any active interrupts */
375 GPIOA_INT_CLR = source;
376 return BUTTON_NONE;
377 }
378 was_hold = 0;
379
380
381 if ((state & 0x20) == 0) {
382 /* 3g hold switch is active low */
383 btn |= BUTTON_HOLD;
384 was_hold = 1;
385 /* hold switch on 3g causes all outputs to go low */
386 /* we shouldn't interpret these as key presses */
387 GPIOA_INT_CLR = source;
388 return BUTTON_NONE;
389 }
390 if ((state & 0x1) == 0) {
391 btn |= BUTTON_RIGHT;
392 }
393 if ((state & 0x2) == 0) {
394 btn |= BUTTON_SELECT;
395 }
396 if ((state & 0x4) == 0) {
397 btn |= BUTTON_PLAY;
398 }
399 if ((state & 0x8) == 0) {
400 btn |= BUTTON_LEFT;
401 }
402 if ((state & 0x10) == 0) {
403 btn |= BUTTON_MENU;
404 }
405
406 if (source & 0xc0) {
407 handle_scroll_wheel((state & 0xc0) >> 6, was_hold, 0);
408 }
409
410 /* ack any active interrupts */ 374 /* ack any active interrupts */
411 GPIOA_INT_CLR = source; 375 GPIOA_INT_CLR = source;
412 376 return BUTTON_NONE;
377 }
378 was_hold = 0;
379
380
381 if ((state & 0x20) == 0) {
382 /* 3g hold switch is active low */
383 btn |= BUTTON_HOLD;
384 was_hold = 1;
385 /* hold switch on 3g causes all outputs to go low */
386 /* we shouldn't interpret these as key presses */
387 GPIOA_INT_CLR = source;
388 return BUTTON_NONE;
389 }
390 if ((state & 0x1) == 0) {
391 btn |= BUTTON_RIGHT;
392 }
393 if ((state & 0x2) == 0) {
394 btn |= BUTTON_SELECT;
395 }
396 if ((state & 0x4) == 0) {
397 btn |= BUTTON_PLAY;
398 }
399 if ((state & 0x8) == 0) {
400 btn |= BUTTON_LEFT;
401 }
402 if ((state & 0x10) == 0) {
403 btn |= BUTTON_MENU;
404 }
405
406 if (source & 0xc0) {
407 handle_scroll_wheel((state & 0xc0) >> 6, was_hold, 0);
408 }
409
410 /* ack any active interrupts */
411 GPIOA_INT_CLR = source;
412
413 return btn; 413 return btn;
414} 414}
415 415
@@ -478,15 +478,16 @@ static void button_tick(void)
478 which doesn't shut down easily with the OFF 478 which doesn't shut down easily with the OFF
479 key */ 479 key */
480#ifdef HAVE_SW_POWEROFF 480#ifdef HAVE_SW_POWEROFF
481 if ((btn == POWEROFF_BUTTON
481#ifdef BUTTON_RC_STOP 482#ifdef BUTTON_RC_STOP
482 if ((btn == POWEROFF_BUTTON || btn == BUTTON_RC_STOP) && 483 || btn == BUTTON_RC_STOP) &&
483#else 484#else
484 if (btn == POWEROFF_BUTTON && 485 ) &&
485#endif 486#endif
486#if defined(HAVE_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING) 487#if defined(HAVE_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING)
487 !charger_inserted() && 488 !charger_inserted() &&
488#endif 489#endif
489 repeat_count > POWEROFF_COUNT) 490 repeat_count > POWEROFF_COUNT)
490 { 491 {
491 /* Tell the main thread that it's time to 492 /* Tell the main thread that it's time to
492 power off */ 493 power off */
@@ -518,7 +519,8 @@ static void button_tick(void)
518 { 519 {
519 if (queue_empty(&button_queue)) 520 if (queue_empty(&button_queue))
520 { 521 {
521 queue_post(&button_queue, BUTTON_REPEAT | btn, NULL); 522 queue_post(
523 &button_queue, BUTTON_REPEAT | btn, NULL);
522 post = false; 524 post = false;
523 } 525 }
524 } 526 }
@@ -1239,9 +1241,9 @@ bool button_hold(void)
1239static bool remote_button_hold_only(void) 1241static bool remote_button_hold_only(void)
1240{ 1242{
1241 if(remote_type() == REMOTETYPE_H300_NONLCD) 1243 if(remote_type() == REMOTETYPE_H300_NONLCD)
1242 return adc_scan(ADC_REMOTE)<0x0d; /* hold should be 0x00 */ 1244 return adc_scan(ADC_REMOTE)<0x0d; /* hold should be 0x00 */
1243 else 1245 else
1244 return (GPIO1_READ & 0x00100000)?true:false; 1246 return (GPIO1_READ & 0x00100000)?true:false;
1245} 1247}
1246 1248
1247/* returns true only if there is remote present */ 1249/* returns true only if there is remote present */