fix pitch_detector: recording will stop itself if the callback returns <0
[kugel-rb.git] / apps / keymaps / keymap-ondio.c
blob45938138edf6981ab23f88b15dd7684b0cdb3179
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_TREE_PGLEFT, BUTTON_MENU|BUTTON_RIGHT|BUTTON_REL, BUTTON_MENU|BUTTON_RIGHT|BUTTON_REPEAT },
102 { ACTION_NONE, BUTTON_RIGHT, BUTTON_NONE },
103 { ACTION_STD_OK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
104 { ACTION_TREE_PGRIGHT, BUTTON_MENU|BUTTON_RIGHT, BUTTON_NONE },
105 { ACTION_TREE_PGRIGHT, BUTTON_MENU|BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
106 { ACTION_TREE_PGRIGHT, BUTTON_MENU|BUTTON_RIGHT|BUTTON_REL, BUTTON_MENU|BUTTON_RIGHT|BUTTON_REPEAT },
108 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE),
111 static const struct button_mapping button_context_yesno[] = {
112 { ACTION_YESNO_ACCEPT, BUTTON_RIGHT, BUTTON_NONE },
114 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
117 static const struct button_mapping button_context_bmark[] = {
118 { ACTION_NONE, BUTTON_LEFT, BUTTON_NONE },
119 { ACTION_BMS_DELETE, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT },
121 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST),
122 }; /* button_context_settings_bmark */
124 static const struct button_mapping button_context_pitchscreen[] = {
125 { ACTION_PS_INC_SMALL, BUTTON_UP, BUTTON_NONE },
126 { ACTION_PS_INC_BIG, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
127 { ACTION_PS_DEC_SMALL, BUTTON_DOWN, BUTTON_NONE },
128 { ACTION_PS_DEC_BIG, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
129 { ACTION_PS_NUDGE_LEFT, BUTTON_LEFT, BUTTON_NONE },
130 { ACTION_PS_NUDGE_LEFTOFF, BUTTON_LEFT|BUTTON_REL, BUTTON_NONE },
131 { ACTION_PS_NUDGE_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
132 { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_RIGHT|BUTTON_REL, BUTTON_NONE },
133 { ACTION_PS_TOGGLE_MODE, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU },
134 { ACTION_PS_RESET, BUTTON_MENU, BUTTON_NONE },
135 { ACTION_PS_EXIT, BUTTON_OFF, BUTTON_NONE },
137 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
138 }; /* button_context_pitchscreen */
140 #ifdef HAVE_RECORDING
141 static const struct button_mapping button_context_rectrigger[] = {
142 { ACTION_STD_OK, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
143 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_RECSCREEN)
145 static const struct button_mapping button_context_recscreen[] = {
146 { ACTION_REC_PAUSE, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
147 { ACTION_SETTINGS_INC, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
148 { ACTION_SETTINGS_INCREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
149 { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE },
150 { ACTION_SETTINGS_DECREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
152 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
153 }; /* button_context_recscreen */
154 #endif /* HAVE_RECORDING */
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_MENU|BUTTON_REL, BUTTON_MENU },
162 { ACTION_KBD_DONE, BUTTON_MENU|BUTTON_REPEAT, BUTTON_NONE },
163 { ACTION_KBD_ABORT, BUTTON_OFF, BUTTON_NONE },
164 { ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE },
165 { ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
166 { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE },
167 { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
169 LAST_ITEM_IN_LIST
170 }; /* button_context_keyboard */
172 static const struct button_mapping button_context_morse_input[] = {
173 { ACTION_KBD_CURSOR_LEFT, BUTTON_LEFT, BUTTON_NONE },
174 { ACTION_KBD_CURSOR_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
175 { ACTION_KBD_CURSOR_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
176 { ACTION_KBD_CURSOR_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
177 { ACTION_KBD_BACKSPACE, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
178 { ACTION_KBD_DONE, BUTTON_MENU|BUTTON_REPEAT, BUTTON_NONE },
179 { ACTION_KBD_ABORT, BUTTON_OFF, BUTTON_NONE },
180 { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE },
181 { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
182 { ACTION_KBD_SELECT, BUTTON_UP, BUTTON_NONE },
183 { ACTION_KBD_MORSE_SELECT, BUTTON_UP|BUTTON_REL, BUTTON_NONE },
185 LAST_ITEM_IN_LIST
186 }; /* button_context_morse_input */
188 #if CONFIG_TUNER
189 static const struct button_mapping button_context_radio[] = {
190 { ACTION_FM_MENU, BUTTON_MENU | BUTTON_REPEAT, BUTTON_NONE },
191 { ACTION_FM_RECORD_DBLPRE, BUTTON_MENU, BUTTON_NONE},
192 { ACTION_FM_RECORD, BUTTON_MENU | BUTTON_REL, BUTTON_NONE },
193 { ACTION_FM_STOP, BUTTON_OFF | BUTTON_REPEAT, BUTTON_OFF },
194 { ACTION_FM_EXIT, BUTTON_OFF | BUTTON_REL, BUTTON_OFF },
195 { ACTION_STD_PREV, BUTTON_LEFT, BUTTON_NONE },
196 { ACTION_STD_PREVREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
197 { ACTION_STD_NEXT, BUTTON_RIGHT, BUTTON_NONE },
198 { ACTION_STD_NEXTREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
202 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
205 #endif
207 const struct button_mapping* get_context_mapping( int context )
209 switch( context )
211 case CONTEXT_STD:
212 return button_context_standard;
214 case CONTEXT_WPS:
215 return button_context_wps;
217 case CONTEXT_SETTINGS:
218 return button_context_settings;
220 case CONTEXT_YESNOSCREEN:
221 return button_context_yesno;
223 case CONTEXT_BOOKMARKSCREEN:
224 return button_context_bmark;
225 case CONTEXT_PITCHSCREEN:
226 return button_context_pitchscreen;
227 case CONTEXT_TREE:
228 case CONTEXT_MAINMENU:
229 if (global_settings.hold_lr_for_scroll_in_list)
230 return button_context_tree_scroll_lr;
231 /* else fall through to CUSTOM|CONTEXT_TREE */
232 case CONTEXT_CUSTOM|CONTEXT_TREE:
233 return button_context_tree;
234 #ifdef HAVE_RECORDING
235 case CONTEXT_RECSCREEN:
236 return button_context_recscreen;
237 case CONTEXT_SETTINGS_RECTRIGGER:
238 return button_context_rectrigger;
239 #endif
240 case CONTEXT_KEYBOARD:
241 return button_context_keyboard;
242 case CONTEXT_MORSE_INPUT:
243 return button_context_morse_input;
244 #if CONFIG_TUNER
245 case CONTEXT_FM:
246 return button_context_radio;
247 #endif
248 case CONTEXT_LIST:
249 default:
250 return button_context_standard;