Shut down Pandora on push of pandoara button
[maemo-rb.git] / apps / keymaps / keymap-ondio.c
blob7724714d5a717810bcba008c243b1ff2607cb17d
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 /* *
23 * Button Code Definitions for archos ondio fm/sp targets
26 #include "config.h"
27 #include "action.h"
28 #include "button.h"
29 #include "settings.h"
31 /* CONTEXT_CUSTOM's used in this file...
33 CONTEXT_CUSTOM|CONTEXT_TREE = the standard list/tree defines (without directions)
38 static const struct button_mapping button_context_standard[] = {
39 { ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE },
40 { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
41 { ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE },
42 { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
44 { ACTION_STD_CONTEXT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_RIGHT },
45 { ACTION_STD_CANCEL, BUTTON_LEFT, BUTTON_NONE },
46 { ACTION_STD_OK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
47 { ACTION_STD_MENU, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU },
48 { ACTION_STD_CANCEL, BUTTON_OFF, BUTTON_NONE },
50 LAST_ITEM_IN_LIST
53 static const struct button_mapping button_context_wps[] = {
54 { ACTION_WPS_PLAY, BUTTON_OFF|BUTTON_REL, BUTTON_OFF },
55 { ACTION_WPS_SKIPNEXT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
56 { ACTION_WPS_SKIPPREV, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT },
57 { ACTION_WPS_SEEKBACK, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
58 { ACTION_WPS_SEEKFWD, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
59 { ACTION_WPS_STOPSEEK, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT|BUTTON_REPEAT },
60 { ACTION_WPS_STOPSEEK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT },
61 { ACTION_WPS_STOP, BUTTON_OFF|BUTTON_REPEAT, BUTTON_OFF },
62 { ACTION_WPS_VOLDOWN, BUTTON_DOWN, BUTTON_NONE },
63 { ACTION_WPS_VOLDOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
64 { ACTION_WPS_VOLUP, BUTTON_UP, BUTTON_NONE },
65 { ACTION_WPS_VOLUP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
66 { ACTION_WPS_BROWSE, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
67 { ACTION_WPS_CONTEXT, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU },
68 /* { ACTION_WPS_MENU, BUTTON_NONE, BUTTON_NONE }, we can't have that */
69 { ACTION_STD_KEYLOCK, BUTTON_MENU|BUTTON_DOWN, BUTTON_NONE },
70 /* { ACTION_WPS_VIEW_PLAYLIST,BUTTON_NONE, BUTTON_NONE }, can't have this either */
72 LAST_ITEM_IN_LIST
75 static const struct button_mapping button_context_settings[] = {
76 { ACTION_SETTINGS_INC, BUTTON_UP, BUTTON_NONE },
77 { ACTION_SETTINGS_INCREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
78 { ACTION_SETTINGS_DEC, BUTTON_DOWN, BUTTON_NONE },
79 { ACTION_SETTINGS_DECREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
80 { ACTION_STD_OK, BUTTON_RIGHT, BUTTON_NONE },
81 { ACTION_STD_OK, BUTTON_LEFT, BUTTON_NONE },
82 { ACTION_STD_CANCEL, BUTTON_MENU, BUTTON_NONE },
84 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
87 static const struct button_mapping button_context_tree[] = {
88 { ACTION_TREE_WPS, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
89 { ACTION_TREE_STOP, BUTTON_OFF, BUTTON_NONE },
90 { ACTION_STD_CANCEL, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
92 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
93 }; /* button_context_listtree */
95 static const struct button_mapping button_context_tree_scroll_lr[] = {
96 { ACTION_NONE, BUTTON_LEFT, BUTTON_NONE },
97 { ACTION_STD_CANCEL, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT },
98 { ACTION_TREE_PGLEFT, BUTTON_MENU|BUTTON_LEFT, BUTTON_NONE },
99 { ACTION_TREE_ROOT_INIT, BUTTON_MENU|BUTTON_LEFT|BUTTON_REPEAT, BUTTON_MENU|BUTTON_LEFT },
100 { ACTION_TREE_PGLEFT, BUTTON_MENU|BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
101 { ACTION_NONE, BUTTON_RIGHT, BUTTON_NONE },
102 { ACTION_STD_OK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
103 { ACTION_TREE_PGRIGHT, BUTTON_MENU|BUTTON_RIGHT, BUTTON_NONE },
104 { ACTION_TREE_PGRIGHT, BUTTON_MENU|BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
106 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE),
109 static const struct button_mapping button_context_yesno[] = {
110 { ACTION_YESNO_ACCEPT, BUTTON_RIGHT, BUTTON_NONE },
112 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
115 static const struct button_mapping button_context_bmark[] = {
116 { ACTION_NONE, BUTTON_LEFT, BUTTON_NONE },
117 { ACTION_BMS_DELETE, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT },
119 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST),
120 }; /* button_context_settings_bmark */
122 static const struct button_mapping button_context_pitchscreen[] = {
123 { ACTION_PS_INC_SMALL, BUTTON_UP, BUTTON_NONE },
124 { ACTION_PS_INC_BIG, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
125 { ACTION_PS_DEC_SMALL, BUTTON_DOWN, BUTTON_NONE },
126 { ACTION_PS_DEC_BIG, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
127 { ACTION_PS_NUDGE_LEFT, BUTTON_LEFT, BUTTON_NONE },
128 { ACTION_PS_NUDGE_LEFTOFF, BUTTON_LEFT|BUTTON_REL, BUTTON_NONE },
129 { ACTION_PS_NUDGE_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
130 { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_RIGHT|BUTTON_REL, BUTTON_NONE },
131 { ACTION_PS_TOGGLE_MODE, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU },
132 { ACTION_PS_RESET, BUTTON_MENU, BUTTON_NONE },
133 { ACTION_PS_EXIT, BUTTON_OFF, BUTTON_NONE },
135 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
136 }; /* button_context_pitchscreen */
138 #ifdef HAVE_RECORDING
139 static const struct button_mapping button_context_rectrigger[] = {
140 { ACTION_STD_OK, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
141 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_RECSCREEN)
143 static const struct button_mapping button_context_recscreen[] = {
144 { ACTION_REC_PAUSE, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
145 { ACTION_SETTINGS_INC, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
146 { ACTION_SETTINGS_INCREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
147 { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE },
148 { ACTION_SETTINGS_DECREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
150 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
151 }; /* button_context_recscreen */
152 #endif /* HAVE_RECORDING */
154 static const struct button_mapping button_context_keyboard[] = {
155 { ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE },
156 { ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
157 { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
158 { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
159 { ACTION_KBD_SELECT, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
160 { ACTION_KBD_DONE, BUTTON_MENU|BUTTON_REPEAT, BUTTON_NONE },
161 { ACTION_KBD_ABORT, BUTTON_OFF, BUTTON_NONE },
162 { ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE },
163 { ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
164 { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE },
165 { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
167 LAST_ITEM_IN_LIST
168 }; /* button_context_keyboard */
170 static const struct button_mapping button_context_morse_input[] = {
171 { ACTION_KBD_CURSOR_LEFT, BUTTON_LEFT, BUTTON_NONE },
172 { ACTION_KBD_CURSOR_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
173 { ACTION_KBD_CURSOR_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
174 { ACTION_KBD_CURSOR_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
175 { ACTION_KBD_BACKSPACE, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
176 { ACTION_KBD_DONE, BUTTON_MENU|BUTTON_REPEAT, BUTTON_NONE },
177 { ACTION_KBD_ABORT, BUTTON_OFF, BUTTON_NONE },
178 { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE },
179 { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
180 { ACTION_KBD_SELECT, BUTTON_UP, BUTTON_NONE },
181 { ACTION_KBD_MORSE_SELECT, BUTTON_UP|BUTTON_REL, BUTTON_NONE },
183 LAST_ITEM_IN_LIST
184 }; /* button_context_morse_input */
186 #if CONFIG_TUNER
187 static const struct button_mapping button_context_radio[] = {
188 { ACTION_FM_MENU, BUTTON_MENU | BUTTON_REPEAT, BUTTON_NONE },
189 { ACTION_FM_RECORD_DBLPRE, BUTTON_MENU, BUTTON_NONE},
190 { ACTION_FM_RECORD, BUTTON_MENU | BUTTON_REL, BUTTON_NONE },
191 { ACTION_FM_STOP, BUTTON_OFF | BUTTON_REPEAT, BUTTON_OFF },
192 { ACTION_FM_EXIT, BUTTON_OFF | BUTTON_REL, BUTTON_OFF },
193 { ACTION_STD_PREV, BUTTON_LEFT, BUTTON_NONE },
194 { ACTION_STD_PREVREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
195 { ACTION_STD_NEXT, BUTTON_RIGHT, BUTTON_NONE },
196 { ACTION_STD_NEXTREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
200 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
203 #endif
205 const struct button_mapping* get_context_mapping( int context )
207 switch( context )
209 case CONTEXT_STD:
210 return button_context_standard;
212 case CONTEXT_WPS:
213 return button_context_wps;
215 case CONTEXT_SETTINGS:
216 return button_context_settings;
218 case CONTEXT_YESNOSCREEN:
219 return button_context_yesno;
221 case CONTEXT_BOOKMARKSCREEN:
222 return button_context_bmark;
223 case CONTEXT_PITCHSCREEN:
224 return button_context_pitchscreen;
225 case CONTEXT_TREE:
226 case CONTEXT_MAINMENU:
227 if (global_settings.hold_lr_for_scroll_in_list)
228 return button_context_tree_scroll_lr;
229 /* else fall through to CUSTOM|CONTEXT_TREE */
230 case CONTEXT_CUSTOM|CONTEXT_TREE:
231 return button_context_tree;
232 #ifdef HAVE_RECORDING
233 case CONTEXT_RECSCREEN:
234 return button_context_recscreen;
235 case CONTEXT_SETTINGS_RECTRIGGER:
236 return button_context_rectrigger;
237 #endif
238 case CONTEXT_KEYBOARD:
239 return button_context_keyboard;
240 case CONTEXT_MORSE_INPUT:
241 return button_context_morse_input;
242 #if CONFIG_TUNER
243 case CONTEXT_FM:
244 return button_context_radio;
245 #endif
246 case CONTEXT_LIST:
247 default:
248 return button_context_standard;