Portal player i2c driver: More struct spinlock phaseout.
[Rockbox.git] / apps / keymaps / keymap-recorder.c
blob73fdbf069675df3ffb54845d22488146cb01a731
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2006 Antoine Cellerier <dionoea @t videolan d.t org>
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 recorder target
22 * \TODO handle F3
25 #include "config.h"
26 #include "action.h"
27 #include "button.h"
28 #include "settings.h"
30 /* CONTEXT_CUSTOM's used in this file...
32 CONTEXT_CUSTOM|1 = the standard list/tree defines (without directions)
37 static const struct button_mapping button_context_standard[] = {
38 { ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE },
39 { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
40 { ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE },
41 { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
43 { ACTION_STD_OK, BUTTON_ON, BUTTON_NONE },
44 { ACTION_STD_OK, BUTTON_RIGHT, BUTTON_NONE },
45 { ACTION_STD_OK, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_RIGHT },
47 { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
48 { ACTION_STD_MENU, BUTTON_F1, BUTTON_NONE },
49 { ACTION_STD_QUICKSCREEN, BUTTON_F2, BUTTON_NONE },
50 { ACTION_STD_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
51 { ACTION_STD_CANCEL, BUTTON_OFF, BUTTON_NONE },
52 { ACTION_STD_CANCEL, BUTTON_LEFT, BUTTON_NONE },
53 { ACTION_STD_CANCEL, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
54 { ACTION_F3, BUTTON_F3, BUTTON_NONE },
56 LAST_ITEM_IN_LIST
59 static const struct button_mapping button_context_wps[] = {
60 { ACTION_WPS_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
61 { ACTION_WPS_SKIPNEXT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
62 { ACTION_WPS_SKIPPREV, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT },
63 { ACTION_WPS_SEEKBACK, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
64 { ACTION_WPS_SEEKFWD, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
65 { ACTION_WPS_STOPSEEK, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT|BUTTON_REPEAT },
66 { ACTION_WPS_STOPSEEK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT },
67 { ACTION_WPS_STOP, BUTTON_OFF|BUTTON_REL, BUTTON_OFF },
68 { ACTION_WPS_VOLDOWN, BUTTON_DOWN, BUTTON_NONE },
69 { ACTION_WPS_VOLDOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
70 { ACTION_WPS_VOLUP, BUTTON_UP, BUTTON_NONE },
71 { ACTION_WPS_VOLUP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
72 { ACTION_WPS_MENU, BUTTON_F1|BUTTON_REL, BUTTON_F1 },
73 { ACTION_WPS_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
74 { ACTION_WPS_QUICKSCREEN, BUTTON_F2, BUTTON_NONE },
75 { ACTION_WPS_BROWSE, BUTTON_ON|BUTTON_REL, BUTTON_ON },
76 { ACTION_WPS_ID3SCREEN, BUTTON_F1|BUTTON_ON, BUTTON_NONE },
77 { ACTION_WPS_PITCHSCREEN, BUTTON_ON|BUTTON_UP, BUTTON_ON },
78 { ACTION_WPS_PITCHSCREEN, BUTTON_ON|BUTTON_DOWN, BUTTON_ON },
79 { ACTION_STD_KEYLOCK, BUTTON_F1|BUTTON_DOWN, BUTTON_NONE },
80 { ACTION_F3, BUTTON_F3, BUTTON_NONE },
81 { ACTION_WPS_ABSETB_NEXTDIR, BUTTON_ON|BUTTON_RIGHT, BUTTON_NONE },
82 { ACTION_WPS_ABSETA_PREVDIR, BUTTON_ON|BUTTON_LEFT, BUTTON_NONE },
83 { ACTION_WPS_ABRESET, BUTTON_ON|BUTTON_OFF, BUTTON_ON },
86 LAST_ITEM_IN_LIST
89 static const struct button_mapping button_context_settings[] = {
90 { ACTION_SETTINGS_INC, BUTTON_UP, BUTTON_NONE },
91 { ACTION_SETTINGS_INCREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
92 { ACTION_SETTINGS_DEC, BUTTON_DOWN, BUTTON_NONE },
93 { ACTION_SETTINGS_DECREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
94 { ACTION_STD_PREV, BUTTON_LEFT, BUTTON_NONE },
95 { ACTION_STD_PREVREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
96 { ACTION_STD_NEXT, BUTTON_RIGHT, BUTTON_NONE },
97 { ACTION_STD_NEXTREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
99 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
102 static const struct button_mapping button_context_tree[] = {
103 { ACTION_TREE_WPS, BUTTON_ON|BUTTON_REL, BUTTON_ON },
104 { ACTION_TREE_STOP, BUTTON_OFF, BUTTON_NONE },
105 { ACTION_NONE, BUTTON_ON, BUTTON_NONE },
106 { ACTION_LISTTREE_PGUP, BUTTON_ON|BUTTON_UP, BUTTON_ON },
107 { ACTION_LISTTREE_PGUP, BUTTON_UP|BUTTON_REL, BUTTON_ON|BUTTON_UP },
108 { ACTION_LISTTREE_PGUP, BUTTON_ON|BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
109 { ACTION_LISTTREE_PGDOWN, BUTTON_ON|BUTTON_DOWN, BUTTON_ON },
110 { ACTION_LISTTREE_PGDOWN, BUTTON_DOWN|BUTTON_REL, BUTTON_ON|BUTTON_DOWN },
111 { ACTION_LISTTREE_PGDOWN, BUTTON_ON|BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
112 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
113 }; /* button_context_listtree */
116 static const struct button_mapping button_context_tree_scroll_lr[] = {
117 { ACTION_NONE, BUTTON_LEFT, BUTTON_NONE },
118 { ACTION_STD_CANCEL, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT },
119 { ACTION_TREE_ROOT_INIT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT },
120 { ACTION_TREE_PGLEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
121 { ACTION_TREE_PGLEFT, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT|BUTTON_REPEAT },
122 { ACTION_NONE, BUTTON_RIGHT, BUTTON_NONE },
123 { ACTION_STD_OK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
124 { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
125 { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT },
126 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|1),
129 static const struct button_mapping button_context_yesno[] = {
130 { ACTION_YESNO_ACCEPT, BUTTON_PLAY, BUTTON_NONE },
132 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
134 static const struct button_mapping button_context_quickscreen[] = {
135 { ACTION_QS_DOWNINV, BUTTON_UP, BUTTON_NONE },
136 { ACTION_QS_DOWNINV, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
137 { ACTION_QS_DOWN, BUTTON_DOWN, BUTTON_NONE },
138 { ACTION_QS_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
139 { ACTION_QS_LEFT, BUTTON_LEFT, BUTTON_NONE },
140 { ACTION_QS_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
141 { ACTION_QS_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
142 { ACTION_QS_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
143 { ACTION_STD_CANCEL, BUTTON_PLAY, BUTTON_NONE },
145 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
146 }; /* button_context_quickscreen */
148 static const struct button_mapping button_context_pitchscreen[] = {
149 { ACTION_PS_INC_SMALL, BUTTON_UP, BUTTON_NONE },
150 { ACTION_PS_INC_BIG, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
151 { ACTION_PS_DEC_SMALL, BUTTON_DOWN, BUTTON_NONE },
152 { ACTION_PS_DEC_BIG, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
153 { ACTION_PS_NUDGE_LEFT, BUTTON_LEFT, BUTTON_NONE },
154 { ACTION_PS_NUDGE_LEFTOFF, BUTTON_LEFT|BUTTON_REL, BUTTON_NONE },
155 { ACTION_PS_NUDGE_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
156 { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_RIGHT|BUTTON_REL, BUTTON_NONE },
157 { ACTION_PS_TOGGLE_MODE, BUTTON_F1, BUTTON_NONE },
158 { ACTION_PS_RESET, BUTTON_ON, BUTTON_NONE },
159 { ACTION_PS_EXIT, BUTTON_OFF, BUTTON_NONE },
161 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
162 }; /* button_context_pitchcreen */
164 static const struct button_mapping button_context_recscreen[] = {
165 { ACTION_REC_PAUSE, BUTTON_PLAY, BUTTON_NONE },
166 { ACTION_REC_F2, BUTTON_F2, BUTTON_NONE },
167 { ACTION_REC_F3, BUTTON_F3, BUTTON_NONE },
168 { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE },
169 { ACTION_SETTINGS_INC, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
170 { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE },
171 { ACTION_SETTINGS_DEC, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
173 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
174 }; /* button_context_recscreen */
176 static const struct button_mapping button_context_keyboard[] = {
177 { ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE },
178 { ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
179 { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
180 { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
181 { ACTION_KBD_CURSOR_LEFT, BUTTON_ON|BUTTON_LEFT, BUTTON_NONE },
182 { ACTION_KBD_CURSOR_LEFT, BUTTON_ON|BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
183 { ACTION_KBD_CURSOR_RIGHT, BUTTON_ON|BUTTON_RIGHT, BUTTON_NONE },
184 { ACTION_KBD_CURSOR_RIGHT, BUTTON_ON|BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
185 { ACTION_KBD_SELECT, BUTTON_PLAY, BUTTON_NONE },
186 { ACTION_KBD_PAGE_FLIP, BUTTON_F1, BUTTON_NONE },
187 { ACTION_KBD_DONE, BUTTON_F2, BUTTON_NONE },
188 { ACTION_KBD_ABORT, BUTTON_OFF, BUTTON_NONE },
189 { ACTION_KBD_BACKSPACE, BUTTON_F3, BUTTON_NONE },
190 { ACTION_KBD_BACKSPACE, BUTTON_F3|BUTTON_REPEAT, BUTTON_NONE },
191 { ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE },
192 { ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
193 { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE },
194 { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
196 LAST_ITEM_IN_LIST
197 }; /* button_context_keyboard */
199 static const struct button_mapping button_context_bmark[] = {
200 { ACTION_BMS_DELETE, BUTTON_PLAY|BUTTON_ON, BUTTON_PLAY },
201 { ACTION_BMS_DELETE, BUTTON_PLAY|BUTTON_ON, BUTTON_ON },
203 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST),
205 }; /* button_context_settings_bmark */
207 static const struct button_mapping button_context_radio[] = {
208 { ACTION_FM_MENU, BUTTON_F1, BUTTON_NONE },
209 { ACTION_FM_PRESET, BUTTON_F2, BUTTON_NONE },
210 { ACTION_FM_RECORD, BUTTON_F3, BUTTON_NONE },
211 { ACTION_FM_FREEZE, BUTTON_PLAY, BUTTON_NONE },
212 { ACTION_FM_STOP, BUTTON_OFF, BUTTON_NONE },
213 { ACTION_FM_MODE, BUTTON_ON | BUTTON_REPEAT, BUTTON_ON },
214 { ACTION_FM_EXIT, BUTTON_ON | BUTTON_REL, BUTTON_ON },
216 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
220 #if BUTTON_REMOTE != 0
221 /*****************************************************************************
222 * Remote control mappings
223 *****************************************************************************/
225 static const struct button_mapping remote_button_context_standard[] = {
226 { ACTION_STD_PREV, BUTTON_RC_LEFT, BUTTON_NONE },
227 { ACTION_STD_NEXT, BUTTON_RC_RIGHT, BUTTON_NONE },
228 { ACTION_STD_CANCEL, BUTTON_RC_STOP, BUTTON_NONE },
229 { ACTION_STD_OK, BUTTON_RC_PLAY, BUTTON_NONE },
231 LAST_ITEM_IN_LIST
234 static const struct button_mapping remote_button_context_wps[] = {
235 { ACTION_WPS_PLAY, BUTTON_RC_PLAY, BUTTON_NONE },
236 { ACTION_WPS_SKIPNEXT, BUTTON_RC_RIGHT, BUTTON_NONE },
237 { ACTION_WPS_SKIPPREV, BUTTON_RC_LEFT, BUTTON_NONE },
238 { ACTION_WPS_STOP, BUTTON_RC_STOP, BUTTON_NONE },
240 { ACTION_WPS_VOLDOWN, BUTTON_RC_VOL_DOWN, BUTTON_NONE },
241 { ACTION_WPS_VOLUP, BUTTON_RC_VOL_UP, BUTTON_NONE },
243 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
247 static const struct button_mapping* get_context_mapping_remote( int context )
249 context ^= CONTEXT_REMOTE;
251 switch (context)
253 case CONTEXT_WPS:
254 return remote_button_context_wps;
256 default:
257 return remote_button_context_standard;
260 #endif /* BUTTON_REMOTE != 0 */
262 const struct button_mapping* get_context_mapping( int context )
264 #if BUTTON_REMOTE != 0
265 if (context&CONTEXT_REMOTE)
266 return get_context_mapping_remote(context);
267 #endif
269 switch( context )
271 case CONTEXT_WPS:
272 return button_context_wps;
273 case CONTEXT_SETTINGS_TIME:
274 case CONTEXT_SETTINGS:
275 return button_context_settings;
277 case CONTEXT_YESNOSCREEN:
278 return button_context_yesno;
280 case CONTEXT_PITCHSCREEN:
281 return button_context_pitchscreen;
282 case CONTEXT_BOOKMARKSCREEN:
283 return button_context_bmark;
284 case CONTEXT_TREE:
285 case CONTEXT_MAINMENU:
286 if (global_settings.hold_lr_for_scroll_in_list)
287 return button_context_tree_scroll_lr;
288 /* else fall through to CUSTOM|1 */
289 case CONTEXT_CUSTOM|1:
290 return button_context_tree;
292 case CONTEXT_QUICKSCREEN:
293 return button_context_quickscreen;
295 case CONTEXT_RECSCREEN:
296 return button_context_recscreen;
297 case CONTEXT_KEYBOARD:
298 return button_context_keyboard;
299 case CONTEXT_FM:
300 return button_context_radio;
302 case CONTEXT_STD:
303 case CONTEXT_LIST:
304 default:
305 return button_context_standard;