Add 2008 to the copyright notice.
[Rockbox.git] / apps / keymaps / keymap-c200.c
blobd3b0593954db37dc220a3f5df587f06b64cedf3d
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id:$
10 * Copyright (C) 2007 Mark Arigo
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 /* Button Code Definitions for Sandisk c200 target */
21 #include "config.h"
22 #include "action.h"
23 #include "button.h"
24 #include "settings.h"
26 /* {Action Code, Button code, Prereq button code } */
28 /*
29 * The format of the list is as follows
30 * { Action Code, Button code, Prereq button code }
31 * if there's no need to check the previous button's value, use BUTTON_NONE
32 * Insert LAST_ITEM_IN_LIST at the end of each mapping
34 static const struct button_mapping button_context_standard[] = {
35 { ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE },
36 { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
38 { ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE },
39 { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
41 { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT },
42 { ACTION_STD_OK, BUTTON_RIGHT, BUTTON_NONE },
43 { ACTION_STD_CANCEL, BUTTON_LEFT, BUTTON_NONE },
45 { ACTION_STD_MENU, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
46 { ACTION_STD_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT },
47 { ACTION_STD_REC, BUTTON_REC|BUTTON_REPEAT, BUTTON_NONE },
48 { ACTION_STD_QUICKSCREEN, BUTTON_REC|BUTTON_SELECT, BUTTON_NONE },
50 LAST_ITEM_IN_LIST
51 }; /* button_context_standard */
54 static const struct button_mapping button_context_wps[] = {
55 { ACTION_WPS_PLAY, BUTTON_UP|BUTTON_REL, BUTTON_UP },
56 { ACTION_WPS_STOP, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP },
58 { ACTION_WPS_SKIPPREV, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT },
59 { ACTION_WPS_SEEKBACK, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
60 { ACTION_WPS_STOPSEEK, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT|BUTTON_REPEAT },
62 { ACTION_WPS_SKIPNEXT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
63 { ACTION_WPS_SEEKFWD, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
64 { ACTION_WPS_STOPSEEK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT },
66 { ACTION_WPS_ABSETB_NEXTDIR,BUTTON_POWER|BUTTON_RIGHT, BUTTON_POWER },
67 { ACTION_WPS_ABSETA_PREVDIR,BUTTON_POWER|BUTTON_LEFT, BUTTON_POWER },
68 { ACTION_WPS_ABRESET, BUTTON_POWER|BUTTON_UP, BUTTON_POWER },
70 { ACTION_WPS_VOLUP, BUTTON_VOL_UP, BUTTON_NONE },
71 { ACTION_WPS_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
73 { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE },
74 { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
76 { ACTION_WPS_MENU, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
77 { ACTION_WPS_BROWSE, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT },
78 { ACTION_WPS_PITCHSCREEN, BUTTON_SELECT|BUTTON_UP, BUTTON_SELECT },
79 { ACTION_WPS_ID3SCREEN, BUTTON_SELECT|BUTTON_DOWN, BUTTON_SELECT },
80 { ACTION_WPS_CONTEXT, BUTTON_DOWN|BUTTON_REL, BUTTON_DOWN },
81 { ACTION_WPS_QUICKSCREEN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_DOWN },
82 { ACTION_WPS_REC, BUTTON_REC|BUTTON_REPEAT, BUTTON_NONE },
84 LAST_ITEM_IN_LIST
85 }; /* button_context_wps */
87 static const struct button_mapping button_context_settings[] = {
88 { ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE },
89 { ACTION_SETTINGS_RESET, BUTTON_SELECT, BUTTON_NONE },
91 { ACTION_SETTINGS_INC, BUTTON_UP, BUTTON_NONE },
92 { ACTION_SETTINGS_INCREPEAT,BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
94 { ACTION_SETTINGS_DEC, BUTTON_DOWN, BUTTON_NONE },
95 { ACTION_SETTINGS_DECREPEAT,BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
97 { ACTION_STD_PREV, BUTTON_LEFT, BUTTON_NONE },
98 { ACTION_STD_PREVREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
100 { ACTION_STD_NEXT, BUTTON_RIGHT, BUTTON_NONE },
101 { ACTION_STD_NEXTREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
103 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD),
104 }; /* button_context_settings */
106 static const struct button_mapping button_context_list[] = {
107 { ACTION_LISTTREE_PGUP, BUTTON_REC|BUTTON_UP, BUTTON_REC },
108 { ACTION_LISTTREE_PGDOWN, BUTTON_REC|BUTTON_DOWN, BUTTON_REC },
110 #ifdef HAVE_VOLUME_IN_LIST
111 { ACTION_LIST_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
112 { ACTION_LIST_VOLUP, BUTTON_VOL_UP, BUTTON_NONE },
114 { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE },
115 { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
116 #endif
118 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
119 }; /* button_context_list */
121 static const struct button_mapping button_context_tree[] = {
122 { ACTION_TREE_WPS, BUTTON_REC|BUTTON_UP, BUTTON_REC },
123 { ACTION_TREE_STOP, BUTTON_REC|BUTTON_UP|BUTTON_REPEAT, BUTTON_REC|BUTTON_UP },
125 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST),
126 }; /* button_context_tree */
128 static const struct button_mapping button_context_listtree_scroll_without_combo[] = {
129 { ACTION_NONE, BUTTON_LEFT, BUTTON_NONE },
130 { ACTION_STD_CANCEL, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT },
131 { ACTION_TREE_ROOT_INIT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT },
132 { ACTION_TREE_PGLEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
133 { ACTION_TREE_PGLEFT, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT|BUTTON_REPEAT },
135 { ACTION_NONE, BUTTON_RIGHT, BUTTON_NONE },
136 { ACTION_STD_OK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
137 { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
138 { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT },
140 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE),
141 }; /* button_context_listtree_scroll_without_combo */
143 static const struct button_mapping button_context_listtree_scroll_with_combo[] = {
144 { ACTION_TREE_ROOT_INIT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
146 { ACTION_TREE_PGLEFT, BUTTON_REC|BUTTON_LEFT, BUTTON_REC },
147 { ACTION_TREE_PGLEFT, BUTTON_REC|BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
149 { ACTION_TREE_PGRIGHT, BUTTON_REC|BUTTON_RIGHT, BUTTON_REC },
150 { ACTION_TREE_PGRIGHT, BUTTON_REC|BUTTON_RIGHT|BUTTON_REPEAT,BUTTON_NONE },
152 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE),
153 }; /* button_context_listtree_scroll_with_combo */
155 static const struct button_mapping button_context_yesno[] = {
156 { ACTION_YESNO_ACCEPT, BUTTON_SELECT, BUTTON_NONE },
158 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD),
159 }; /* button_context_settings_yesno */
161 static const struct button_mapping button_context_quickscreen[] = {
162 { ACTION_NONE, BUTTON_LEFT, BUTTON_NONE },
163 { ACTION_STD_CANCEL, BUTTON_POWER|BUTTON_REL, BUTTON_NONE },
165 { ACTION_QS_DOWNINV, BUTTON_UP|BUTTON_REL, BUTTON_NONE },
166 { ACTION_QS_DOWNINV, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
168 { ACTION_QS_DOWN, BUTTON_DOWN|BUTTON_REL, BUTTON_NONE },
169 { ACTION_QS_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
171 { ACTION_QS_LEFT, BUTTON_LEFT|BUTTON_REL, BUTTON_NONE },
172 { ACTION_QS_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
174 { ACTION_QS_RIGHT, BUTTON_RIGHT|BUTTON_REL, BUTTON_NONE },
175 { ACTION_QS_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
177 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD),
178 }; /* button_context_quickscreen */
180 static const struct button_mapping button_context_settings_right_is_inc[] = {
181 { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE },
182 { ACTION_SETTINGS_INCREPEAT,BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
184 { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE },
185 { ACTION_SETTINGS_DECREPEAT,BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
187 { ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE },
189 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD),
190 }; /* button_context_settings_right_is_inc */
192 static const struct button_mapping button_context_pitchscreen[] = {
193 { ACTION_PS_INC_SMALL, BUTTON_UP, BUTTON_NONE },
194 { ACTION_PS_INC_BIG, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
196 { ACTION_PS_DEC_SMALL, BUTTON_DOWN, BUTTON_NONE },
197 { ACTION_PS_DEC_BIG, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
199 { ACTION_PS_NUDGE_LEFT, BUTTON_LEFT, BUTTON_NONE },
200 { ACTION_PS_NUDGE_LEFTOFF, BUTTON_LEFT|BUTTON_REL, BUTTON_NONE },
202 { ACTION_PS_NUDGE_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
203 { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_RIGHT|BUTTON_REL, BUTTON_NONE },
205 { ACTION_PS_RESET, BUTTON_SELECT, BUTTON_NONE },
206 { ACTION_PS_EXIT, BUTTON_POWER, BUTTON_NONE },
208 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD),
209 }; /* button_context_pitchscreen */
211 /** Recording Screen **/
212 #ifdef HAVE_RECORDING
213 static const struct button_mapping button_context_recscreen[] = {
214 { ACTION_STD_MENU, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
215 { ACTION_REC_PAUSE, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT },
216 { ACTION_STD_CANCEL, BUTTON_POWER|BUTTON_REPEAT, BUTTON_NONE },
217 { ACTION_REC_NEWFILE, BUTTON_REC|BUTTON_REL, BUTTON_REC },
219 { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE },
220 { ACTION_SETTINGS_INCREPEAT,BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
221 { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE },
222 { ACTION_SETTINGS_DECREPEAT,BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
224 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
225 }; /* button_context_recscreen */
226 #endif
228 /** FM Radio Screen **/
229 #if CONFIG_TUNER
230 static const struct button_mapping button_context_radio[] = {
231 { ACTION_NONE, BUTTON_UP, BUTTON_NONE },
232 { ACTION_FM_MENU, BUTTON_DOWN, BUTTON_NONE },
233 { ACTION_FM_PRESET, BUTTON_SELECT, BUTTON_NONE },
234 { ACTION_FM_STOP, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP },
235 { ACTION_FM_MODE, BUTTON_REC, BUTTON_NONE },
236 { ACTION_FM_EXIT, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
237 { ACTION_FM_PLAY, BUTTON_UP|BUTTON_REL, BUTTON_UP },
238 { ACTION_SETTINGS_INC, BUTTON_VOL_UP, BUTTON_NONE },
239 { ACTION_SETTINGS_INCREPEAT,BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
240 { ACTION_SETTINGS_DEC, BUTTON_VOL_DOWN, BUTTON_NONE },
241 { ACTION_SETTINGS_DECREPEAT,BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
243 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
244 }; /* button_context_radio */
245 #endif
247 static const struct button_mapping button_context_keyboard[] = {
248 { ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE },
249 { ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
250 { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
251 { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
253 { ACTION_KBD_CURSOR_LEFT, BUTTON_REC|BUTTON_LEFT, BUTTON_NONE },
254 { ACTION_KBD_CURSOR_LEFT, BUTTON_REC|BUTTON_LEFT|BUTTON_REPEAT,BUTTON_NONE },
255 { ACTION_KBD_CURSOR_RIGHT, BUTTON_REC|BUTTON_RIGHT, BUTTON_NONE },
256 { ACTION_KBD_CURSOR_RIGHT, BUTTON_REC|BUTTON_RIGHT|BUTTON_REPEAT,BUTTON_NONE },
258 { ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE },
259 { ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
260 { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE },
261 { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
263 { ACTION_KBD_BACKSPACE, BUTTON_REC|BUTTON_DOWN, BUTTON_NONE },
264 { ACTION_KBD_BACKSPACE, BUTTON_REC|BUTTON_DOWN|BUTTON_REPEAT,BUTTON_NONE },
266 { ACTION_KBD_PAGE_FLIP, BUTTON_REC|BUTTON_SELECT, BUTTON_REC },
268 { ACTION_KBD_SELECT, BUTTON_SELECT, BUTTON_NONE },
269 { ACTION_KBD_DONE, BUTTON_VOL_UP, BUTTON_NONE },
270 { ACTION_KBD_DONE, BUTTON_VOL_DOWN, BUTTON_NONE },
271 { ACTION_KBD_ABORT, BUTTON_POWER, BUTTON_NONE },
273 LAST_ITEM_IN_LIST
274 }; /* button_context_keyboard */
276 static const struct button_mapping button_context_bmark[] = {
277 { ACTION_BMS_DELETE, BUTTON_REC, BUTTON_NONE },
279 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST),
280 }; /* button_context_bmark */
282 /* get_context_mapping returns a pointer to one of the above defined arrays depending on the context */
283 const struct button_mapping* get_context_mapping(int context)
285 switch (context)
287 case CONTEXT_STD:
288 return button_context_standard;
290 case CONTEXT_WPS:
291 return button_context_wps;
293 case CONTEXT_LIST:
294 return button_context_list;
295 case CONTEXT_TREE:
296 case CONTEXT_MAINMENU:
297 if (global_settings.hold_lr_for_scroll_in_list)
298 return button_context_listtree_scroll_without_combo;
299 else
300 return button_context_listtree_scroll_with_combo;
301 case CONTEXT_CUSTOM|CONTEXT_TREE:
302 return button_context_tree;
304 case CONTEXT_SETTINGS:
305 case CONTEXT_SETTINGS_TIME:
306 return button_context_settings;
307 case CONTEXT_CUSTOM|CONTEXT_SETTINGS:
308 case CONTEXT_SETTINGS_COLOURCHOOSER:
309 case CONTEXT_SETTINGS_EQ:
310 return button_context_settings_right_is_inc;
312 case CONTEXT_YESNOSCREEN:
313 return button_context_yesno;
314 #if CONFIG_TUNER
315 case CONTEXT_FM:
316 return button_context_radio;
317 #endif
318 case CONTEXT_BOOKMARKSCREEN:
319 return button_context_bmark;
320 case CONTEXT_QUICKSCREEN:
321 return button_context_quickscreen;
322 case CONTEXT_PITCHSCREEN:
323 return button_context_pitchscreen;
324 #ifdef HAVE_RECORDING
325 case CONTEXT_RECSCREEN:
326 return button_context_recscreen;
327 #endif
328 case CONTEXT_KEYBOARD:
329 return button_context_keyboard;
331 default:
332 return button_context_standard;
334 return button_context_standard;