Meizu M6SP: initial LCD driver (compiles but is untested)
[kugel-rb.git] / apps / keymaps / keymap-ipod.c
blob83f46e6575e43430c025ee4b021499033344c8c4
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 Jonathan Gordon
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 /* Button Code Definitions for ipod target */
24 #include "config.h"
25 #include "action.h"
26 #include "button.h"
27 #include "settings.h"
29 /*
30 * The format of the list is as follows
31 * { Action Code, Button code, Prereq button code }
32 * if there's no need to check the previous button's value, use BUTTON_NONE
33 * Insert LAST_ITEM_IN_LIST at the end of each mapping
36 /* CONTEXT_CUSTOM's used in this file...
38 CONTEXT_CUSTOM|CONTEXT_TREE = the standard list/tree defines (without directions)
43 static const struct button_mapping button_context_standard[] = {
44 { ACTION_STD_PREV, BUTTON_SCROLL_BACK, BUTTON_NONE },
45 { ACTION_STD_PREVREPEAT, BUTTON_SCROLL_BACK|BUTTON_REPEAT, BUTTON_NONE },
46 { ACTION_STD_NEXT, BUTTON_SCROLL_FWD, BUTTON_NONE },
47 { ACTION_STD_NEXTREPEAT, BUTTON_SCROLL_FWD|BUTTON_REPEAT, BUTTON_NONE },
48 { ACTION_STD_CANCEL, BUTTON_LEFT, BUTTON_NONE },
49 { ACTION_STD_OK, BUTTON_RIGHT, BUTTON_NONE },
51 { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT },
52 { ACTION_STD_MENU, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
53 { ACTION_STD_QUICKSCREEN, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU },
54 { ACTION_STD_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT },
55 { ACTION_STD_CANCEL, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE },
57 LAST_ITEM_IN_LIST
58 }; /* button_context_standard */
59 static const struct button_mapping button_context_tree[] = {
60 { ACTION_TREE_WPS, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
61 { ACTION_TREE_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
63 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
64 }; /* button_context_tree */
66 static const struct button_mapping button_context_tree_scroll_lr[] = {
67 { ACTION_NONE, BUTTON_LEFT, BUTTON_NONE },
68 { ACTION_STD_CANCEL, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT },
69 { ACTION_TREE_ROOT_INIT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT },
70 { ACTION_TREE_PGLEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
71 { ACTION_TREE_PGLEFT, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT|BUTTON_REPEAT },
72 { ACTION_NONE, BUTTON_RIGHT, BUTTON_NONE },
73 { ACTION_STD_OK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
74 { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
75 { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT },
76 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE),
79 static const struct button_mapping button_context_wps[] = {
80 { ACTION_WPS_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
81 { ACTION_WPS_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
82 { ACTION_WPS_SKIPPREV, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT },
83 { ACTION_WPS_SEEKBACK, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
84 { ACTION_WPS_STOPSEEK, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT|BUTTON_REPEAT },
85 { ACTION_WPS_SKIPNEXT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
86 { ACTION_WPS_SEEKFWD, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
87 { ACTION_WPS_STOPSEEK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT },
88 { ACTION_WPS_VOLDOWN, BUTTON_SCROLL_BACK, BUTTON_NONE },
89 { ACTION_WPS_VOLDOWN, BUTTON_SCROLL_BACK|BUTTON_REPEAT, BUTTON_NONE },
90 { ACTION_WPS_VOLUP, BUTTON_SCROLL_FWD, BUTTON_NONE },
91 { ACTION_WPS_VOLUP, BUTTON_SCROLL_FWD|BUTTON_REPEAT, BUTTON_NONE },
92 { ACTION_WPS_BROWSE, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT },
93 { ACTION_WPS_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT },
94 { ACTION_WPS_VIEW_PLAYLIST, BUTTON_SELECT|BUTTON_PLAY, BUTTON_NONE },
95 { ACTION_WPS_MENU, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
96 { ACTION_WPS_QUICKSCREEN, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU },
98 LAST_ITEM_IN_LIST,
99 }; /* button_context_wps */
101 static const struct button_mapping button_context_settings[] = {
102 { ACTION_SETTINGS_INC, BUTTON_SCROLL_FWD, BUTTON_NONE },
103 { ACTION_SETTINGS_INCREPEAT, BUTTON_SCROLL_FWD|BUTTON_REPEAT, BUTTON_NONE },
104 { ACTION_SETTINGS_DEC, BUTTON_SCROLL_BACK, BUTTON_NONE },
105 { ACTION_SETTINGS_DECREPEAT, BUTTON_SCROLL_BACK|BUTTON_REPEAT, BUTTON_NONE },
106 { ACTION_STD_PREV, BUTTON_LEFT, BUTTON_NONE },
107 { ACTION_STD_PREVREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
108 { ACTION_STD_NEXT, BUTTON_RIGHT, BUTTON_NONE },
109 { ACTION_STD_NEXTREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
110 { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_NONE },
111 { ACTION_STD_CANCEL, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
113 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
114 }; /* button_context_settings */
116 static const struct button_mapping button_context_yesno[] = {
117 { ACTION_YESNO_ACCEPT, BUTTON_SELECT, BUTTON_NONE },
118 LAST_ITEM_IN_LIST
119 }; /* button_context_settings_yesno */
121 static const struct button_mapping button_context_bmark[] = {
122 { ACTION_BMS_DELETE, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU },
123 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST),
124 }; /* button_context_settings_bmark */
126 static const struct button_mapping button_context_quickscreen[] = {
127 { ACTION_QS_DOWN, BUTTON_PLAY, BUTTON_NONE },
128 { ACTION_QS_DOWN, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE },
129 { ACTION_QS_LEFT, BUTTON_LEFT, BUTTON_NONE },
130 { ACTION_QS_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
131 { ACTION_QS_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
132 { ACTION_QS_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
133 { ACTION_STD_CANCEL, BUTTON_MENU, BUTTON_NONE },
135 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
136 }; /* button_context_quickscreen */
138 static const struct button_mapping button_context_pitchscreen[] = {
139 { ACTION_PS_INC_SMALL, BUTTON_SCROLL_FWD, BUTTON_NONE },
140 { ACTION_PS_INC_BIG, BUTTON_SCROLL_FWD|BUTTON_REPEAT, BUTTON_NONE },
141 { ACTION_PS_DEC_SMALL, BUTTON_SCROLL_BACK, BUTTON_NONE },
142 { ACTION_PS_DEC_BIG, BUTTON_SCROLL_BACK|BUTTON_REPEAT, BUTTON_NONE },
143 { ACTION_PS_NUDGE_LEFT, BUTTON_LEFT, BUTTON_NONE },
144 { ACTION_PS_NUDGE_LEFTOFF, BUTTON_LEFT|BUTTON_REL, BUTTON_NONE },
145 { ACTION_PS_NUDGE_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
146 { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_RIGHT|BUTTON_REL, BUTTON_NONE },
147 { ACTION_PS_TOGGLE_MODE, BUTTON_PLAY, BUTTON_NONE },
148 { ACTION_PS_RESET, BUTTON_MENU, BUTTON_NONE },
149 { ACTION_PS_EXIT, BUTTON_SELECT, BUTTON_NONE },
150 { ACTION_PS_SLOWER, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
151 { ACTION_PS_FASTER, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
153 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
154 }; /* button_context_pitchscreen */
156 static const struct button_mapping button_context_keyboard[] = {
157 { ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE },
158 { ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
159 { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
160 { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
161 { ACTION_KBD_SELECT, BUTTON_SELECT, BUTTON_NONE },
162 { ACTION_KBD_DONE, BUTTON_PLAY, BUTTON_NONE },
163 { ACTION_KBD_ABORT, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
164 { ACTION_KBD_UP, BUTTON_SCROLL_BACK, BUTTON_NONE },
165 { ACTION_KBD_UP, BUTTON_SCROLL_BACK|BUTTON_REPEAT, BUTTON_NONE },
166 { ACTION_KBD_DOWN, BUTTON_SCROLL_FWD, BUTTON_NONE },
167 { ACTION_KBD_DOWN, BUTTON_SCROLL_FWD|BUTTON_REPEAT, BUTTON_NONE },
168 { ACTION_KBD_MORSE_INPUT, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU },
169 { ACTION_KBD_MORSE_SELECT, BUTTON_SELECT|BUTTON_REL, BUTTON_NONE },
170 LAST_ITEM_IN_LIST
171 }; /* button_context_keyboard */
173 #ifdef HAVE_RECORDING
174 const struct button_mapping button_context_recscreen[] = {
176 { ACTION_REC_NEWFILE, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT },
177 { ACTION_STD_MENU, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT },
178 { ACTION_REC_PAUSE, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
179 { ACTION_STD_CANCEL, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE },
180 { ACTION_STD_CANCEL, BUTTON_MENU, BUTTON_NONE },
181 { ACTION_STD_NEXT, BUTTON_SCROLL_FWD, BUTTON_NONE },
182 { ACTION_STD_NEXT, BUTTON_SCROLL_FWD|BUTTON_REPEAT, BUTTON_NONE },
183 { ACTION_STD_PREV, BUTTON_SCROLL_BACK, BUTTON_NONE },
184 { ACTION_STD_PREV, BUTTON_SCROLL_BACK|BUTTON_REPEAT, BUTTON_NONE },
185 { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE },
186 { ACTION_SETTINGS_INCREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
187 { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE },
188 { ACTION_SETTINGS_DECREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
190 LAST_ITEM_IN_LIST
191 }; /* button_context_recscreen */
192 #endif
194 #ifdef HAVE_USBSTACK
195 static const struct button_mapping button_context_usb_hid[] = {
196 { ACTION_USB_HID_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
197 { ACTION_USB_HID_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
198 { ACTION_USB_HID_SKIPPREV, BUTTON_LEFT, BUTTON_NONE },
199 { ACTION_USB_HID_SKIPNEXT, BUTTON_RIGHT, BUTTON_NONE },
200 { ACTION_USB_HID_VOLUP, BUTTON_SCROLL_FWD, BUTTON_NONE },
201 { ACTION_USB_HID_VOLUP, BUTTON_SCROLL_FWD|BUTTON_REPEAT, BUTTON_NONE },
202 { ACTION_USB_HID_VOLDOWN, BUTTON_SCROLL_BACK, BUTTON_NONE },
203 { ACTION_USB_HID_VOLDOWN, BUTTON_SCROLL_BACK|BUTTON_REPEAT, BUTTON_NONE },
204 { ACTION_USB_HID_MUTE, BUTTON_SELECT, BUTTON_NONE },
205 { ACTION_USB_HID_MENU, BUTTON_MENU, BUTTON_NONE },
207 LAST_ITEM_IN_LIST
208 }; /* button_context_usb_hid */
209 #endif
211 #if BUTTON_REMOTE != 0
212 /*****************************************************************************
213 * Remote control mappings
214 *****************************************************************************/
216 static const struct button_mapping remote_button_context_standard[] = {
217 { ACTION_STD_PREV, BUTTON_RC_LEFT, BUTTON_NONE },
218 { ACTION_STD_NEXT, BUTTON_RC_RIGHT, BUTTON_NONE },
219 { ACTION_STD_CANCEL, BUTTON_RC_STOP, BUTTON_NONE },
220 { ACTION_STD_OK, BUTTON_RC_PLAY, BUTTON_NONE },
222 LAST_ITEM_IN_LIST
225 static const struct button_mapping remote_button_context_wps[] = {
226 { ACTION_WPS_VOLDOWN, BUTTON_RC_VOL_DOWN, BUTTON_NONE },
227 { ACTION_WPS_VOLDOWN, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
228 { ACTION_WPS_VOLUP, BUTTON_RC_VOL_UP, BUTTON_NONE },
229 { ACTION_WPS_VOLUP, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
231 { ACTION_WPS_PLAY, BUTTON_RC_PLAY|BUTTON_REL, BUTTON_RC_PLAY },
232 { ACTION_WPS_STOP, BUTTON_RC_PLAY|BUTTON_REPEAT, BUTTON_NONE },
233 { ACTION_WPS_SKIPNEXT, BUTTON_RC_RIGHT|BUTTON_REL, BUTTON_RC_RIGHT },
234 { ACTION_WPS_SEEKFWD, BUTTON_RC_RIGHT|BUTTON_REPEAT,BUTTON_NONE },
235 { ACTION_WPS_STOPSEEK, BUTTON_RC_RIGHT|BUTTON_REL, BUTTON_RC_RIGHT|BUTTON_REPEAT },
236 { ACTION_WPS_SKIPPREV, BUTTON_RC_LEFT|BUTTON_REL, BUTTON_RC_LEFT },
237 { ACTION_WPS_SEEKBACK, BUTTON_RC_LEFT|BUTTON_REPEAT, BUTTON_NONE },
238 { ACTION_WPS_STOPSEEK, BUTTON_RC_LEFT|BUTTON_REL, BUTTON_RC_LEFT|BUTTON_REPEAT },
240 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
243 #ifdef HAVE_USBSTACK
244 static const struct button_mapping remote_button_context_usb_hid[] = {
245 { ACTION_USB_HID_PLAY, BUTTON_RC_PLAY, BUTTON_NONE },
246 { ACTION_USB_HID_STOP, BUTTON_RC_PLAY|BUTTON_REPEAT, BUTTON_NONE },
247 { ACTION_USB_HID_SKIPPREV, BUTTON_RC_LEFT, BUTTON_NONE },
248 { ACTION_USB_HID_SKIPNEXT, BUTTON_RC_RIGHT, BUTTON_NONE },
249 { ACTION_USB_HID_VOLUP, BUTTON_RC_VOL_UP, BUTTON_NONE },
250 { ACTION_USB_HID_VOLUP, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
251 { ACTION_USB_HID_VOLDOWN, BUTTON_RC_VOL_DOWN, BUTTON_NONE },
252 { ACTION_USB_HID_VOLDOWN, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
254 LAST_ITEM_IN_LIST
255 }; /* remote_button_context_usb_hid */
256 #endif
258 static const struct button_mapping* get_context_mapping_remote( int context )
260 context ^= CONTEXT_REMOTE;
262 switch (context)
264 case CONTEXT_WPS:
265 return remote_button_context_wps;
266 #ifdef HAVE_USBSTACK
267 case CONTEXT_USB_HID:
268 return remote_button_context_usb_hid;
269 #endif
270 default:
271 return remote_button_context_standard;
274 #endif /* BUTTON_REMOTE != 0 */
276 /* get_context_mapping returns a pointer to one of the above defined arrays depending on the context */
277 const struct button_mapping* get_context_mapping(int context)
279 #if BUTTON_REMOTE != 0
280 if (context&CONTEXT_REMOTE)
281 return get_context_mapping_remote(context);
282 #endif
284 switch (context)
286 case CONTEXT_STD:
287 return button_context_standard;
288 case CONTEXT_WPS:
289 return button_context_wps;
291 case CONTEXT_TREE:
292 case CONTEXT_MAINMENU:
293 if (global_settings.hold_lr_for_scroll_in_list)
294 return button_context_tree_scroll_lr;
295 /* else fall through to CUSTOM|CONTEXT_TREE */
296 case CONTEXT_CUSTOM|CONTEXT_TREE:
297 return button_context_tree;
299 case CONTEXT_LIST:
300 return button_context_standard;
302 case CONTEXT_SETTINGS_EQ:
303 case CONTEXT_SETTINGS_COLOURCHOOSER:
304 case CONTEXT_SETTINGS_TIME:
305 case CONTEXT_SETTINGS:
306 case CONTEXT_SETTINGS_RECTRIGGER:
307 return button_context_settings;
308 case CONTEXT_YESNOSCREEN:
309 return button_context_yesno;
310 case CONTEXT_BOOKMARKSCREEN:
311 return button_context_bmark;
312 case CONTEXT_QUICKSCREEN:
313 return button_context_quickscreen;
314 case CONTEXT_PITCHSCREEN:
315 return button_context_pitchscreen;
316 case CONTEXT_KEYBOARD:
317 return button_context_keyboard;
318 #ifdef HAVE_RECORDING
319 case CONTEXT_RECSCREEN:
320 return button_context_recscreen;
321 #endif
322 #ifdef HAVE_USBSTACK
323 case CONTEXT_USB_HID:
324 return button_context_usb_hid;
325 #endif
326 default:
327 return button_context_standard;
329 return button_context_standard;