diff options
author | Thomas Martitz <kugel@rockbox.org> | 2010-10-31 15:32:57 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2010-10-31 15:32:57 +0000 |
commit | 49f1ec8e8ad0b4c06df01fcdd4b18037fbe3ebcc (patch) | |
tree | b185e604dcea64865389f5b149e754ba8ffd3f75 /apps | |
parent | dbe2ac1ec6f4ed88f267d2a4df024b6dc42a87ff (diff) | |
download | rockbox-49f1ec8e8ad0b4c06df01fcdd4b18037fbe3ebcc.tar.gz rockbox-49f1ec8e8ad0b4c06df01fcdd4b18037fbe3ebcc.zip |
Add support multimedia keys/buttons to the core, and adapt Rockbox on android for it (multimedia buttons are found on wired headsets and the lock screen in cyanogenmod).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28421 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/action.c | 5 | ||||
-rw-r--r-- | apps/gui/wps.c | 14 | ||||
-rw-r--r-- | apps/menu.c | 16 | ||||
-rw-r--r-- | apps/misc.c | 37 |
4 files changed, 59 insertions, 13 deletions
diff --git a/apps/action.c b/apps/action.c index 8f427c8d68..d61930a08c 100644 --- a/apps/action.c +++ b/apps/action.c | |||
@@ -183,8 +183,9 @@ static int get_action_worker(int context, int timeout, | |||
183 | else | 183 | else |
184 | button = button_get_w_tmo(timeout); | 184 | button = button_get_w_tmo(timeout); |
185 | 185 | ||
186 | /* Data from sys events can be pulled with button_get_data */ | 186 | /* Data from sys events can be pulled with button_get_data |
187 | if (button == BUTTON_NONE || button & SYS_EVENT) | 187 | * multimedia button presses don't go through the action system */ |
188 | if (button == BUTTON_NONE || button & (SYS_EVENT|BUTTON_MULTIMEDIA)) | ||
188 | return button; | 189 | return button; |
189 | /* Don't send any buttons through untill we see the release event */ | 190 | /* Don't send any buttons through untill we see the release event */ |
190 | if (wait_for_release) | 191 | if (wait_for_release) |
diff --git a/apps/gui/wps.c b/apps/gui/wps.c index a5fe304d21..7d633ad4e8 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c | |||
@@ -1045,18 +1045,18 @@ long gui_wps_show(void) | |||
1045 | exit = true; | 1045 | exit = true; |
1046 | break; | 1046 | break; |
1047 | #endif | 1047 | #endif |
1048 | case SYS_POWEROFF: | ||
1049 | default_event_handler(SYS_POWEROFF); | ||
1050 | break; | ||
1051 | case ACTION_WPS_VIEW_PLAYLIST: | 1048 | case ACTION_WPS_VIEW_PLAYLIST: |
1052 | gwps_leave_wps(); | 1049 | gwps_leave_wps(); |
1053 | return GO_TO_PLAYLIST_VIEWER; | 1050 | return GO_TO_PLAYLIST_VIEWER; |
1054 | break; | 1051 | break; |
1055 | default: | 1052 | default: |
1056 | if(default_event_handler(button) == SYS_USB_CONNECTED) | 1053 | switch(default_event_handler(button)) |
1057 | { | 1054 | { /* music has been stopped by the default handler */ |
1058 | gwps_leave_wps(); | 1055 | case SYS_USB_CONNECTED: |
1059 | return GO_TO_ROOT; | 1056 | case SYS_CALL_INCOMING: |
1057 | case BUTTON_MULTIMEDIA_STOP: | ||
1058 | gwps_leave_wps(); | ||
1059 | return GO_TO_ROOT; | ||
1060 | } | 1060 | } |
1061 | update = true; | 1061 | update = true; |
1062 | break; | 1062 | break; |
diff --git a/apps/menu.c b/apps/menu.c index 9d67c7b03e..5839a51c21 100644 --- a/apps/menu.c +++ b/apps/menu.c | |||
@@ -650,10 +650,20 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected, | |||
650 | } | 650 | } |
651 | #endif | 651 | #endif |
652 | } | 652 | } |
653 | else if(default_event_handler(action) == SYS_USB_CONNECTED) | 653 | else |
654 | { | 654 | { |
655 | ret = MENU_ATTACHED_USB; | 655 | switch(default_event_handler(action)) |
656 | done = true; | 656 | { |
657 | case SYS_USB_CONNECTED: | ||
658 | ret = MENU_ATTACHED_USB; | ||
659 | done = true; | ||
660 | break; | ||
661 | case SYS_CALL_HUNG_UP: | ||
662 | case BUTTON_MULTIMEDIA_PLAYPAUSE: | ||
663 | /* remove splash from playlist_resume() */ | ||
664 | redraw_lists = true; | ||
665 | break; | ||
666 | } | ||
657 | } | 667 | } |
658 | 668 | ||
659 | if (redraw_lists && !done) | 669 | if (redraw_lists && !done) |
diff --git a/apps/misc.c b/apps/misc.c index 8d0ca7922f..c41f63456c 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -529,6 +529,7 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame | |||
529 | #if CONFIG_PLATFORM & PLATFORM_ANDROID | 529 | #if CONFIG_PLATFORM & PLATFORM_ANDROID |
530 | static bool resume = false; | 530 | static bool resume = false; |
531 | #endif | 531 | #endif |
532 | |||
532 | switch(event) | 533 | switch(event) |
533 | { | 534 | { |
534 | case SYS_BATTERY_UPDATE: | 535 | case SYS_BATTERY_UPDATE: |
@@ -629,11 +630,45 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame | |||
629 | if (resume && playlist_resume() != -1) | 630 | if (resume && playlist_resume() != -1) |
630 | { | 631 | { |
631 | playlist_start(global_status.resume_index, | 632 | playlist_start(global_status.resume_index, |
632 | global_status.resume_offset); | 633 | global_status.resume_offset); |
633 | } | 634 | } |
634 | resume = false; | 635 | resume = false; |
635 | return SYS_CALL_HUNG_UP; | 636 | return SYS_CALL_HUNG_UP; |
636 | #endif | 637 | #endif |
638 | #ifdef HAVE_MULTIMEDIA_KEYS | ||
639 | /* multimedia keys on keyboards, headsets */ | ||
640 | case BUTTON_MULTIMEDIA_PLAYPAUSE: | ||
641 | { | ||
642 | int status = audio_status(); | ||
643 | if (status & AUDIO_STATUS_PLAY) | ||
644 | { | ||
645 | if (status & AUDIO_STATUS_PAUSE) | ||
646 | audio_resume(); | ||
647 | else | ||
648 | audio_pause(); | ||
649 | } | ||
650 | else | ||
651 | if (playlist_resume() != -1) | ||
652 | { | ||
653 | playlist_start(global_status.resume_index, | ||
654 | global_status.resume_offset); | ||
655 | } | ||
656 | return event; | ||
657 | } | ||
658 | case BUTTON_MULTIMEDIA_NEXT: | ||
659 | audio_next(); | ||
660 | return event; | ||
661 | case BUTTON_MULTIMEDIA_PREV: | ||
662 | audio_prev(); | ||
663 | return event; | ||
664 | case BUTTON_MULTIMEDIA_STOP: | ||
665 | list_stop_handler(); | ||
666 | return event; | ||
667 | case BUTTON_MULTIMEDIA_REW: | ||
668 | case BUTTON_MULTIMEDIA_FFWD: | ||
669 | /* not supported yet, needs to be done in the WPS */ | ||
670 | return 0; | ||
671 | #endif | ||
637 | } | 672 | } |
638 | return 0; | 673 | return 0; |
639 | } | 674 | } |