From c8bd9129bf146c3c0bbacc744ab509709a004fd7 Mon Sep 17 00:00:00 2001 From: Martin Scarratt Date: Sun, 20 Aug 2006 21:33:40 +0000 Subject: [PATCH] Button action code for recording screen. Shouldnt make any noticable difference in recording screen button operation except for H300 I-River remote, which should now work as expected, -10 button = LCD off git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10666 a1c6a512-1295-4272-9138-f99709370657 --- apps/action.h | 6 ++ apps/keymaps/keymap-h1x0_h3x0.c | 60 ++++++++++-- apps/keymaps/keymap-ondio.c | 12 +++ apps/keymaps/keymap-recorder.c | 15 +++ apps/keymaps/keymap-x5.c | 15 +++ apps/recorder/peakmeter.c | 3 +- apps/recorder/recording.c | 166 ++++---------------------------- 7 files changed, 122 insertions(+), 155 deletions(-) diff --git a/apps/action.h b/apps/action.h index e95d009a0f..a74a2e145d 100644 --- a/apps/action.h +++ b/apps/action.h @@ -53,6 +53,7 @@ enum { CONTEXT_BOOKMARKSCREEN, /*NOTE: requires the action_setting_* mappings also */ CONTEXT_QUICKSCREEN, /* uses ACTION_QS_ defines below */ CONTEXT_PITCHSCREEN, /* uses ACTION_PS_ defines below */ + CONTEXT_RECSCREEN, }; @@ -111,6 +112,11 @@ enum { ACTION_TREE_WPS, /* recording screen */ + ACTION_REC_LCD, + ACTION_REC_PAUSE, + ACTION_REC_NEWFILE, + ACTION_REC_F2, + ACTION_REC_F3, /* main menu */ diff --git a/apps/keymaps/keymap-h1x0_h3x0.c b/apps/keymaps/keymap-h1x0_h3x0.c index 5a6f823d53..969bb9c46b 100644 --- a/apps/keymaps/keymap-h1x0_h3x0.c +++ b/apps/keymaps/keymap-h1x0_h3x0.c @@ -197,6 +197,17 @@ const struct button_mapping button_context_pitchscreen[] = { LAST_ITEM_IN_LIST }; /* button_context_pitchcreen */ +const struct button_mapping button_context_recscreen[] = { + { ACTION_REC_PAUSE, BUTTON_ON, BUTTON_NONE }, + { ACTION_REC_NEWFILE, BUTTON_REC, BUTTON_NONE }, + { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_SETTINGS_INC, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_recscreen */ + /***************************************************************************** * Remote control mappings *****************************************************************************/ @@ -384,7 +395,7 @@ const struct button_mapping button_context_settingsgraphical_h100remote[] = { { ACTION_STD_NEXTREPEAT, BUTTON_RC_BITRATE|BUTTON_REPEAT, BUTTON_NONE }, LAST_ITEM_IN_LIST -}; +}; /* button_context_recscreen_h100remote*/ const struct button_mapping button_context_settingsgraphical_h300lcdremote[] = { { ACTION_SETTINGS_INC, BUTTON_RC_FF, BUTTON_NONE }, @@ -397,7 +408,7 @@ const struct button_mapping button_context_settingsgraphical_h300lcdremote[] = { ACTION_STD_NEXTREPEAT, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, LAST_ITEM_IN_LIST -}; +}; /* button_context_recscreen_h300lcdremote */ const struct button_mapping button_context_yesno_h100remote[] = { { ACTION_YESNO_ACCEPT, BUTTON_RC_MENU, BUTTON_NONE }, @@ -477,6 +488,29 @@ const struct button_mapping button_context_pitchscreen_h300lcdremote[] = { LAST_ITEM_IN_LIST }; +const struct button_mapping button_context_recscreen_h100remote[] = { + { ACTION_REC_LCD, BUTTON_RC_VOL_DOWN, BUTTON_NONE }, + { ACTION_REC_PAUSE, BUTTON_RC_ON, BUTTON_NONE }, + { ACTION_REC_NEWFILE, BUTTON_RC_REC, BUTTON_NONE }, + { ACTION_SETTINGS_INC, BUTTON_RC_BITRATE, BUTTON_NONE }, + { ACTION_SETTINGS_INC, BUTTON_RC_BITRATE|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_RC_SOURCE, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_RC_SOURCE|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; + +const struct button_mapping button_context_recscreen_h300lcdremote[] = { + { ACTION_REC_LCD, BUTTON_RC_SOURCE, BUTTON_NONE }, + { ACTION_REC_PAUSE, BUTTON_RC_ON, BUTTON_NONE }, + { ACTION_REC_NEWFILE, BUTTON_RC_REC, BUTTON_NONE }, + { ACTION_SETTINGS_INC, BUTTON_RC_FF, BUTTON_NONE }, + { ACTION_SETTINGS_INC, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_RC_REW, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* the actual used tables */ @@ -497,7 +531,9 @@ static const struct button_mapping *remote_btn_ctxt_quickscreen = button_context_quickscreen_h100remote, *remote_btn_ctxt_pitchscreen - = button_context_pitchscreen_h100remote; + = button_context_pitchscreen_h100remote, + *remote_button_ctxt_recscreen + = button_context_recscreen_h100remote; static int _remote_type = 0; @@ -519,6 +555,7 @@ static void remap_remote(void) remote_btn_ctxt_bmark = NULL; remote_btn_ctxt_quickscreen = NULL; remote_btn_ctxt_pitchscreen = NULL; + remote_button_ctxt_recscreen = NULL; break; case REMOTETYPE_H100_LCD: @@ -538,7 +575,9 @@ static void remap_remote(void) remote_btn_ctxt_quickscreen = button_context_quickscreen_h100remote, remote_btn_ctxt_pitchscreen - = button_context_pitchscreen_h100remote; + = button_context_pitchscreen_h100remote, + remote_button_ctxt_recscreen + = button_context_recscreen_h100remote; break; case REMOTETYPE_H300_LCD: @@ -558,7 +597,9 @@ static void remap_remote(void) remote_btn_ctxt_quickscreen = button_context_quickscreen_h300lcdremote, remote_btn_ctxt_pitchscreen - = button_context_pitchscreen_h300lcdremote; + = button_context_pitchscreen_h300lcdremote, + remote_button_ctxt_recscreen + = button_context_recscreen_h300lcdremote; break; case REMOTETYPE_H300_NONLCD: /* FIXME: add its tables */ @@ -578,7 +619,9 @@ static void remap_remote(void) remote_btn_ctxt_quickscreen = button_context_quickscreen_h300lcdremote, remote_btn_ctxt_pitchscreen - = button_context_pitchscreen_h300lcdremote; + = button_context_pitchscreen_h300lcdremote, + remote_button_ctxt_recscreen + = button_context_recscreen_h300lcdremote; #if 0 remote_btn_ctxt_std = remote_btn_ctxt_wps = @@ -592,6 +635,7 @@ static void remap_remote(void) remote_btn_ctxt_bmark = remote_btn_ctxt_quickscreen = remote_btn_ctxt_pitchscreen = + remote_button_ctxt_recscreen = #endif break; @@ -641,6 +685,8 @@ const struct button_mapping* get_context_mapping_remote(int context) return remote_btn_ctxt_quickscreen; case CONTEXT_PITCHSCREEN: return remote_btn_ctxt_pitchscreen; + case CONTEXT_RECSCREEN: + return remote_button_ctxt_recscreen; } return remote_btn_ctxt_std; } @@ -683,6 +729,8 @@ const struct button_mapping* get_context_mapping(int context) return button_context_quickscreen; case CONTEXT_PITCHSCREEN: return button_context_pitchscreen; + case CONTEXT_RECSCREEN: + return button_context_recscreen; } return button_context_standard; } diff --git a/apps/keymaps/keymap-ondio.c b/apps/keymaps/keymap-ondio.c index 5476268065..57bdcc324a 100644 --- a/apps/keymaps/keymap-ondio.c +++ b/apps/keymaps/keymap-ondio.c @@ -127,6 +127,16 @@ const struct button_mapping button_context_pitchscreen[] = { LAST_ITEM_IN_LIST }; /* button_context_quickscreen */ +const struct button_mapping button_context_recscreen[] = { + { ACTION_REC_PAUSE, BUTTON_MENU|BUTTON_REL, BUTTON_MENU }, + { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_SETTINGS_INC, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_recscreen */ + const struct button_mapping* get_context_mapping( int context ) { switch( context ) @@ -153,6 +163,8 @@ const struct button_mapping* get_context_mapping( int context ) /* else fall through to CUSTOM|1 */ case CONTEXT_CUSTOM|1: return button_context_tree; + case CONTEXT_RECSCREEN: + return button_context_recscreen; case CONTEXT_LIST: case CONTEXT_MAINMENU: diff --git a/apps/keymaps/keymap-recorder.c b/apps/keymaps/keymap-recorder.c index 8cb6790fe7..72e04071a9 100644 --- a/apps/keymaps/keymap-recorder.c +++ b/apps/keymaps/keymap-recorder.c @@ -143,6 +143,18 @@ static const struct button_mapping button_context_pitchscreen[] = { LAST_ITEM_IN_LIST }; /* button_context_pitchcreen */ +const struct button_mapping button_context_recscreen[] = { + { ACTION_REC_PAUSE, BUTTON_PLAY, BUTTON_NONE }, + { ACTION_REC_F2, BUTTON_F2, BUTTON_NONE }, + { ACTION_REC_F3, BUTTON_F3, BUTTON_NONE }, + { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_SETTINGS_INC, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_recscreen */ + /***************************************************************************** * Remote control mappings *****************************************************************************/ @@ -212,6 +224,9 @@ const struct button_mapping* get_context_mapping( int context ) case CONTEXT_QUICKSCREEN: return button_context_quickscreen; + case CONTEXT_RECSCREEN: + return button_context_recscreen; + case CONTEXT_STD: case CONTEXT_LIST: case CONTEXT_MAINMENU: diff --git a/apps/keymaps/keymap-x5.c b/apps/keymaps/keymap-x5.c index b04932f02f..3752b35f9c 100644 --- a/apps/keymaps/keymap-x5.c +++ b/apps/keymaps/keymap-x5.c @@ -202,6 +202,19 @@ const struct button_mapping remote_button_context_wps[] = { LAST_ITEM_IN_LIST }; +const struct button_mapping button_context_recscreen[] = { + { ACTION_REC_PAUSE, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, + { ACTION_STD_CANCEL, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, + { ACTION_REC_NEWFILE, BUTTON_REC|BUTTON_REL, BUTTON_REC }, + { ACTION_STD_MENU, BUTTON_REC|BUTTON_REPEAT, BUTTON_REC }, + { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_SETTINGS_INC, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_recscreen */ + static const struct button_mapping* get_context_mapping_remote( int context ) { @@ -252,6 +265,8 @@ const struct button_mapping* get_context_mapping( int context ) return button_context_quickscreen; case CONTEXT_PITCHSCREEN: return button_context_pitchscreen; + case CONTEXT_RECSCREEN: + return button_context_recscreen; case CONTEXT_LIST: case CONTEXT_MAINMENU: default: diff --git a/apps/recorder/peakmeter.c b/apps/recorder/peakmeter.c index 39444fe787..0370f4deea 100644 --- a/apps/recorder/peakmeter.c +++ b/apps/recorder/peakmeter.c @@ -37,6 +37,7 @@ #ifdef CONFIG_BACKLIGHT #include "backlight.h" #endif +#include "action.h" #if CONFIG_CODEC == SWCODEC #include "pcm_playback.h" @@ -1222,7 +1223,7 @@ int peak_meter_draw_get_btn(int x, int y[], int height, int nb_screens) bool dopeek = true; while (TIME_BEFORE(current_tick, next_big_refresh)) { - button = button_get(false); + button = get_action(CONTEXT_RECSCREEN, TIMEOUT_NOBLOCK); if (button != BUTTON_NONE) { break; } diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index 0d4f12742f..e6b06d56dc 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c @@ -65,75 +65,9 @@ #include "ata.h" #include "splash.h" #include "screen_access.h" +#include "action.h" #ifdef HAVE_RECORDING - -#if CONFIG_KEYPAD == RECORDER_PAD -#define REC_SHUTDOWN (BUTTON_OFF | BUTTON_REPEAT) -#define REC_STOPEXIT BUTTON_OFF -#define REC_RECPAUSE BUTTON_PLAY -#define REC_INC BUTTON_RIGHT -#define REC_DEC BUTTON_LEFT -#define REC_NEXT BUTTON_DOWN -#define REC_PREV BUTTON_UP -#define REC_SETTINGS BUTTON_F1 -#define REC_F2 BUTTON_F2 -#define REC_F3 BUTTON_F3 - -#elif CONFIG_KEYPAD == ONDIO_PAD /* only limited features */ -#define REC_SHUTDOWN (BUTTON_OFF | BUTTON_REPEAT) -#define REC_STOPEXIT BUTTON_OFF -#define REC_RECPAUSE_PRE BUTTON_MENU -#define REC_RECPAUSE (BUTTON_MENU | BUTTON_REL) -#define REC_INC BUTTON_RIGHT -#define REC_DEC BUTTON_LEFT -#define REC_NEXT BUTTON_DOWN -#define REC_PREV BUTTON_UP -#define REC_SETTINGS (BUTTON_MENU | BUTTON_REPEAT) - -#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) -#define REC_SHUTDOWN (BUTTON_OFF | BUTTON_REPEAT) -#define REC_STOPEXIT BUTTON_OFF -#define REC_RECPAUSE BUTTON_ON -#define REC_NEWFILE BUTTON_REC -#define REC_INC BUTTON_RIGHT -#define REC_DEC BUTTON_LEFT -#define REC_NEXT BUTTON_DOWN -#define REC_PREV BUTTON_UP -#define REC_SETTINGS BUTTON_MODE - -#define REC_RC_SHUTDOWN (BUTTON_RC_STOP | BUTTON_REPEAT) -#define REC_RC_STOPEXIT BUTTON_RC_STOP -#define REC_RC_RECPAUSE BUTTON_RC_ON -#define REC_RC_NEWFILE BUTTON_RC_REC -#define REC_RC_INC BUTTON_RC_BITRATE -#define REC_RC_DEC BUTTON_RC_SOURCE -#define REC_RC_NEXT BUTTON_RC_FF -#define REC_RC_PREV BUTTON_RC_REW -#define REC_RC_SETTINGS BUTTON_RC_MODE -#define BUTTON_RC_DISPLAY BUTTON_RC_VOL_DOWN - -#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD) -#define REC_SHUTDOWN (BUTTON_POWER | BUTTON_REPEAT) -#define REC_STOPEXIT (BUTTON_PLAY | BUTTON_REPEAT) -#define REC_RECPAUSE_PRE BUTTON_PLAY -#define REC_RECPAUSE (BUTTON_PLAY | BUTTON_REL) -#define REC_INC BUTTON_RIGHT -#define REC_DEC BUTTON_LEFT -#define REC_NEXT BUTTON_DOWN -#define REC_PREV BUTTON_UP -#define REC_NEWFILE_PRE BUTTON_REC -#define REC_SETTINGS (BUTTON_REC | BUTTON_REPEAT) -#define REC_NEWFILE (BUTTON_REC | BUTTON_REL) - -#elif CONFIG_KEYPAD == GMINI100_PAD -#define REC_SHUTDOWN (BUTTON_OFF | BUTTON_REPEAT) -#define REC_STOPEXIT BUTTON_OFF -#define REC_RECPAUSE BUTTON_ON -#define REC_INC BUTTON_RIGHT -#define REC_DEC BUTTON_LEFT -#endif - #define PM_HEIGHT ((LCD_HEIGHT >= 72) ? 2 : 1) bool f2_rec_screen(void); @@ -830,8 +764,7 @@ bool recording_screen(void) switch(button) { -#ifdef BUTTON_RC_DISPLAY - case BUTTON_RC_DISPLAY: + case ACTION_REC_LCD: if (remote_display_on) { remote_display_on = false; @@ -849,15 +782,8 @@ bool recording_screen(void) screen_update = NB_SCREENS; } break; -#endif - case REC_STOPEXIT: - case REC_SHUTDOWN: -#ifdef REC_RC_STOPEXIT - case REC_RC_STOPEXIT: -#endif -#ifdef REC_RC_SHUTDOWN - case REC_RC_SHUTDOWN: -#endif + + case ACTION_STD_CANCEL: /* turn off the trigger */ peak_meter_trigger(false); peak_meter_set_trigger_listener(NULL); @@ -877,27 +803,8 @@ bool recording_screen(void) update_countdown = 1; /* Update immediately */ break; - case REC_RECPAUSE: -#ifdef REC_RC_RECPAUSE - case REC_RC_RECPAUSE: -#endif -#ifdef REC_RECPAUSE_PRE - if (lastbutton != REC_RECPAUSE_PRE) - break; -#endif -#ifdef REC_NEWFILE - case REC_NEWFILE: -#endif -#ifdef REC_RC_NEWFILE - case REC_RC_NEWFILE: -#endif -#ifdef REC_NEWFILE_PRE - if (button == REC_NEWFILE){ - if (lastbutton != REC_NEWFILE_PRE) - break; - } -#endif - + case ACTION_REC_PAUSE: + case ACTION_REC_NEWFILE: /* Only act if the mpeg is stopped */ if(!(audio_stat & AUDIO_STATUS_RECORD)) { @@ -928,19 +835,13 @@ bool recording_screen(void) } else { -#ifdef REC_NEWFILE /*if new file button pressed, start new file */ - if ((button == REC_NEWFILE) -#ifdef REC_RC_NEWFILE - || (button == REC_RC_NEWFILE) -#endif - ) + if (button == ACTION_REC_NEWFILE) { audio_new_file(rec_create_filename(path_buffer)); last_seconds = 0; } else -#endif /* if pause button pressed, pause or resume */ { if(audio_stat & AUDIO_STATUS_PAUSE) @@ -960,34 +861,19 @@ bool recording_screen(void) update_countdown = 1; /* Update immediately */ break; -#ifdef REC_PREV - case REC_PREV: -#ifdef REC_RC_PREV - case REC_RC_PREV: -#endif + case ACTION_STD_PREV: cursor--; adjust_cursor(); update_countdown = 1; /* Update immediately */ break; -#endif -#ifdef REC_NEXT - case REC_NEXT: -#ifdef REC_RC_NEXT - case REC_RC_NEXT: -#endif + case ACTION_STD_NEXT: cursor++; adjust_cursor(); update_countdown = 1; /* Update immediately */ break; -#endif - case REC_INC: - case REC_INC | BUTTON_REPEAT: -#ifdef REC_RC_INC - case REC_RC_INC: - case REC_RC_INC | BUTTON_REPEAT: -#endif + case ACTION_SETTINGS_INC: switch(cursor) { case 0: @@ -1055,12 +941,7 @@ bool recording_screen(void) update_countdown = 1; /* Update immediately */ break; - case REC_DEC: - case REC_DEC | BUTTON_REPEAT: -#ifdef REC_RC_DEC - case REC_RC_DEC: - case REC_RC_DEC | BUTTON_REPEAT: -#endif + case ACTION_SETTINGS_DEC: switch(cursor) { case 0: @@ -1128,11 +1009,7 @@ bool recording_screen(void) update_countdown = 1; /* Update immediately */ break; -#ifdef REC_SETTINGS - case REC_SETTINGS: -#ifdef REC_RC_SETTINGS - case REC_RC_SETTINGS: -#endif + case ACTION_STD_MENU: if(audio_stat != AUDIO_STATUS_RECORD) { #if CONFIG_LED == LED_REAL @@ -1178,10 +1055,8 @@ bool recording_screen(void) } } break; -#endif - -#ifdef REC_F2 - case REC_F2: +#if CONFIG_KEYPAD == RECORDER_PAD + case ACTION_REC_F2: if(audio_stat != AUDIO_STATUS_RECORD) { #if CONFIG_LED == LED_REAL @@ -1197,10 +1072,8 @@ bool recording_screen(void) update_countdown = 1; /* Update immediately */ } break; -#endif -#ifdef REC_F3 - case REC_F3: + case ACTION_REC_F3: if(audio_stat & AUDIO_STATUS_RECORD) { audio_new_file(rec_create_filename(path_buffer)); @@ -1653,8 +1526,7 @@ bool recording_screen(void) while(1) { - button = button_get(true); - if(button == (REC_STOPEXIT | BUTTON_REL)) + if (action_userabort(TIMEOUT_NOBLOCK)) break; } } @@ -1690,7 +1562,7 @@ bool recording_screen(void) return been_in_usb_mode; } -#ifdef REC_F2 +#if CONFIG_KEYPAD == RECORDER_PAD bool f2_rec_screen(void) { bool exit = false; @@ -1826,9 +1698,7 @@ bool f2_rec_screen(void) return false; } -#endif /* #ifdef REC_F2 */ -#ifdef REC_F3 bool f3_rec_screen(void) { bool exit = false; @@ -1931,7 +1801,7 @@ bool f3_rec_screen(void) return false; } -#endif /* #ifdef REC_F3 */ +#endif /* #ifdef RECORDER_PAD */ #if CONFIG_CODEC == SWCODEC void audio_beep(int duration)