Unify the way functions are called from menus.
[Rockbox.git] / apps / keymaps / keymap-player.c
blob80cdedfc3c0da386b464d83e902915be479f3b8f
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2006 Jonathan Gordon
11 * All files in this archive are subject to the GNU General Public License.
12 * See the file COPYING in the source tree root for full license agreement.
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
17 ****************************************************************************/
19 /* *
20 * Button Code Definitions for archos player targets
24 #include "config.h"
25 #include "action.h"
26 #include "button.h"
28 static const struct button_mapping button_context_standard[] = {
29 { ACTION_STD_PREV, BUTTON_LEFT, BUTTON_NONE },
30 { ACTION_STD_PREVREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
31 { ACTION_STD_NEXT, BUTTON_RIGHT, BUTTON_NONE },
32 { ACTION_STD_NEXTREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
34 { ACTION_STD_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
35 { ACTION_STD_CANCEL, BUTTON_STOP, BUTTON_NONE },
36 { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
37 { ACTION_STD_MENU, BUTTON_MENU, BUTTON_NONE },
39 LAST_ITEM_IN_LIST
42 static const struct button_mapping button_context_wps[] = {
43 { ACTION_WPS_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
44 { ACTION_WPS_SKIPNEXT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
45 { ACTION_WPS_SKIPPREV, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT },
46 { ACTION_WPS_SEEKBACK, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
47 { ACTION_WPS_SEEKFWD, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
48 { ACTION_WPS_STOPSEEK, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT|BUTTON_REPEAT },
49 { ACTION_WPS_STOPSEEK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT },
50 { ACTION_WPS_STOP, BUTTON_STOP, BUTTON_NONE },
52 { ACTION_WPS_VOLDOWN, BUTTON_MENU|BUTTON_LEFT, BUTTON_MENU },
53 { ACTION_WPS_VOLDOWN, BUTTON_MENU|BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
54 { ACTION_WPS_VOLUP, BUTTON_MENU|BUTTON_RIGHT, BUTTON_MENU },
55 { ACTION_WPS_VOLUP, BUTTON_MENU|BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
57 { ACTION_WPS_BROWSE, BUTTON_ON|BUTTON_REL, BUTTON_ON },
58 { ACTION_WPS_MENU, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
59 { ACTION_WPS_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
60 { ACTION_WPS_ID3SCREEN, BUTTON_MENU|BUTTON_ON, BUTTON_NONE },
61 { ACTION_STD_KEYLOCK, BUTTON_MENU|BUTTON_STOP, BUTTON_NONE },
63 LAST_ITEM_IN_LIST
66 static const struct button_mapping button_context_settings[] = {
67 { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE },
68 { ACTION_SETTINGS_INCREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
69 { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE },
70 { ACTION_SETTINGS_DECREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
72 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
75 static const struct button_mapping button_context_tree[] = {
76 { ACTION_TREE_WPS, BUTTON_ON, BUTTON_NONE },
78 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
79 }; /* button_context_listtree */
81 static const struct button_mapping button_context_menu[] = {
82 { ACTION_MENU_WPS, BUTTON_ON, BUTTON_NONE },
84 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
85 }; /* button_context_menu */
87 static const struct button_mapping button_context_yesno[] = {
88 { ACTION_YESNO_ACCEPT, BUTTON_PLAY, BUTTON_NONE },
90 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
91 }; /* button_context_settings_yesno */
93 static const struct button_mapping button_context_bmark[] = {
94 { ACTION_BMS_DELETE, BUTTON_PLAY|BUTTON_ON, BUTTON_PLAY },
95 { ACTION_BMS_DELETE, BUTTON_PLAY|BUTTON_ON, BUTTON_ON },
96 { ACTION_BMS_EXIT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE },
97 { ACTION_BMS_SELECT, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
99 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD),
100 }; /* button_context_settings_bmark */
102 /*****************************************************************************
103 * Remote control mappings
104 *****************************************************************************/
106 static const struct button_mapping remote_button_context_standard[] = {
107 { ACTION_STD_PREV, BUTTON_RC_LEFT, BUTTON_NONE },
108 { ACTION_STD_NEXT, BUTTON_RC_RIGHT, BUTTON_NONE },
109 { ACTION_STD_CANCEL, BUTTON_RC_STOP, BUTTON_NONE },
110 { ACTION_STD_OK, BUTTON_RC_PLAY, BUTTON_NONE },
112 LAST_ITEM_IN_LIST
115 static const struct button_mapping remote_button_context_wps[] = {
116 { ACTION_WPS_PLAY, BUTTON_RC_PLAY, BUTTON_NONE },
117 { ACTION_WPS_SKIPNEXT, BUTTON_RC_RIGHT, BUTTON_NONE },
118 { ACTION_WPS_SKIPPREV, BUTTON_RC_LEFT, BUTTON_NONE },
119 { ACTION_WPS_STOP, BUTTON_RC_STOP, BUTTON_NONE },
121 { ACTION_WPS_VOLDOWN, BUTTON_RC_VOL_DOWN, BUTTON_NONE },
122 { ACTION_WPS_VOLUP, BUTTON_RC_VOL_UP, BUTTON_NONE },
124 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
128 static const struct button_mapping* get_context_mapping_remote( int context )
130 context ^= CONTEXT_REMOTE;
132 switch (context)
134 case CONTEXT_WPS:
135 return remote_button_context_wps;
137 default:
138 return remote_button_context_standard;
142 const struct button_mapping* get_context_mapping( int context )
144 if (context&CONTEXT_REMOTE)
145 return get_context_mapping_remote(context);
147 switch (context)
149 case CONTEXT_WPS:
150 return button_context_wps;
152 case CONTEXT_SETTINGS:
153 return button_context_settings;
155 case CONTEXT_YESNOSCREEN:
156 return button_context_yesno;
158 case CONTEXT_TREE:
159 return button_context_tree;
160 case CONTEXT_BOOKMARKSCREEN:
161 return button_context_bmark;
162 case CONTEXT_MAINMENU:
163 return button_context_menu;
164 case CONTEXT_STD:
165 case CONTEXT_LIST:
166 default:
167 return button_context_standard;