From 0ba2204beb8f97ce71133bf74fdc24b40f81407c Mon Sep 17 00:00:00 2001 From: Martin Scarratt Date: Tue, 22 Aug 2006 13:21:13 +0000 Subject: [PATCH] Button action code for the Virtual keyboard. Extra buttons for H1xx remote: Vol-+ Cursor Left/Right. H3xx remote:-10/+10 Cursor Left/Right. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10694 a1c6a512-1295-4272-9138-f99709370657 --- apps/action.h | 18 ++- apps/keymaps/keymap-gigabeat.c | 25 ++++ apps/keymaps/keymap-h10.c | 17 +++ apps/keymaps/keymap-h1x0_h3x0.c | 119 +++++++++++++-- apps/keymaps/keymap-ifp7xx.c | 18 +++ apps/keymaps/keymap-ipod.c | 16 ++ apps/keymaps/keymap-ondio.c | 20 ++- apps/keymaps/keymap-recorder.c | 25 ++++ apps/keymaps/keymap-x5.c | 19 +++ apps/recorder/keyboard.c | 249 ++++---------------------------- 10 files changed, 292 insertions(+), 234 deletions(-) diff --git a/apps/action.h b/apps/action.h index df07606171..1bbe6fc6e8 100644 --- a/apps/action.h +++ b/apps/action.h @@ -68,6 +68,7 @@ enum { CONTEXT_YESNOSCREEN, /*NOTE: make sure your target has this and ACTION_YESNO_ACCEPT */ CONTEXT_RECSCREEN, + CONTEXT_KEYBOARD, }; @@ -177,7 +178,22 @@ enum { /* yesno screen */ ACTION_YESNO_ACCEPT, - + /* keyboard screen */ + ACTION_KBD_LEFT, + ACTION_KBD_RIGHT, + ACTION_KBD_CURSOR_LEFT, + ACTION_KBD_CURSOR_RIGHT, + ACTION_KBD_SELECT, + ACTION_KBD_SELECT_REM, + ACTION_KBD_PAGE_FLIP, + ACTION_KBD_DONE, + ACTION_KBD_ABORT, + ACTION_KBD_BACKSPACE, + ACTION_KBD_UP, + ACTION_KBD_DOWN, + ACTION_KBD_MORSE_INPUT, + ACTION_KBD_MORSE_SELECT, + }; struct button_mapping { diff --git a/apps/keymaps/keymap-gigabeat.c b/apps/keymaps/keymap-gigabeat.c index 9a987d2bfc..042a1f7d8b 100644 --- a/apps/keymaps/keymap-gigabeat.c +++ b/apps/keymaps/keymap-gigabeat.c @@ -220,6 +220,29 @@ const struct button_mapping button_context_pitchscreen[] = { LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* button_context_pitchcreen */ +const struct button_mapping button_context_keyboard[] = { + { ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_POWER|BUTTON_LEFT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_POWER|BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_POWER|BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_POWER|BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_SELECT, BUTTON_SELECT, BUTTON_NONE }, + { ACTION_KBD_PAGE_FLIP, BUTTON_POWER|BUTTON_MENU, BUTTON_NONE }, + { ACTION_KBD_DONE, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, + { ACTION_KBD_ABORT, BUTTON_A, BUTTON_NONE }, + { ACTION_KBD_BACKSPACE, BUTTON_MENU, BUTTON_NONE }, + { ACTION_KBD_BACKSPACE, BUTTON_MENU|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_keyboard */ + const struct button_mapping* get_context_mapping(int context) { switch (context) @@ -261,6 +284,8 @@ const struct button_mapping* get_context_mapping(int context) return button_context_quickscreen; case CONTEXT_PITCHSCREEN: return button_context_pitchscreen; + case CONTEXT_KEYBOARD: + return button_context_keyboard; } return button_context_standard; } diff --git a/apps/keymaps/keymap-h10.c b/apps/keymaps/keymap-h10.c index 25ee13022f..c6b6229f61 100644 --- a/apps/keymaps/keymap-h10.c +++ b/apps/keymaps/keymap-h10.c @@ -152,7 +152,21 @@ const struct button_mapping button_context_pitchscreen[] = { LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD), }; /* button_context_pitchscreen */ +const struct button_mapping button_context_keyboard[] = { + { ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_SELECT, BUTTON_REW|BUTTON_REL, BUTTON_REW }, + { ACTION_KBD_DONE, BUTTON_PLAY, BUTTON_NONE }, + { ACTION_KBD_ABORT, BUTTON_FF, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_SCROLL_UP, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_SCROLL_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_SCROLL_DOWN, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_SCROLL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + LAST_ITEM_IN_LIST +}; /* button_context_keyboard */ /* get_context_mapping returns a pointer to one of the above defined arrays depending on the context */ const struct button_mapping* get_context_mapping(int context) @@ -186,6 +200,9 @@ const struct button_mapping* get_context_mapping(int context) return button_context_quickscreen; case CONTEXT_PITCHSCREEN: return button_context_pitchscreen; + case CONTEXT_KEYBOARD: + return button_context_keyboard; + case CONTEXT_LIST: case CONTEXT_MAINMENU: default: diff --git a/apps/keymaps/keymap-h1x0_h3x0.c b/apps/keymaps/keymap-h1x0_h3x0.c index 9eebdf25c1..476e307ffd 100644 --- a/apps/keymaps/keymap-h1x0_h3x0.c +++ b/apps/keymaps/keymap-h1x0_h3x0.c @@ -232,6 +232,31 @@ const struct button_mapping button_context_recscreen[] = { LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* button_context_recscreen */ +const struct button_mapping button_context_keyboard[] = { + { ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_ON|BUTTON_LEFT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_ON|BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_ON|BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_ON|BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_SELECT, BUTTON_SELECT, BUTTON_NONE }, + { ACTION_KBD_PAGE_FLIP, BUTTON_MODE, BUTTON_NONE }, + { ACTION_KBD_DONE, BUTTON_ON|BUTTON_REL, BUTTON_ON }, + { ACTION_KBD_ABORT, BUTTON_OFF, BUTTON_NONE }, + { ACTION_KBD_BACKSPACE, BUTTON_REC, BUTTON_NONE }, + { ACTION_KBD_BACKSPACE, BUTTON_REC|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_MORSE_INPUT, BUTTON_ON|BUTTON_MODE, BUTTON_NONE }, + { ACTION_KBD_MORSE_SELECT, BUTTON_SELECT|BUTTON_REL, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_keyboard */ + /***************************************************************************** * Remote control mappings *****************************************************************************/ @@ -536,6 +561,64 @@ const struct button_mapping button_context_recscreen_h300lcdremote[] = { LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* button_context_recscreen_h300lcdremote */ +const struct button_mapping button_context_keyboard_h100remote[] = { + { ACTION_KBD_LEFT, BUTTON_RC_REW, BUTTON_NONE }, + { ACTION_KBD_LEFT, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RC_FF, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_RC_ON|BUTTON_RC_REW, BUTTON_NONE }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_RC_ON|BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_RC_ON|BUTTON_RC_FF, BUTTON_NONE }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_RC_ON|BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_RC_VOL_DOWN, BUTTON_NONE }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_RC_VOL_UP, BUTTON_NONE }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_SELECT_REM, BUTTON_RC_MENU, BUTTON_NONE }, + { ACTION_KBD_PAGE_FLIP, BUTTON_RC_MODE, BUTTON_NONE }, + { ACTION_KBD_DONE, BUTTON_RC_ON|BUTTON_REL, BUTTON_RC_ON }, + { ACTION_KBD_ABORT, BUTTON_RC_STOP, BUTTON_NONE }, + { ACTION_KBD_BACKSPACE, BUTTON_RC_REC, BUTTON_NONE }, + { ACTION_KBD_BACKSPACE, BUTTON_RC_REC|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_RC_SOURCE, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_RC_SOURCE|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_RC_BITRATE, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_RC_BITRATE|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_MORSE_INPUT, BUTTON_RC_ON|BUTTON_RC_MODE, BUTTON_NONE }, + { ACTION_KBD_MORSE_SELECT, BUTTON_RC_MENU|BUTTON_REL, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_keyboard_h100remote */ + +const struct button_mapping button_context_keyboard_h300lcdremote[] = { + { ACTION_KBD_LEFT, BUTTON_RC_REW, BUTTON_NONE }, + { ACTION_KBD_LEFT, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RC_FF, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_RC_MENU|BUTTON_RC_REW, BUTTON_NONE }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_RC_MENU|BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_RC_MENU|BUTTON_RC_FF, BUTTON_NONE }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_RC_MENU|BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_RC_SOURCE, BUTTON_NONE }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_RC_SOURCE|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_RC_BITRATE, BUTTON_NONE }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_RC_BITRATE|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_SELECT_REM, BUTTON_RC_MENU, BUTTON_NONE }, + { ACTION_KBD_PAGE_FLIP, BUTTON_RC_MODE, BUTTON_NONE }, + { ACTION_KBD_DONE, BUTTON_RC_ON|BUTTON_REL, BUTTON_RC_ON }, + { ACTION_KBD_ABORT, BUTTON_RC_STOP, BUTTON_NONE }, + { ACTION_KBD_BACKSPACE, BUTTON_RC_REC, BUTTON_NONE }, + { ACTION_KBD_BACKSPACE, BUTTON_RC_REC|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_RC_VOL_UP, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_RC_VOL_DOWN, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_MORSE_INPUT, BUTTON_RC_ON|BUTTON_RC_MODE, BUTTON_NONE }, + { ACTION_KBD_MORSE_SELECT, BUTTON_RC_MENU|BUTTON_REL, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_keyboard_h300lcdremote */ + /* the actual used tables */ static const struct button_mapping @@ -556,8 +639,10 @@ static const struct button_mapping = button_context_quickscreen_h100remote, *remote_btn_ctxt_pitchscreen = button_context_pitchscreen_h100remote, - *remote_button_ctxt_recscreen - = button_context_recscreen_h100remote; + *remote_btn_ctxt_recscreen + = button_context_recscreen_h100remote, + *remote_btn_ctxt_keyboard + = button_context_keyboard_h100remote; static int _remote_type = 0; @@ -579,7 +664,8 @@ 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; + remote_btn_ctxt_recscreen = NULL; + remote_btn_ctxt_keyboard = NULL; break; case REMOTETYPE_H100_LCD: @@ -600,8 +686,10 @@ static void remap_remote(void) = button_context_quickscreen_h100remote, remote_btn_ctxt_pitchscreen = button_context_pitchscreen_h100remote, - remote_button_ctxt_recscreen - = button_context_recscreen_h100remote; + remote_btn_ctxt_recscreen + = button_context_recscreen_h100remote, + remote_btn_ctxt_keyboard + = button_context_keyboard_h100remote; break; case REMOTETYPE_H300_LCD: @@ -622,8 +710,10 @@ static void remap_remote(void) = button_context_quickscreen_h300lcdremote, remote_btn_ctxt_pitchscreen = button_context_pitchscreen_h300lcdremote, - remote_button_ctxt_recscreen - = button_context_recscreen_h300lcdremote; + remote_btn_ctxt_recscreen + = button_context_recscreen_h300lcdremote, + remote_btn_ctxt_keyboard + = button_context_keyboard_h300lcdremote; break; case REMOTETYPE_H300_NONLCD: /* FIXME: add its tables */ @@ -644,8 +734,10 @@ static void remap_remote(void) = button_context_quickscreen_h300lcdremote, remote_btn_ctxt_pitchscreen = button_context_pitchscreen_h300lcdremote, - remote_button_ctxt_recscreen - = button_context_recscreen_h300lcdremote; + remote_btn_ctxt_recscreen + = button_context_recscreen_h300lcdremote, + remote_btn_ctxt_keyboard + = button_context_keyboard_h300lcdremote; #if 0 remote_btn_ctxt_std = remote_btn_ctxt_wps = @@ -659,7 +751,8 @@ static void remap_remote(void) remote_btn_ctxt_bmark = remote_btn_ctxt_quickscreen = remote_btn_ctxt_pitchscreen = - remote_button_ctxt_recscreen = + remote_btn_ctxt_recscreen = + remote_btn_ctxt_keyboard = #endif break; @@ -707,7 +800,9 @@ const struct button_mapping* get_context_mapping_remote(int context) case CONTEXT_PITCHSCREEN: return remote_btn_ctxt_pitchscreen; case CONTEXT_RECSCREEN: - return remote_button_ctxt_recscreen; + return remote_btn_ctxt_recscreen; + case CONTEXT_KEYBOARD: + return remote_btn_ctxt_keyboard; } return remote_btn_ctxt_std; } @@ -758,6 +853,8 @@ const struct button_mapping* get_context_mapping(int context) return button_context_pitchscreen; case CONTEXT_RECSCREEN: return button_context_recscreen; + case CONTEXT_KEYBOARD: + return button_context_keyboard; } return button_context_standard; } diff --git a/apps/keymaps/keymap-ifp7xx.c b/apps/keymaps/keymap-ifp7xx.c index 5ffa71593c..b5d0fd7df0 100644 --- a/apps/keymaps/keymap-ifp7xx.c +++ b/apps/keymaps/keymap-ifp7xx.c @@ -134,6 +134,22 @@ const struct button_mapping button_context_pitchscreen[] = { LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* button_context_pitchcreen */ +const struct button_mapping button_context_keyboard[] = { + { ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_SELECT, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, + { ACTION_KBD_DONE, BUTTON_MODE, BUTTON_NONE }, + { ACTION_KBD_ABORT, BUTTON_PLAY, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_keyboard */ + /* get_context_mapping returns a pointer to one of the above defined arrays depending on the context */ const struct button_mapping* get_context_mapping(int context) { @@ -158,6 +174,8 @@ const struct button_mapping* get_context_mapping(int context) return button_context_quickscreen; case CONTEXT_PITCHSCREEN: return button_context_pitchscreen; + case CONTEXT_KEYBOARD: + return button_context_keyboard; } return button_context_standard; } diff --git a/apps/keymaps/keymap-ipod.c b/apps/keymaps/keymap-ipod.c index 895691d5bc..b41a91afdf 100644 --- a/apps/keymaps/keymap-ipod.c +++ b/apps/keymaps/keymap-ipod.c @@ -146,6 +146,20 @@ const struct button_mapping button_context_pitchscreen[] = { LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* button_context_pitchscreen */ +const struct button_mapping button_context_keyboard[] = { + { ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_SELECT, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, + { ACTION_KBD_DONE, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_ABORT, BUTTON_MENU, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_SCROLL_BACK, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_SCROLL_FWD, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_keyboard */ + /* get_context_mapping returns a pointer to one of the above defined arrays depending on the context */ const struct button_mapping* get_context_mapping(int context) { @@ -180,6 +194,8 @@ const struct button_mapping* get_context_mapping(int context) return button_context_quickscreen; case CONTEXT_PITCHSCREEN: return button_context_pitchscreen; + case CONTEXT_KEYBOARD: + return button_context_keyboard; default: return button_context_standard; } diff --git a/apps/keymaps/keymap-ondio.c b/apps/keymaps/keymap-ondio.c index 1a1411093e..9af3b12cab 100644 --- a/apps/keymaps/keymap-ondio.c +++ b/apps/keymaps/keymap-ondio.c @@ -137,6 +137,22 @@ const struct button_mapping button_context_recscreen[] = { LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* button_context_recscreen */ +const struct button_mapping button_context_keyboard[] = { + { ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_SELECT, BUTTON_MENU|BUTTON_REL, BUTTON_MENU }, + { ACTION_KBD_DONE, BUTTON_MENU|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_ABORT, BUTTON_OFF, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_keyboard */ + const struct button_mapping* get_context_mapping( int context ) { switch( context ) @@ -165,7 +181,9 @@ const struct button_mapping* get_context_mapping( int context ) return button_context_tree; case CONTEXT_RECSCREEN: return button_context_recscreen; - + case CONTEXT_KEYBOARD: + return button_context_keyboard; + case CONTEXT_LIST: case CONTEXT_MAINMENU: default: diff --git a/apps/keymaps/keymap-recorder.c b/apps/keymaps/keymap-recorder.c index 01a6a0df11..4fb278db6e 100644 --- a/apps/keymaps/keymap-recorder.c +++ b/apps/keymaps/keymap-recorder.c @@ -161,6 +161,29 @@ const struct button_mapping button_context_recscreen[] = { LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* button_context_recscreen */ +const struct button_mapping button_context_keyboard[] = { + { ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_ON|BUTTON_LEFT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_ON|BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_ON|BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_ON|BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_SELECT, BUTTON_PLAY, BUTTON_NONE }, + { ACTION_KBD_PAGE_FLIP, BUTTON_F1, BUTTON_NONE }, + { ACTION_KBD_DONE, BUTTON_F2, BUTTON_NONE }, + { ACTION_KBD_ABORT, BUTTON_OFF, BUTTON_NONE }, + { ACTION_KBD_BACKSPACE, BUTTON_F3, BUTTON_NONE }, + { ACTION_KBD_BACKSPACE, BUTTON_F3|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_keyboard */ + /***************************************************************************** * Remote control mappings *****************************************************************************/ @@ -232,6 +255,8 @@ const struct button_mapping* get_context_mapping( int context ) case CONTEXT_RECSCREEN: return button_context_recscreen; + case CONTEXT_KEYBOARD: + return button_context_keyboard; case CONTEXT_STD: case CONTEXT_LIST: diff --git a/apps/keymaps/keymap-x5.c b/apps/keymaps/keymap-x5.c index cb5de5b0f2..603f9c7568 100644 --- a/apps/keymaps/keymap-x5.c +++ b/apps/keymaps/keymap-x5.c @@ -216,6 +216,22 @@ const struct button_mapping button_context_recscreen[] = { LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* button_context_recscreen */ +const struct button_mapping button_context_keyboard[] = { + { ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_SELECT, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, + { ACTION_KBD_DONE, BUTTON_PLAY, BUTTON_NONE }, + { ACTION_KBD_ABORT, BUTTON_REC, BUTTON_NONE }, + + + LAST_ITEM_IN_LIST +}; /* button_context_keyboard */ static const struct button_mapping* get_context_mapping_remote( int context ) { @@ -271,6 +287,9 @@ const struct button_mapping* get_context_mapping( int context ) return button_context_pitchscreen; case CONTEXT_RECSCREEN: return button_context_recscreen; + case CONTEXT_KEYBOARD: + return button_context_keyboard; + case CONTEXT_LIST: case CONTEXT_MAINMENU: default: diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c index 8f35b12d4b..8e82ab58f9 100644 --- a/apps/recorder/keyboard.c +++ b/apps/recorder/keyboard.c @@ -36,6 +36,7 @@ #include "icons.h" #include "file.h" #include "hangul.h" +#include "action.h" #ifndef O_BINARY #define O_BINARY 0 @@ -52,143 +53,22 @@ #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ (CONFIG_KEYPAD == IRIVER_H300_PAD) -#define KBD_CURSOR_RIGHT (BUTTON_ON | BUTTON_RIGHT) -#define KBD_CURSOR_LEFT (BUTTON_ON | BUTTON_LEFT) -#define KBD_SELECT BUTTON_SELECT -#define KBD_PAGE_FLIP BUTTON_MODE /* unused */ -#define KBD_DONE_PRE BUTTON_ON -#define KBD_DONE (BUTTON_ON | BUTTON_REL) -#define KBD_ABORT BUTTON_OFF -#define KBD_BACKSPACE BUTTON_REC -#define KBD_LEFT BUTTON_LEFT -#define KBD_RIGHT BUTTON_RIGHT -#define KBD_UP BUTTON_UP -#define KBD_DOWN BUTTON_DOWN -#define KBD_MORSE_INPUT (BUTTON_ON | BUTTON_MODE) -#define KBD_RC_CURSOR_RIGHT (BUTTON_RC_ON | BUTTON_RC_FF) -#define KBD_RC_CURSOR_LEFT (BUTTON_RC_ON | BUTTON_RC_REW) -#define KBD_RC_SELECT BUTTON_RC_MENU -#define KBD_RC_PAGE_FLIP BUTTON_RC_MODE -#define KBD_RC_DONE_PRE BUTTON_RC_ON -#define KBD_RC_DONE (BUTTON_RC_ON | BUTTON_REL) -#define KBD_RC_ABORT BUTTON_RC_STOP -#define KBD_RC_BACKSPACE BUTTON_RC_REC -#define KBD_RC_LEFT BUTTON_RC_REW -#define KBD_RC_RIGHT BUTTON_RC_FF -#define KBD_RC_UP BUTTON_RC_SOURCE -#define KBD_RC_DOWN BUTTON_RC_BITRATE -#define KBD_RC_MORSE_INPUT (BUTTON_RC_ON | BUTTON_RC_MODE) - -#elif CONFIG_KEYPAD == RECORDER_PAD -#define KBD_CURSOR_RIGHT (BUTTON_ON | BUTTON_RIGHT) -#define KBD_CURSOR_LEFT (BUTTON_ON | BUTTON_LEFT) -#define KBD_SELECT BUTTON_PLAY -#define KBD_PAGE_FLIP BUTTON_F1 -#define KBD_DONE BUTTON_F2 -#define KBD_ABORT BUTTON_OFF -#define KBD_BACKSPACE BUTTON_F3 -#define KBD_LEFT BUTTON_LEFT -#define KBD_RIGHT BUTTON_RIGHT -#define KBD_UP BUTTON_UP -#define KBD_DOWN BUTTON_DOWN +#define KBD_MORSE_INPUT /* I-Rivers have a Morse input mode */ #elif CONFIG_KEYPAD == ONDIO_PAD /* restricted Ondio keypad */ #define KBD_MODES /* Ondio uses 2 modes, picker and line edit */ -#define KBD_SELECT (BUTTON_MENU | BUTTON_REL) /* backspace in line edit */ -#define KBD_SELECT_PRE BUTTON_MENU -#define KBD_DONE_PRE BUTTON_MENU -#define KBD_DONE (BUTTON_MENU | BUTTON_REPEAT) -#define KBD_ABORT BUTTON_OFF -#define KBD_LEFT BUTTON_LEFT -#define KBD_RIGHT BUTTON_RIGHT -#define KBD_UP BUTTON_UP -#define KBD_DOWN BUTTON_DOWN - -#elif CONFIG_KEYPAD == GMINI100_PAD -#define KBD_CURSOR_RIGHT (BUTTON_MENU | BUTTON_RIGHT) -#define KBD_CURSOR_LEFT (BUTTON_MENU | BUTTON_LEFT) -#define KBD_SELECT (BUTTON_PLAY | BUTTON_REL) -#define KBD_SELECT_PRE BUTTON_PLAY -#define KBD_PAGE_FLIP BUTTON_ON -#define KBD_DONE_PRE BUTTON_PLAY -#define KBD_DONE (BUTTON_PLAY | BUTTON_REPEAT) -#define KBD_ABORT BUTTON_OFF -#define KBD_BACKSPACE (BUTTON_MENU | BUTTON_PLAY) -#define KBD_LEFT BUTTON_LEFT -#define KBD_RIGHT BUTTON_RIGHT -#define KBD_UP BUTTON_UP -#define KBD_DOWN BUTTON_DOWN #elif (CONFIG_KEYPAD == IPOD_3G_PAD) || (CONFIG_KEYPAD == IPOD_4G_PAD) - #define KBD_MODES /* iPod uses 2 modes, picker and line edit */ -#define KBD_SELECT (BUTTON_SELECT | BUTTON_REL) /* backspace in line edit */ -#define KBD_SELECT_PRE BUTTON_SELECT -#define KBD_DONE_PRE BUTTON_SELECT -#define KBD_DONE (BUTTON_SELECT | BUTTON_REPEAT) -#define KBD_ABORT BUTTON_MENU -#define KBD_LEFT BUTTON_LEFT -#define KBD_RIGHT BUTTON_RIGHT -#define KBD_UP BUTTON_SCROLL_BACK -#define KBD_DOWN BUTTON_SCROLL_FWD #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD - -/* TODO: Check keyboard mappings */ - #define KBD_MODES /* iFP7xx uses 2 modes, picker and line edit */ -#define KBD_SELECT (BUTTON_SELECT | BUTTON_REL) /* backspace in line edit */ -#define KBD_SELECT_PRE BUTTON_SELECT -#define KBD_DONE BUTTON_MODE -#define KBD_ABORT BUTTON_PLAY -#define KBD_LEFT BUTTON_LEFT -#define KBD_RIGHT BUTTON_RIGHT -#define KBD_UP BUTTON_UP -#define KBD_DOWN BUTTON_DOWN #elif CONFIG_KEYPAD == IAUDIO_X5_PAD - -/* TODO: Check keyboard mappings */ - #define KBD_MODES /* iAudio X5 uses 2 modes, picker and line edit */ -#define KBD_SELECT (BUTTON_SELECT | BUTTON_REL) /* backspace in line edit */ -#define KBD_SELECT_PRE BUTTON_SELECT -#define KBD_DONE BUTTON_PLAY -#define KBD_ABORT BUTTON_REC -#define KBD_LEFT BUTTON_LEFT -#define KBD_RIGHT BUTTON_RIGHT -#define KBD_UP BUTTON_UP -#define KBD_DOWN BUTTON_DOWN - -#elif CONFIG_KEYPAD == GIGABEAT_PAD - -#define KBD_CURSOR_RIGHT (BUTTON_POWER | BUTTON_RIGHT) -#define KBD_CURSOR_LEFT (BUTTON_POWER | BUTTON_LEFT) -#define KBD_SELECT BUTTON_SELECT -#define KBD_PAGE_FLIP (BUTTON_POWER | BUTTON_MENU) -#define KBD_DONE_PRE BUTTON_POWER -#define KBD_DONE (BUTTON_POWER | BUTTON_REL) -#define KBD_ABORT BUTTON_A -#define KBD_BACKSPACE BUTTON_MENU -#define KBD_LEFT BUTTON_LEFT -#define KBD_RIGHT BUTTON_RIGHT -#define KBD_UP BUTTON_UP -#define KBD_DOWN BUTTON_DOWN #elif CONFIG_KEYPAD == IRIVER_H10_PAD - -/* TODO: Check keyboard mappings */ - #define KBD_MODES /* iriver H10 uses 2 modes, picker and line edit */ -#define KBD_SELECT (BUTTON_REW | BUTTON_REL) /* backspace in line edit */ -#define KBD_SELECT_PRE BUTTON_REW -#define KBD_DONE BUTTON_PLAY -#define KBD_ABORT BUTTON_FF -#define KBD_LEFT BUTTON_LEFT -#define KBD_RIGHT BUTTON_RIGHT -#define KBD_UP BUTTON_SCROLL_UP -#define KBD_DOWN BUTTON_SCROLL_DOWN - #endif struct keyboard_parameters { @@ -694,30 +574,21 @@ int kbd_input(char* text, int buflen) FOR_NB_SCREENS(l) screens[l].update(); - button = button_get_w_tmo(HZ/2); + button = get_action(CONTEXT_KEYBOARD,HZ/2); #ifdef KBD_MORSE_INPUT if (morse_mode) { /* Remap some buttons for morse mode. */ - if (button == KBD_LEFT || button == (KBD_LEFT | BUTTON_REPEAT)) - button = KBD_CURSOR_LEFT; - if (button == KBD_RIGHT || button == (KBD_RIGHT | BUTTON_REPEAT)) - button = KBD_CURSOR_RIGHT; -#ifdef KBD_RC_LEFT - if (button == KBD_RC_LEFT || button == (KBD_RC_LEFT | BUTTON_REPEAT)) - button = KBD_RC_CURSOR_LEFT; - if (button == KBD_RC_RIGHT || button == (KBD_RC_RIGHT | BUTTON_REPEAT)) - button = KBD_RC_CURSOR_RIGHT; + if (button == ACTION_KBD_LEFT) + button = ACTION_KBD_CURSOR_LEFT; + if (button == ACTION_KBD_RIGHT) + button = ACTION_KBD_CURSOR_RIGHT; } -#endif #endif switch ( button ) { -#ifdef KBD_RC_ABORT - case KBD_RC_ABORT: -#endif - case KBD_ABORT: + case ACTION_KBD_ABORT: FOR_NB_SCREENS(l) screens[l].setfont(FONT_UI); @@ -727,11 +598,7 @@ int kbd_input(char* text, int buflen) return -1; break; -#if defined(KBD_PAGE_FLIP) - case KBD_PAGE_FLIP: -#ifdef KBD_RC_PAGE_FLIP - case KBD_RC_PAGE_FLIP: -#endif + case ACTION_KBD_PAGE_FLIP: #ifdef KBD_MORSE_INPUT if (morse_mode) break; @@ -745,13 +612,10 @@ int kbd_input(char* text, int buflen) kbd_spellchar(param[l].kbd_buf[k]); } break; -#endif #ifdef KBD_MORSE_INPUT - case KBD_MORSE_INPUT: -#ifdef KBD_RC_MORSE_INPUT - case KBD_RC_MORSE_INPUT: -#endif + case ACTION_KBD_MORSE_INPUT: + morse_mode = !morse_mode; FOR_NB_SCREENS(l) { @@ -765,12 +629,8 @@ int kbd_input(char* text, int buflen) /* FIXME: We should talk something like Morse mode.. */ break; #endif -#ifdef KBD_RC_RIGHT - case KBD_RC_RIGHT: - case KBD_RC_RIGHT | BUTTON_REPEAT: -#endif - case KBD_RIGHT: - case KBD_RIGHT | BUTTON_REPEAT: + + case ACTION_KBD_RIGHT: #ifdef KBD_MORSE_INPUT if (morse_mode) break; @@ -806,12 +666,8 @@ int kbd_input(char* text, int buflen) } } break; -#ifdef KBD_RC_LEFT - case KBD_RC_LEFT: - case KBD_RC_LEFT | BUTTON_REPEAT: -#endif - case KBD_LEFT: - case KBD_LEFT | BUTTON_REPEAT: + + case ACTION_KBD_LEFT: #ifdef KBD_MORSE_INPUT if (morse_mode) break; @@ -852,12 +708,7 @@ int kbd_input(char* text, int buflen) } break; -#ifdef KBD_RC_DOWN - case KBD_RC_DOWN: - case KBD_RC_DOWN | BUTTON_REPEAT: -#endif - case KBD_DOWN: - case KBD_DOWN | BUTTON_REPEAT: + case ACTION_KBD_DOWN: #ifdef KBD_MORSE_INPUT if (morse_mode) break; @@ -895,12 +746,7 @@ int kbd_input(char* text, int buflen) } break; -#ifdef KBD_RC_UP - case KBD_RC_UP: - case KBD_RC_UP | BUTTON_REPEAT: -#endif - case KBD_UP: - case KBD_UP | BUTTON_REPEAT: + case ACTION_KBD_UP: #ifdef KBD_MORSE_INPUT if (morse_mode) break; @@ -938,27 +784,13 @@ int kbd_input(char* text, int buflen) } break; -#ifdef KBD_RC_DONE - case KBD_RC_DONE: -#endif - case KBD_DONE: + case ACTION_KBD_DONE: /* accepts what was entered and continues */ -#ifdef KBD_DONE_PRE - if ((lastbutton != KBD_DONE_PRE) -#ifdef KBD_RC_DONE_PRE - && (lastbutton != KBD_RC_DONE_PRE) -#endif - ) - break; -#endif done = true; break; #ifdef KBD_MORSE_INPUT -#ifdef KBD_RC_SELECT - case KBD_RC_SELECT | BUTTON_REL: -#endif - case KBD_SELECT | BUTTON_REL: + case ACTION_KBD_MORSE_SELECT: if (morse_mode && morse_reading) { morse_code <<= 1; @@ -969,15 +801,11 @@ int kbd_input(char* text, int buflen) break; #endif -#ifdef KBD_RC_SELECT - case KBD_RC_SELECT: - - if (button == KBD_RC_SELECT) + case ACTION_KBD_SELECT: + case ACTION_KBD_SELECT_REM: + if (button == ACTION_KBD_SELECT_REM) char_screen = 1; -#endif - case KBD_SELECT: - - if (button == KBD_SELECT) + else char_screen = 0; #ifdef KBD_MORSE_INPUT if (morse_mode) @@ -993,14 +821,6 @@ int kbd_input(char* text, int buflen) #endif /* inserts the selected char */ -#ifdef KBD_SELECT_PRE - if ((lastbutton != KBD_SELECT_PRE) -#ifdef KBD_RC_SELECT_PRE - && (lastbutton != KBD_RC_SELECT_PRE) -#endif - ) - break; -#endif #ifdef KBD_MODES if (line_edit) { /* select doubles as backspace in line_edit */ if (hangul) { @@ -1088,12 +908,7 @@ int kbd_input(char* text, int buflen) break; #ifndef KBD_MODES -#ifdef KBD_RC_BACKSPACE - case KBD_RC_BACKSPACE: - case KBD_RC_BACKSPACE | BUTTON_REPEAT: -#endif - case KBD_BACKSPACE: - case KBD_BACKSPACE | BUTTON_REPEAT: + case ACTION_KBD_BACKSPACE: if (hangul) { if (htail) @@ -1116,12 +931,8 @@ int kbd_input(char* text, int buflen) talk_spell(text, false); /* speak revised text */ break; -#ifdef KBD_RC_CURSOR_RIGHT - case KBD_RC_CURSOR_RIGHT: - case KBD_RC_CURSOR_RIGHT | BUTTON_REPEAT: -#endif - case KBD_CURSOR_RIGHT: - case KBD_CURSOR_RIGHT | BUTTON_REPEAT: + case ACTION_KBD_CURSOR_RIGHT: + if (hangul) hangul = false; @@ -1133,12 +944,8 @@ int kbd_input(char* text, int buflen) } break; -#ifdef KBD_RC_CURSOR_LEFT - case KBD_RC_CURSOR_LEFT: - case KBD_RC_CURSOR_LEFT | BUTTON_REPEAT: -#endif - case KBD_CURSOR_LEFT: - case KBD_CURSOR_LEFT | BUTTON_REPEAT: + case ACTION_KBD_CURSOR_LEFT: + if (hangul) hangul = false; if (editpos)