Fix disastrous variable shadowing, change casts to unsigned in (cygwin doesn't like...
[kugel-rb.git] / apps / keymaps / keymap-recorder.c
blob8b395e2700b91bde00ed498c09ea8c98445e43af
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2006 Antoine Cellerier <dionoea @t videolan d.t org>
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 /* *
23 * Button Code Definitions for archos recorder target
25 * \TODO handle F3
28 #include "config.h"
29 #include "action.h"
30 #include "button.h"
31 #include "settings.h"
33 /* CONTEXT_CUSTOM's used in this file...
35 CONTEXT_CUSTOM|1 = the standard list/tree defines (without directions)
40 static const struct button_mapping button_context_standard[] = {
41 { ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE },
42 { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
43 { ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE },
44 { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
46 { ACTION_STD_OK, BUTTON_ON, BUTTON_NONE },
47 { ACTION_STD_OK, BUTTON_RIGHT, BUTTON_NONE },
48 { ACTION_STD_OK, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_RIGHT },
50 { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
51 { ACTION_STD_MENU, BUTTON_F1, BUTTON_NONE },
52 { ACTION_STD_QUICKSCREEN, BUTTON_F2, BUTTON_NONE },
53 { ACTION_STD_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
54 { ACTION_STD_CANCEL, BUTTON_OFF, BUTTON_NONE },
55 { ACTION_STD_CANCEL, BUTTON_LEFT, BUTTON_NONE },
56 { ACTION_STD_CANCEL, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
57 { ACTION_F3, BUTTON_F3, BUTTON_NONE },
59 LAST_ITEM_IN_LIST
62 static const struct button_mapping button_context_wps[] = {
63 { ACTION_NONE, BUTTON_ON, BUTTON_NONE },
64 { ACTION_WPS_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
65 { ACTION_WPS_SKIPNEXT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
66 { ACTION_WPS_SKIPPREV, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT },
67 { ACTION_WPS_SEEKBACK, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
68 { ACTION_WPS_SEEKFWD, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
69 { ACTION_WPS_STOPSEEK, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT|BUTTON_REPEAT },
70 { ACTION_WPS_STOPSEEK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT },
71 { ACTION_WPS_STOP, BUTTON_OFF|BUTTON_REL, BUTTON_OFF },
72 { ACTION_WPS_VOLDOWN, BUTTON_DOWN, BUTTON_NONE },
73 { ACTION_WPS_VOLDOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
74 { ACTION_WPS_VOLUP, BUTTON_UP, BUTTON_NONE },
75 { ACTION_WPS_VOLUP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
76 { ACTION_WPS_MENU, BUTTON_F1|BUTTON_REL, BUTTON_F1 },
77 { ACTION_WPS_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
78 { ACTION_WPS_QUICKSCREEN, BUTTON_F2|BUTTON_REPEAT, BUTTON_NONE },
79 { ACTION_WPS_HOTKEY, BUTTON_F2|BUTTON_REL, BUTTON_F2 },
80 { ACTION_WPS_BROWSE, BUTTON_ON|BUTTON_REL, BUTTON_ON },
81 { ACTION_WPS_ID3SCREEN, BUTTON_F1|BUTTON_ON, BUTTON_NONE },
82 { ACTION_WPS_PITCHSCREEN, BUTTON_ON|BUTTON_UP, BUTTON_ON },
83 { ACTION_WPS_PITCHSCREEN, BUTTON_ON|BUTTON_DOWN, BUTTON_ON },
84 { ACTION_STD_KEYLOCK, BUTTON_F1|BUTTON_DOWN, BUTTON_NONE },
85 { ACTION_F3, BUTTON_F3, BUTTON_NONE },
86 { ACTION_WPS_ABSETB_NEXTDIR, BUTTON_ON|BUTTON_RIGHT, BUTTON_NONE },
87 { ACTION_WPS_ABSETA_PREVDIR, BUTTON_ON|BUTTON_LEFT, BUTTON_NONE },
88 { ACTION_WPS_ABRESET, BUTTON_ON|BUTTON_OFF, BUTTON_ON },
91 LAST_ITEM_IN_LIST
94 static const struct button_mapping button_context_settings[] = {
95 { ACTION_SETTINGS_INC, BUTTON_UP, BUTTON_NONE },
96 { ACTION_SETTINGS_INCREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
97 { ACTION_SETTINGS_DEC, BUTTON_DOWN, BUTTON_NONE },
98 { ACTION_SETTINGS_DECREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
99 { ACTION_STD_PREV, BUTTON_LEFT, BUTTON_NONE },
100 { ACTION_STD_PREVREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
101 { ACTION_STD_NEXT, BUTTON_RIGHT, BUTTON_NONE },
102 { ACTION_STD_NEXTREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
104 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
107 static const struct button_mapping button_context_tree[] = {
108 { ACTION_TREE_WPS, BUTTON_ON|BUTTON_REL, BUTTON_ON },
109 { ACTION_TREE_STOP, BUTTON_OFF, BUTTON_NONE },
110 { ACTION_TREE_HOTKEY, BUTTON_F2|BUTTON_REL, BUTTON_F2 },
111 { ACTION_NONE, BUTTON_ON, BUTTON_NONE },
112 { ACTION_LISTTREE_PGUP, BUTTON_ON|BUTTON_UP, BUTTON_ON },
113 { ACTION_LISTTREE_PGUP, BUTTON_UP|BUTTON_REL, BUTTON_ON|BUTTON_UP },
114 { ACTION_LISTTREE_PGUP, BUTTON_ON|BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
115 { ACTION_LISTTREE_PGDOWN, BUTTON_ON|BUTTON_DOWN, BUTTON_ON },
116 { ACTION_LISTTREE_PGDOWN, BUTTON_DOWN|BUTTON_REL, BUTTON_ON|BUTTON_DOWN },
117 { ACTION_LISTTREE_PGDOWN, BUTTON_ON|BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
118 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
119 }; /* button_context_listtree */
122 static const struct button_mapping button_context_tree_scroll_lr[] = {
123 { ACTION_NONE, BUTTON_LEFT, BUTTON_NONE },
124 { ACTION_STD_CANCEL, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT },
125 { ACTION_TREE_ROOT_INIT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT },
126 { ACTION_TREE_PGLEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
127 { ACTION_TREE_PGLEFT, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT|BUTTON_REPEAT },
128 { ACTION_NONE, BUTTON_RIGHT, BUTTON_NONE },
129 { ACTION_STD_OK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
130 { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
131 { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT },
132 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|1),
135 static const struct button_mapping button_context_yesno[] = {
136 { ACTION_YESNO_ACCEPT, BUTTON_PLAY, BUTTON_NONE },
138 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
140 static const struct button_mapping button_context_quickscreen[] = {
141 { ACTION_QS_TOP, BUTTON_UP, BUTTON_NONE },
142 { ACTION_QS_TOP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
143 { ACTION_QS_DOWN, BUTTON_DOWN, BUTTON_NONE },
144 { ACTION_QS_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
145 { ACTION_QS_LEFT, BUTTON_LEFT, BUTTON_NONE },
146 { ACTION_QS_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
147 { ACTION_QS_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
148 { ACTION_QS_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
149 { ACTION_STD_CANCEL, BUTTON_PLAY, BUTTON_NONE },
151 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
152 }; /* button_context_quickscreen */
154 static const struct button_mapping button_context_pitchscreen[] = {
155 { ACTION_PS_INC_SMALL, BUTTON_UP, BUTTON_NONE },
156 { ACTION_PS_INC_BIG, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
157 { ACTION_PS_DEC_SMALL, BUTTON_DOWN, BUTTON_NONE },
158 { ACTION_PS_DEC_BIG, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
159 { ACTION_PS_NUDGE_LEFT, BUTTON_LEFT, BUTTON_NONE },
160 { ACTION_PS_NUDGE_LEFTOFF, BUTTON_LEFT|BUTTON_REL, BUTTON_NONE },
161 { ACTION_PS_NUDGE_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
162 { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_RIGHT|BUTTON_REL, BUTTON_NONE },
163 { ACTION_PS_TOGGLE_MODE, BUTTON_F1, BUTTON_NONE },
164 { ACTION_PS_RESET, BUTTON_ON, BUTTON_NONE },
165 { ACTION_PS_EXIT, BUTTON_OFF, BUTTON_NONE },
167 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
168 }; /* button_context_pitchcreen */
170 static const struct button_mapping button_context_recscreen[] = {
171 { ACTION_REC_PAUSE, BUTTON_PLAY, BUTTON_NONE },
172 { ACTION_REC_F2, BUTTON_F2, BUTTON_NONE },
173 { ACTION_REC_F3, BUTTON_F3, BUTTON_NONE },
174 { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE },
175 { ACTION_SETTINGS_INCREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
176 { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE },
177 { ACTION_SETTINGS_DECREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
179 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
180 }; /* button_context_recscreen */
182 static const struct button_mapping button_context_keyboard[] = {
183 { ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE },
184 { ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
185 { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
186 { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
187 { ACTION_KBD_CURSOR_LEFT, BUTTON_ON|BUTTON_LEFT, BUTTON_NONE },
188 { ACTION_KBD_CURSOR_LEFT, BUTTON_ON|BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
189 { ACTION_KBD_CURSOR_RIGHT, BUTTON_ON|BUTTON_RIGHT, BUTTON_NONE },
190 { ACTION_KBD_CURSOR_RIGHT, BUTTON_ON|BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
191 { ACTION_KBD_SELECT, BUTTON_PLAY, BUTTON_NONE },
192 { ACTION_KBD_PAGE_FLIP, BUTTON_F1, BUTTON_NONE },
193 { ACTION_KBD_DONE, BUTTON_F2, BUTTON_NONE },
194 { ACTION_KBD_ABORT, BUTTON_OFF, BUTTON_NONE },
195 { ACTION_KBD_BACKSPACE, BUTTON_F3, BUTTON_NONE },
196 { ACTION_KBD_BACKSPACE, BUTTON_F3|BUTTON_REPEAT, BUTTON_NONE },
197 { ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE },
198 { ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
199 { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE },
200 { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
201 { ACTION_KBD_MORSE_SELECT, BUTTON_PLAY|BUTTON_REL, BUTTON_NONE },
203 LAST_ITEM_IN_LIST
204 }; /* button_context_keyboard */
206 static const struct button_mapping button_context_bmark[] = {
207 { ACTION_NONE, BUTTON_ON, BUTTON_NONE },
208 { ACTION_BMS_DELETE, BUTTON_PLAY|BUTTON_ON, BUTTON_NONE },
210 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST),
212 }; /* button_context_settings_bmark */
214 static const struct button_mapping button_context_radio[] = {
215 { ACTION_FM_MENU, BUTTON_F1, BUTTON_NONE },
216 { ACTION_FM_PRESET, BUTTON_F2|BUTTON_REL, BUTTON_F2 },
217 { ACTION_FM_QUICKSCREEN, BUTTON_F2|BUTTON_REPEAT, BUTTON_NONE },
218 { ACTION_FM_RECORD, BUTTON_F3, BUTTON_NONE },
219 { ACTION_FM_FREEZE, BUTTON_PLAY, BUTTON_NONE },
220 { ACTION_FM_STOP, BUTTON_OFF, BUTTON_NONE },
221 { ACTION_FM_MODE, BUTTON_ON | BUTTON_REPEAT, BUTTON_ON },
222 { ACTION_FM_EXIT, BUTTON_ON | BUTTON_REL, BUTTON_ON },
224 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
228 #if BUTTON_REMOTE != 0
229 /*****************************************************************************
230 * Remote control mappings
231 *****************************************************************************/
233 static const struct button_mapping remote_button_context_standard[] = {
234 { ACTION_STD_PREV, BUTTON_RC_LEFT, BUTTON_NONE },
235 { ACTION_STD_NEXT, BUTTON_RC_RIGHT, BUTTON_NONE },
236 { ACTION_STD_CANCEL, BUTTON_RC_STOP, BUTTON_NONE },
237 { ACTION_STD_OK, BUTTON_RC_PLAY, BUTTON_NONE },
239 LAST_ITEM_IN_LIST
242 static const struct button_mapping remote_button_context_wps[] = {
243 { ACTION_WPS_PLAY, BUTTON_RC_PLAY, BUTTON_NONE },
244 { ACTION_WPS_SKIPNEXT, BUTTON_RC_RIGHT, BUTTON_NONE },
245 { ACTION_WPS_SKIPPREV, BUTTON_RC_LEFT, BUTTON_NONE },
246 { ACTION_WPS_STOP, BUTTON_RC_STOP, BUTTON_NONE },
248 { ACTION_WPS_VOLDOWN, BUTTON_RC_VOL_DOWN, BUTTON_NONE },
249 { ACTION_WPS_VOLUP, BUTTON_RC_VOL_UP, BUTTON_NONE },
251 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
255 static const struct button_mapping* get_context_mapping_remote( int context )
257 context ^= CONTEXT_REMOTE;
259 switch (context)
261 case CONTEXT_WPS:
262 return remote_button_context_wps;
264 default:
265 return remote_button_context_standard;
268 #endif /* BUTTON_REMOTE != 0 */
270 const struct button_mapping* get_context_mapping( int context )
272 #if BUTTON_REMOTE != 0
273 if (context&CONTEXT_REMOTE)
274 return get_context_mapping_remote(context);
275 #endif
277 switch( context )
279 case CONTEXT_WPS:
280 return button_context_wps;
281 case CONTEXT_SETTINGS_TIME:
282 case CONTEXT_SETTINGS:
283 return button_context_settings;
285 case CONTEXT_YESNOSCREEN:
286 return button_context_yesno;
288 case CONTEXT_PITCHSCREEN:
289 return button_context_pitchscreen;
290 case CONTEXT_BOOKMARKSCREEN:
291 return button_context_bmark;
292 case CONTEXT_TREE:
293 case CONTEXT_MAINMENU:
294 if (global_settings.hold_lr_for_scroll_in_list)
295 return button_context_tree_scroll_lr;
296 /* else fall through to CUSTOM|1 */
297 case CONTEXT_CUSTOM|1:
298 return button_context_tree;
300 case CONTEXT_QUICKSCREEN:
301 return button_context_quickscreen;
303 case CONTEXT_RECSCREEN:
304 case CONTEXT_SETTINGS_RECTRIGGER:
305 return button_context_recscreen;
306 case CONTEXT_KEYBOARD:
307 case CONTEXT_MORSE_INPUT:
308 return button_context_keyboard;
309 case CONTEXT_FM:
310 return button_context_radio;
312 case CONTEXT_STD:
313 case CONTEXT_LIST:
314 default:
315 return button_context_standard;