diff options
author | Thomas Martitz <kugel@rockbox.org> | 2009-09-23 16:59:56 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2009-09-23 16:59:56 +0000 |
commit | ca85c401f58e089b27a4d37ce76265985fa470d7 (patch) | |
tree | 494dd606a51ad63132b5fdf19e4ddc12b552e45a /firmware/drivers/button.c | |
parent | fe4526e8682fe53a9c1eac422f8e9dd8224b8376 (diff) | |
download | rockbox-ca85c401f58e089b27a4d37ce76265985fa470d7.tar.gz rockbox-ca85c401f58e089b27a4d37ce76265985fa470d7.zip |
Rework the simulators button reading to not implement it's own complete driver.
Instead, implement it more as a target driver with button_read_device(), button_init_device() and button_hold(), then use the normal button driver from firmware/drivers/button.c.
Fixes FS#10451 ("backlight off on hold doesn't function properly").
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22799 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/button.c')
-rw-r--r-- | firmware/drivers/button.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 6f6eb8f222..7199d99e28 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c | |||
@@ -33,13 +33,16 @@ | |||
33 | #include "serial.h" | 33 | #include "serial.h" |
34 | #include "power.h" | 34 | #include "power.h" |
35 | #include "powermgmt.h" | 35 | #include "powermgmt.h" |
36 | #ifdef SIMULATOR | ||
37 | #include "button-sdl.h" | ||
38 | #else | ||
36 | #include "button-target.h" | 39 | #include "button-target.h" |
40 | #endif | ||
37 | 41 | ||
38 | #ifdef HAVE_REMOTE_LCD | 42 | #ifdef HAVE_REMOTE_LCD |
39 | #include "lcd-remote.h" | 43 | #include "lcd-remote.h" |
40 | #endif | 44 | #endif |
41 | 45 | ||
42 | #ifndef SIMULATOR | ||
43 | #if 0 | 46 | #if 0 |
44 | /* Older than MAX_EVENT_AGE button events are going to be ignored. | 47 | /* Older than MAX_EVENT_AGE button events are going to be ignored. |
45 | * Used to prevent for example volume going up uncontrollable when events | 48 | * Used to prevent for example volume going up uncontrollable when events |
@@ -82,9 +85,9 @@ static int button_read(void); | |||
82 | #endif | 85 | #endif |
83 | 86 | ||
84 | #ifdef HAVE_TOUCHSCREEN | 87 | #ifdef HAVE_TOUCHSCREEN |
85 | int last_touchscreen_touch; | 88 | static int last_touchscreen_touch; |
86 | #endif | 89 | #endif |
87 | #if defined(HAVE_HEADPHONE_DETECTION) | 90 | #if defined(HAVE_HEADPHONE_DETECTION) && !defined(SIMULATOR) |
88 | static struct timeout hp_detect_timeout; /* Debouncer for headphone plug/unplug */ | 91 | static struct timeout hp_detect_timeout; /* Debouncer for headphone plug/unplug */ |
89 | /* This callback can be used for many different functions if needed - | 92 | /* This callback can be used for many different functions if needed - |
90 | just check to which object tmo points */ | 93 | just check to which object tmo points */ |
@@ -211,8 +214,10 @@ static void button_tick(void) | |||
211 | 214 | ||
212 | /* Safety net for players without hardware | 215 | /* Safety net for players without hardware |
213 | poweroff */ | 216 | poweroff */ |
217 | #ifndef SIMULATOR | ||
214 | if(repeat_count > POWEROFF_COUNT * 10) | 218 | if(repeat_count > POWEROFF_COUNT * 10) |
215 | power_off(); | 219 | power_off(); |
220 | #endif | ||
216 | } | 221 | } |
217 | #endif | 222 | #endif |
218 | } | 223 | } |
@@ -376,7 +381,11 @@ long button_get_w_tmo(int ticks) | |||
376 | 381 | ||
377 | intptr_t button_get_data(void) | 382 | intptr_t button_get_data(void) |
378 | { | 383 | { |
384 | #if defined(SIMULATOR) | ||
385 | return button_get_data_sdl(); | ||
386 | #else | ||
379 | return button_data; | 387 | return button_data; |
388 | #endif | ||
380 | } | 389 | } |
381 | 390 | ||
382 | void button_init(void) | 391 | void button_init(void) |
@@ -416,6 +425,7 @@ void button_init(void) | |||
416 | tick_add_task(button_tick); | 425 | tick_add_task(button_tick); |
417 | } | 426 | } |
418 | 427 | ||
428 | #ifndef SIMULATOR | ||
419 | #ifdef BUTTON_DRIVER_CLOSE | 429 | #ifdef BUTTON_DRIVER_CLOSE |
420 | void button_close(void) | 430 | void button_close(void) |
421 | { | 431 | { |
@@ -423,7 +433,7 @@ void button_close(void) | |||
423 | } | 433 | } |
424 | #endif /* BUTTON_DRIVER_CLOSE */ | 434 | #endif /* BUTTON_DRIVER_CLOSE */ |
425 | 435 | ||
426 | #ifdef HAVE_LCD_BITMAP /* only bitmap displays can be flipped */ | 436 | #ifdef HAVE_LCD_FLIP |
427 | /* | 437 | /* |
428 | * helper function to swap LEFT/RIGHT, UP/DOWN (if present), and F1/F3 (Recorder) | 438 | * helper function to swap LEFT/RIGHT, UP/DOWN (if present), and F1/F3 (Recorder) |
429 | */ | 439 | */ |
@@ -508,7 +518,7 @@ void button_set_flip(bool flip) | |||
508 | restore_irq(oldlevel); | 518 | restore_irq(oldlevel); |
509 | } | 519 | } |
510 | } | 520 | } |
511 | #endif /* HAVE_LCD_BITMAP */ | 521 | #endif /* HAVE_LCD_FLIP */ |
512 | 522 | ||
513 | #ifdef HAVE_BACKLIGHT | 523 | #ifdef HAVE_BACKLIGHT |
514 | void set_backlight_filter_keypress(bool value) | 524 | void set_backlight_filter_keypress(bool value) |
@@ -523,6 +533,7 @@ void set_remote_backlight_filter_keypress(bool value) | |||
523 | #endif | 533 | #endif |
524 | #endif | 534 | #endif |
525 | 535 | ||
536 | #endif /* SIMULATOR */ | ||
526 | /* | 537 | /* |
527 | * Get button pressed from hardware | 538 | * Get button pressed from hardware |
528 | */ | 539 | */ |
@@ -537,10 +548,11 @@ static int button_read(void) | |||
537 | #endif | 548 | #endif |
538 | int retval; | 549 | int retval; |
539 | 550 | ||
540 | #ifdef HAVE_LCD_BITMAP | 551 | #ifdef HAVE_LCD_FLIP |
541 | if (btn && flipped) | 552 | if (btn && flipped) |
542 | btn = button_flip(btn); /* swap upside down */ | 553 | btn = button_flip(btn); /* swap upside down */ |
543 | #endif | 554 | #endif /* HAVE_LCD_FLIP */ |
555 | |||
544 | #ifdef HAVE_TOUCHSCREEN | 556 | #ifdef HAVE_TOUCHSCREEN |
545 | if (btn & BUTTON_TOUCHSCREEN) | 557 | if (btn & BUTTON_TOUCHSCREEN) |
546 | last_touchscreen_touch = current_tick; | 558 | last_touchscreen_touch = current_tick; |
@@ -574,7 +586,6 @@ int touchscreen_last_touch(void) | |||
574 | return last_touchscreen_touch; | 586 | return last_touchscreen_touch; |
575 | } | 587 | } |
576 | #endif | 588 | #endif |
577 | #endif /* SIMULATOR */ | ||
578 | 589 | ||
579 | #ifdef HAVE_WHEEL_ACCELERATION | 590 | #ifdef HAVE_WHEEL_ACCELERATION |
580 | /* WHEEL_ACCEL_FACTOR = 2^16 / WHEEL_ACCEL_START */ | 591 | /* WHEEL_ACCEL_FACTOR = 2^16 / WHEEL_ACCEL_START */ |