blob: 478eea3bfe3e28fd94988537f8c53abe5d2f4569 [file] [log] [blame]
Mark Arigob4275d42008-05-21 03:55:17 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 Jonathan Gordon
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * 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.
Mark Arigob4275d42008-05-21 03:55:17 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22/* Button Code Definitions for the Philips SA9200 target */
23#include <stdio.h>
24#include <string.h>
25#include <stdlib.h>
26
27#include "config.h"
28#include "action.h"
29#include "button.h"
30#include "settings.h"
31
32/*
33 * The format of the list is as follows
34 * { Action Code, Button code, Prereq button code }
35 * if there's no need to check the previous button's value, use BUTTON_NONE
36 * Insert LAST_ITEM_IN_LIST at the end of each mapping
37 */
38
39/* CONTEXT_CUSTOM's used in this file...
40
41CONTEXT_CUSTOM|CONTEXT_TREE = the standard list/tree defines (without directions)
42CONTEXT_CUSTOM|CONTEXT_SETTINGS = the direction keys for the eq/col picker screens
43 i.e where up/down is inc/dec
44 CONTEXT_SETTINGS = up/down is prev/next, l/r is inc/dec
45
46*/
47
48
49static const struct button_mapping button_context_standard[] = {
50 { ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE },
51 { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
52 { ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE },
53 { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
54
55 { ACTION_STD_CANCEL, BUTTON_REW, BUTTON_NONE },
56 { ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE },
57
58 { ACTION_STD_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT },
59
60 { ACTION_STD_QUICKSCREEN, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU },
61 { ACTION_STD_MENU, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
62
63 { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT },
64 { ACTION_STD_OK, BUTTON_FFWD, BUTTON_NONE },
65
66 LAST_ITEM_IN_LIST
67}; /* button_context_standard */
68
69
70static const struct button_mapping button_context_wps[] = {
71 { ACTION_WPS_PLAY, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
72 { ACTION_WPS_STOP, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
73
74 { ACTION_WPS_SKIPNEXT, BUTTON_FFWD|BUTTON_REL, BUTTON_FFWD },
75 { ACTION_WPS_SKIPPREV, BUTTON_REW|BUTTON_REL, BUTTON_REW },
76
77 { ACTION_WPS_SEEKBACK, BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE },
78 { ACTION_WPS_SEEKFWD, BUTTON_FFWD|BUTTON_REPEAT, BUTTON_NONE },
79 { ACTION_WPS_STOPSEEK, BUTTON_REW|BUTTON_REL, BUTTON_REW|BUTTON_REPEAT },
80 { ACTION_WPS_STOPSEEK, BUTTON_FFWD|BUTTON_REL, BUTTON_FFWD|BUTTON_REPEAT },
81
82 { ACTION_WPS_ABSETB_NEXTDIR, BUTTON_RIGHT|BUTTON_FFWD, BUTTON_NONE },
83 { ACTION_WPS_ABSETA_PREVDIR, BUTTON_RIGHT|BUTTON_REW, BUTTON_NONE },
84 { ACTION_WPS_ABRESET, BUTTON_RIGHT|BUTTON_SELECT, BUTTON_NONE },
85
86 { ACTION_WPS_VOLDOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
87 { ACTION_WPS_VOLDOWN, BUTTON_DOWN, BUTTON_NONE },
88 { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE },
89 { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
90 { ACTION_WPS_VOLUP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
91 { ACTION_WPS_VOLUP, BUTTON_UP, BUTTON_NONE },
92 { ACTION_WPS_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
93 { ACTION_WPS_VOLUP, BUTTON_VOL_UP, BUTTON_NONE },
94
95 { ACTION_WPS_PITCHSCREEN, BUTTON_RIGHT|BUTTON_UP, BUTTON_RIGHT },
96 { ACTION_WPS_PITCHSCREEN, BUTTON_RIGHT|BUTTON_DOWN, BUTTON_RIGHT },
97
98 { ACTION_WPS_QUICKSCREEN, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU },
99 { ACTION_WPS_MENU, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
100 { ACTION_WPS_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT },
101
102 { ACTION_WPS_ID3SCREEN, BUTTON_RIGHT|BUTTON_MENU, BUTTON_NONE },
103 { ACTION_WPS_BROWSE, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT },
104
105 LAST_ITEM_IN_LIST
106}; /* button_context_wps */
107
108static const struct button_mapping button_context_list[] = {
109 { ACTION_LISTTREE_PGUP, BUTTON_RIGHT|BUTTON_UP, BUTTON_RIGHT },
110 { ACTION_LISTTREE_PGUP, BUTTON_UP|BUTTON_REL, BUTTON_RIGHT|BUTTON_UP },
111 { ACTION_LISTTREE_PGUP, BUTTON_RIGHT|BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
112 { ACTION_LISTTREE_PGDOWN, BUTTON_RIGHT|BUTTON_DOWN, BUTTON_RIGHT },
113 { ACTION_LISTTREE_PGDOWN, BUTTON_DOWN|BUTTON_REL, BUTTON_RIGHT|BUTTON_DOWN },
114 { ACTION_LISTTREE_PGDOWN, BUTTON_RIGHT|BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
115#ifdef HAVE_VOLUME_IN_LIST
116 { ACTION_LIST_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
117 { ACTION_LIST_VOLUP, BUTTON_VOL_UP, BUTTON_NONE },
118 { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE },
119 { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
120#endif
121
122 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
123}; /* button_context_list */
124
125static const struct button_mapping button_context_tree[] = {
126 { ACTION_TREE_WPS, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
127 { ACTION_TREE_STOP, BUTTON_POWER, BUTTON_NONE },
128 { ACTION_TREE_STOP, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
129 { ACTION_TREE_STOP, BUTTON_POWER|BUTTON_REPEAT, BUTTON_NONE },
130
131 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST)
132}; /* button_context_tree */
133
134static const struct button_mapping button_context_listtree_scroll_with_combo[] = {
135 { ACTION_NONE, BUTTON_RIGHT, BUTTON_NONE },
136 { ACTION_TREE_PGLEFT, BUTTON_RIGHT|BUTTON_REW, BUTTON_RIGHT },
137 { ACTION_TREE_PGLEFT, BUTTON_REW|BUTTON_REL, BUTTON_RIGHT|BUTTON_REW },
138 { ACTION_TREE_PGLEFT, BUTTON_RIGHT|BUTTON_REW, BUTTON_REW|BUTTON_REL },
139 { ACTION_TREE_ROOT_INIT, BUTTON_RIGHT|BUTTON_REW|BUTTON_REPEAT, BUTTON_RIGHT|BUTTON_REW },
140 { ACTION_TREE_PGLEFT, BUTTON_RIGHT|BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE },
141 { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_FFWD, BUTTON_RIGHT },
142 { ACTION_TREE_PGRIGHT, BUTTON_FFWD|BUTTON_REL, BUTTON_RIGHT|BUTTON_FFWD },
143 { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_FFWD, BUTTON_FFWD|BUTTON_REL },
144 { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_FFWD|BUTTON_REPEAT, BUTTON_NONE },
145 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE),
146};
147
148static const struct button_mapping button_context_listtree_scroll_without_combo[] = {
149 { ACTION_NONE, BUTTON_REW, BUTTON_NONE },
150 { ACTION_STD_CANCEL, BUTTON_REW|BUTTON_REL, BUTTON_REW },
151 { ACTION_TREE_ROOT_INIT, BUTTON_REW|BUTTON_REPEAT, BUTTON_REW },
152 { ACTION_TREE_PGLEFT, BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE },
153 { ACTION_TREE_PGLEFT, BUTTON_REW|BUTTON_REL, BUTTON_REW|BUTTON_REPEAT },
154 { ACTION_NONE, BUTTON_FFWD, BUTTON_NONE },
155 { ACTION_STD_OK, BUTTON_FFWD|BUTTON_REL, BUTTON_FFWD },
156 { ACTION_TREE_PGRIGHT, BUTTON_FFWD|BUTTON_REPEAT, BUTTON_NONE },
157 { ACTION_TREE_PGRIGHT, BUTTON_FFWD|BUTTON_REL, BUTTON_FFWD|BUTTON_REPEAT },
158 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE),
159};
160
161static const struct button_mapping button_context_settings[] = {
162 { ACTION_SETTINGS_INC, BUTTON_UP, BUTTON_NONE },
163 { ACTION_SETTINGS_INCREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
164 { ACTION_SETTINGS_DEC, BUTTON_DOWN, BUTTON_NONE },
165 { ACTION_SETTINGS_DECREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
166 { ACTION_STD_PREV, BUTTON_REW, BUTTON_NONE },
167 { ACTION_STD_PREVREPEAT, BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE },
168 { ACTION_STD_NEXT, BUTTON_FFWD, BUTTON_NONE },
169 { ACTION_STD_NEXTREPEAT, BUTTON_FFWD|BUTTON_REPEAT, BUTTON_NONE },
170 { ACTION_SETTINGS_RESET, BUTTON_RIGHT, BUTTON_NONE },
171
172 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
173}; /* button_context_settings */
174
175static const struct button_mapping button_context_settings_right_is_inc[] = {
176 { ACTION_SETTINGS_INC, BUTTON_FFWD, BUTTON_NONE },
177 { ACTION_SETTINGS_INCREPEAT, BUTTON_FFWD|BUTTON_REPEAT, BUTTON_NONE },
178 { ACTION_SETTINGS_DEC, BUTTON_REW, BUTTON_NONE },
179 { ACTION_SETTINGS_DECREPEAT, BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE },
180 { ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE },
181 { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
182 { ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE },
183 { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
184 { ACTION_SETTINGS_RESET, BUTTON_RIGHT, BUTTON_NONE },
185
186 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
187}; /* button_context_settingsgraphical */
188
189static const struct button_mapping button_context_yesno[] = {
190 { ACTION_YESNO_ACCEPT, BUTTON_SELECT, BUTTON_NONE },
191 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
192}; /* button_context_settings_yesno */
193
194static const struct button_mapping button_context_colorchooser[] = {
195 { ACTION_STD_OK, BUTTON_RIGHT|BUTTON_REL, BUTTON_NONE },
196 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_SETTINGS),
197}; /* button_context_colorchooser */
198
199static const struct button_mapping button_context_eq[] = {
200 { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_NONE },
201 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_SETTINGS),
202}; /* button_context_eq */
203
204/** Bookmark Screen **/
205static const struct button_mapping button_context_bmark[] = {
206 { ACTION_BMS_DELETE, BUTTON_RIGHT, BUTTON_NONE },
207
208 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST),
209}; /* button_context_bmark */
210
211static const struct button_mapping button_context_time[] = {
212 { ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE },
213 { ACTION_STD_OK, BUTTON_RIGHT, BUTTON_NONE },
214 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS),
215}; /* button_context_time */
216
217static const struct button_mapping button_context_quickscreen[] = {
218 { ACTION_QS_DOWNINV, BUTTON_UP, BUTTON_NONE },
219 { ACTION_QS_DOWNINV, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
220 { ACTION_QS_DOWN, BUTTON_DOWN, BUTTON_NONE },
221 { ACTION_QS_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
222 { ACTION_QS_LEFT, BUTTON_REW, BUTTON_NONE },
223 { ACTION_QS_LEFT, BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE },
224 { ACTION_QS_RIGHT, BUTTON_FFWD, BUTTON_NONE },
225 { ACTION_QS_RIGHT, BUTTON_FFWD|BUTTON_REPEAT, BUTTON_NONE },
226 { ACTION_STD_CANCEL, BUTTON_MENU, BUTTON_NONE },
227
228 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
229}; /* button_context_quickscreen */
230
231static const struct button_mapping button_context_pitchscreen[] = {
232 { ACTION_PS_INC_SMALL, BUTTON_UP, BUTTON_NONE },
233 { ACTION_PS_INC_BIG, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
234 { ACTION_PS_DEC_SMALL, BUTTON_DOWN, BUTTON_NONE },
235 { ACTION_PS_DEC_BIG, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
236 { ACTION_PS_NUDGE_LEFT, BUTTON_REW, BUTTON_NONE },
237 { ACTION_PS_NUDGE_LEFTOFF, BUTTON_REW|BUTTON_REL, BUTTON_NONE },
238 { ACTION_PS_NUDGE_RIGHT, BUTTON_FFWD, BUTTON_NONE },
239 { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_FFWD|BUTTON_REL, BUTTON_NONE },
240 { ACTION_PS_TOGGLE_MODE, BUTTON_MENU, BUTTON_NONE },
241 { ACTION_PS_RESET, BUTTON_RIGHT, BUTTON_NONE },
242 { ACTION_PS_EXIT, BUTTON_POWER, BUTTON_NONE },
243
244 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
245}; /* button_context_pitchcreen */
246
247static const struct button_mapping button_context_keyboard[] = {
248 { ACTION_KBD_LEFT, BUTTON_REW, BUTTON_NONE },
249 { ACTION_KBD_LEFT, BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE },
250 { ACTION_KBD_RIGHT, BUTTON_FFWD, BUTTON_NONE },
251 { ACTION_KBD_RIGHT, BUTTON_FFWD|BUTTON_REPEAT, BUTTON_NONE },
252 { ACTION_KBD_CURSOR_LEFT, BUTTON_RIGHT|BUTTON_REW, BUTTON_NONE },
253 { ACTION_KBD_CURSOR_LEFT, BUTTON_RIGHT|BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE },
254 { ACTION_KBD_CURSOR_RIGHT, BUTTON_RIGHT|BUTTON_FFWD, BUTTON_NONE },
255 { ACTION_KBD_CURSOR_RIGHT, BUTTON_RIGHT|BUTTON_FFWD|BUTTON_REPEAT, BUTTON_NONE },
256 { ACTION_KBD_SELECT, BUTTON_SELECT, BUTTON_NONE },
257 { ACTION_KBD_PAGE_FLIP, BUTTON_RIGHT|BUTTON_MENU, BUTTON_NONE },
258 { ACTION_KBD_DONE, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
259 { ACTION_KBD_ABORT, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
260 { ACTION_KBD_BACKSPACE, BUTTON_MENU, BUTTON_NONE },
261 { ACTION_KBD_BACKSPACE, BUTTON_MENU|BUTTON_REPEAT, BUTTON_NONE },
262 { ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE },
263 { ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
264 { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE },
265 { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
266 { ACTION_KBD_MORSE_INPUT, BUTTON_RIGHT|BUTTON_POWER, BUTTON_NONE },
267 { ACTION_KBD_MORSE_SELECT, BUTTON_SELECT|BUTTON_REL, BUTTON_NONE },
268
269 LAST_ITEM_IN_LIST
270}; /* button_context_keyboard */
271
272const struct button_mapping* get_context_mapping(int context)
273{
274 switch (context)
275 {
276 case CONTEXT_STD:
277 return button_context_standard;
278 case CONTEXT_WPS:
279 return button_context_wps;
280
281 case CONTEXT_LIST:
282 return button_context_list;
283 case CONTEXT_MAINMENU:
284 case CONTEXT_TREE:
285 if (global_settings.hold_lr_for_scroll_in_list)
286 return button_context_listtree_scroll_without_combo;
287 else
288 return button_context_listtree_scroll_with_combo;
289 case CONTEXT_CUSTOM|CONTEXT_TREE:
290 return button_context_tree;
291
292 case CONTEXT_SETTINGS:
293 return button_context_settings;
294 case CONTEXT_CUSTOM|CONTEXT_SETTINGS:
295 return button_context_settings_right_is_inc;
296
297 case CONTEXT_SETTINGS_COLOURCHOOSER:
298 return button_context_colorchooser;
299 case CONTEXT_SETTINGS_EQ:
300 return button_context_eq;
301
302 case CONTEXT_SETTINGS_TIME:
303 return button_context_time;
304
305 case CONTEXT_YESNOSCREEN:
306 return button_context_yesno;
307 case CONTEXT_BOOKMARKSCREEN:
308 return button_context_bmark;
309 case CONTEXT_QUICKSCREEN:
310 return button_context_quickscreen;
311 case CONTEXT_PITCHSCREEN:
312 return button_context_pitchscreen;
313 case CONTEXT_KEYBOARD:
314 return button_context_keyboard;
315 }
316 return button_context_standard;
317}