diff options
Diffstat (limited to 'apps/keymaps/keymap-zenxfi3.c')
-rw-r--r-- | apps/keymaps/keymap-zenxfi3.c | 327 |
1 files changed, 327 insertions, 0 deletions
diff --git a/apps/keymaps/keymap-zenxfi3.c b/apps/keymaps/keymap-zenxfi3.c new file mode 100644 index 0000000000..1a9be54a06 --- /dev/null +++ b/apps/keymaps/keymap-zenxfi3.c | |||
@@ -0,0 +1,327 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2012 Amaury Pouly | ||
11 | * | ||
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. | ||
16 | * | ||
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 Creative ZEN X-Fi3 target */ | ||
23 | |||
24 | #include <stdio.h> | ||
25 | #include <string.h> | ||
26 | #include <stdlib.h> | ||
27 | |||
28 | #include "config.h" | ||
29 | #include "action.h" | ||
30 | #include "button.h" | ||
31 | #include "settings.h" | ||
32 | |||
33 | /* | ||
34 | * The format of the list is as follows | ||
35 | * { Action Code, Button code, Prereq button code } | ||
36 | * if there's no need to check the previous button's value, use BUTTON_NONE | ||
37 | * Insert LAST_ITEM_IN_LIST at the end of each mapping | ||
38 | */ | ||
39 | |||
40 | static const struct button_mapping button_context_standard[] = { | ||
41 | { ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE }, | ||
42 | { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, | ||
43 | { ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE }, | ||
44 | { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, | ||
45 | |||
46 | { ACTION_STD_CONTEXT, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU }, | ||
47 | |||
48 | { ACTION_STD_CANCEL, BUTTON_LEFT, BUTTON_NONE }, | ||
49 | { ACTION_STD_CANCEL, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, | ||
50 | { ACTION_STD_OK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT }, | ||
51 | |||
52 | { ACTION_STD_KEYLOCK, BUTTON_POWER, BUTTON_NONE }, | ||
53 | |||
54 | LAST_ITEM_IN_LIST | ||
55 | }; /* button_context_standard */ | ||
56 | |||
57 | static const struct button_mapping button_context_wps[] = { | ||
58 | { ACTION_WPS_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, | ||
59 | { ACTION_WPS_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE }, | ||
60 | |||
61 | { ACTION_WPS_SKIPNEXT, BUTTON_DOWN|BUTTON_REL, BUTTON_DOWN }, | ||
62 | { ACTION_WPS_SEEKFWD, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, | ||
63 | { ACTION_WPS_SKIPPREV, BUTTON_UP|BUTTON_REL, BUTTON_UP }, | ||
64 | { ACTION_WPS_SEEKBACK, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, | ||
65 | { ACTION_WPS_STOPSEEK, BUTTON_UP|BUTTON_REL, BUTTON_UP|BUTTON_REPEAT }, | ||
66 | { ACTION_WPS_STOPSEEK, BUTTON_DOWN|BUTTON_REL, BUTTON_DOWN|BUTTON_REPEAT }, | ||
67 | |||
68 | { ACTION_WPS_VOLUP, BUTTON_VOL_UP, BUTTON_NONE }, | ||
69 | { ACTION_WPS_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, | ||
70 | |||
71 | { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE }, | ||
72 | { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, | ||
73 | |||
74 | { ACTION_WPS_MENU, BUTTON_BACK, BUTTON_NONE }, | ||
75 | |||
76 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) | ||
77 | }; /* button_context_wps */ | ||
78 | |||
79 | static const struct button_mapping button_context_keyboard[] = { | ||
80 | { ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE }, | ||
81 | { ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, | ||
82 | { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, | ||
83 | { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, | ||
84 | { ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE }, | ||
85 | { ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, | ||
86 | { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE }, | ||
87 | { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, | ||
88 | |||
89 | { ACTION_KBD_SELECT, BUTTON_MENU, BUTTON_NONE }, | ||
90 | { ACTION_KBD_DONE, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU }, | ||
91 | { ACTION_KBD_ABORT, BUTTON_POWER, BUTTON_NONE }, | ||
92 | |||
93 | { ACTION_KBD_MORSE_INPUT, BUTTON_VOL_UP, BUTTON_NONE }, | ||
94 | { ACTION_KBD_MORSE_SELECT, BUTTON_VOL_DOWN|BUTTON_REL, BUTTON_NONE }, | ||
95 | |||
96 | LAST_ITEM_IN_LIST | ||
97 | }; /* button_context_keyboard */ | ||
98 | |||
99 | static const struct button_mapping button_context_quickscreen[] = { | ||
100 | { ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE }, | ||
101 | { ACTION_STD_CANCEL, BUTTON_MENU, BUTTON_NONE }, | ||
102 | { ACTION_QS_TOP, BUTTON_UP, BUTTON_NONE }, | ||
103 | { ACTION_QS_DOWN, BUTTON_DOWN, BUTTON_NONE }, | ||
104 | { ACTION_QS_LEFT, BUTTON_LEFT, BUTTON_NONE }, | ||
105 | { ACTION_QS_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, | ||
106 | |||
107 | LAST_ITEM_IN_LIST | ||
108 | }; /* button_context_quickscreen */ | ||
109 | |||
110 | static const struct button_mapping button_context_tree[] = { | ||
111 | |||
112 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST) | ||
113 | }; /* button_context_tree */ | ||
114 | |||
115 | static const struct button_mapping button_context_list[] = { | ||
116 | #ifdef HAVE_VOLUME_IN_LIST | ||
117 | { ACTION_LIST_VOLUP, BUTTON_VOL_UP, BUTTON_NONE }, | ||
118 | { ACTION_LIST_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, | ||
119 | { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE }, | ||
120 | { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, | ||
121 | #endif | ||
122 | |||
123 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) | ||
124 | }; /* button_context_list */ | ||
125 | |||
126 | #ifdef CONFIG_TUNER | ||
127 | static const struct button_mapping button_context_radio[] = { | ||
128 | { ACTION_FM_MENU, BUTTON_MENU, BUTTON_NONE }, | ||
129 | { ACTION_FM_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, | ||
130 | { ACTION_FM_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE }, | ||
131 | |||
132 | { ACTION_FM_EXIT, BUTTON_BACK, BUTTON_NONE }, | ||
133 | |||
134 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS) | ||
135 | }; /* button_context_radio */ | ||
136 | #endif | ||
137 | |||
138 | #ifdef HAVE_RECORDING | ||
139 | static const struct button_mapping button_context_recscreen[] = { | ||
140 | { ACTION_REC_PAUSE, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, | ||
141 | { ACTION_SETTINGS_INC, BUTTON_UP, BUTTON_NONE }, | ||
142 | { ACTION_SETTINGS_INCREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, | ||
143 | { ACTION_SETTINGS_DEC, BUTTON_DOWN, BUTTON_NONE }, | ||
144 | { ACTION_SETTINGS_DECREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, | ||
145 | |||
146 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) | ||
147 | }; /* button_context_recscreen */ | ||
148 | #endif | ||
149 | |||
150 | static const struct button_mapping button_context_settings[] = { | ||
151 | /* we overwrite this to avoid select from std */ | ||
152 | { ACTION_NONE, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT }, | ||
153 | |||
154 | { ACTION_SETTINGS_INC, BUTTON_VOL_UP, BUTTON_NONE }, | ||
155 | { ACTION_SETTINGS_INCREPEAT, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, | ||
156 | { ACTION_SETTINGS_DEC, BUTTON_VOL_DOWN, BUTTON_NONE }, | ||
157 | { ACTION_SETTINGS_DECREPEAT, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, | ||
158 | |||
159 | { ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE }, | ||
160 | { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, | ||
161 | { ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE }, | ||
162 | { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, | ||
163 | |||
164 | { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, | ||
165 | { ACTION_SETTINGS_RESET, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE }, | ||
166 | |||
167 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) | ||
168 | }; /* button_context_settings */ | ||
169 | |||
170 | static const struct button_mapping button_context_time[] = { | ||
171 | |||
172 | { ACTION_STD_CANCEL, BUTTON_BACK, BUTTON_NONE }, | ||
173 | { ACTION_STD_OK, BUTTON_PLAY, BUTTON_NONE }, | ||
174 | |||
175 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS) | ||
176 | }; /* button_context_time */ | ||
177 | |||
178 | static const struct button_mapping button_context_colorchooser[] = { | ||
179 | { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, | ||
180 | { ACTION_STD_CANCEL, BUTTON_BACK, BUTTON_NONE }, | ||
181 | |||
182 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_SETTINGS), | ||
183 | }; /* button_context_colorchooser */ | ||
184 | |||
185 | static const struct button_mapping button_context_eq[] = { | ||
186 | { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, | ||
187 | |||
188 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_SETTINGS), | ||
189 | }; /* button_context_eq */ | ||
190 | |||
191 | /* Bookmark Screen */ | ||
192 | static const struct button_mapping button_context_bmark[] = { | ||
193 | { ACTION_BMS_DELETE, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, | ||
194 | |||
195 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST), | ||
196 | }; /* button_context_bmark */ | ||
197 | |||
198 | static const struct button_mapping button_context_pitchscreen[] = { | ||
199 | |||
200 | { ACTION_PS_INC_SMALL, BUTTON_UP, BUTTON_NONE }, | ||
201 | { ACTION_PS_INC_BIG, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, | ||
202 | { ACTION_PS_DEC_SMALL, BUTTON_DOWN, BUTTON_NONE }, | ||
203 | { ACTION_PS_DEC_BIG, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, | ||
204 | |||
205 | { ACTION_PS_RESET, BUTTON_PLAY, BUTTON_NONE }, | ||
206 | { ACTION_PS_EXIT, BUTTON_BACK, BUTTON_NONE }, | ||
207 | |||
208 | LAST_ITEM_IN_LIST | ||
209 | }; /* button_context_pitchcreen */ | ||
210 | |||
211 | static const struct button_mapping button_context_yesno[] = { | ||
212 | { ACTION_YESNO_ACCEPT, BUTTON_PLAY, BUTTON_NONE }, | ||
213 | |||
214 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) | ||
215 | }; /* button_context_yesno */ | ||
216 | |||
217 | #ifdef USB_ENABLE_HID | ||
218 | static const struct button_mapping button_context_usb_hid[] = { | ||
219 | { ACTION_USB_HID_MODE_SWITCH_NEXT, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, | ||
220 | { ACTION_USB_HID_MODE_SWITCH_PREV, BUTTON_POWER|BUTTON_REPEAT, BUTTON_POWER }, | ||
221 | |||
222 | LAST_ITEM_IN_LIST | ||
223 | }; /* button_context_usb_hid */ | ||
224 | |||
225 | static const struct button_mapping button_context_usb_hid_mode_multimedia[] = { | ||
226 | |||
227 | { ACTION_USB_HID_MULTIMEDIA_VOLUME_DOWN, BUTTON_VOL_DOWN, BUTTON_NONE }, | ||
228 | { ACTION_USB_HID_MULTIMEDIA_VOLUME_DOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, | ||
229 | { ACTION_USB_HID_MULTIMEDIA_VOLUME_UP, BUTTON_VOL_UP, BUTTON_NONE }, | ||
230 | { ACTION_USB_HID_MULTIMEDIA_VOLUME_UP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, | ||
231 | { ACTION_USB_HID_MULTIMEDIA_VOLUME_MUTE, BUTTON_BACK|BUTTON_REL, BUTTON_BACK }, | ||
232 | { ACTION_USB_HID_MULTIMEDIA_PLAYBACK_PLAY_PAUSE, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, | ||
233 | { ACTION_USB_HID_MULTIMEDIA_PLAYBACK_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, | ||
234 | { ACTION_USB_HID_MULTIMEDIA_PLAYBACK_TRACK_PREV, BUTTON_UP|BUTTON_REL, BUTTON_UP }, | ||
235 | { ACTION_USB_HID_MULTIMEDIA_PLAYBACK_TRACK_NEXT, BUTTON_DOWN|BUTTON_REL, BUTTON_DOWN }, | ||
236 | |||
237 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_USB_HID) | ||
238 | }; /* button_context_usb_hid_mode_multimedia */ | ||
239 | |||
240 | |||
241 | static const struct button_mapping button_context_usb_hid_mode_presentation[] = { | ||
242 | { ACTION_USB_HID_PRESENTATION_SLIDESHOW_START, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, | ||
243 | { ACTION_USB_HID_PRESENTATION_SLIDESHOW_LEAVE, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, | ||
244 | { ACTION_USB_HID_PRESENTATION_SLIDE_PREV, BUTTON_UP|BUTTON_REL, BUTTON_UP }, | ||
245 | { ACTION_USB_HID_PRESENTATION_SLIDE_NEXT, BUTTON_DOWN|BUTTON_REL, BUTTON_DOWN }, | ||
246 | |||
247 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_USB_HID) | ||
248 | }; /* button_context_usb_hid_mode_presentation */ | ||
249 | |||
250 | static const struct button_mapping button_context_usb_hid_mode_browser[] = { | ||
251 | |||
252 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_USB_HID) | ||
253 | }; /* button_context_usb_hid_mode_browser */ | ||
254 | |||
255 | #ifdef HAVE_USB_HID_MOUSE | ||
256 | static const struct button_mapping button_context_usb_hid_mode_mouse[] = { | ||
257 | |||
258 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_USB_HID) | ||
259 | }; /* button_context_usb_hid_mode_mouse */ | ||
260 | #endif | ||
261 | #endif | ||
262 | |||
263 | /* get_context_mapping returns a pointer to one of the above defined arrays depending on the context */ | ||
264 | const struct button_mapping* get_context_mapping(int context) | ||
265 | { | ||
266 | switch (context) | ||
267 | { | ||
268 | case CONTEXT_STD: | ||
269 | return button_context_standard; | ||
270 | case CONTEXT_MAINMENU: | ||
271 | return button_context_tree; | ||
272 | case CONTEXT_SETTINGS: | ||
273 | return button_context_settings; | ||
274 | case CONTEXT_WPS: | ||
275 | return button_context_wps; | ||
276 | case CONTEXT_YESNOSCREEN: | ||
277 | return button_context_yesno; | ||
278 | case CONTEXT_SETTINGS_TIME: | ||
279 | return button_context_time; | ||
280 | case CONTEXT_KEYBOARD: | ||
281 | case CONTEXT_MORSE_INPUT: | ||
282 | return button_context_keyboard; | ||
283 | #ifdef CONFIG_TUNER | ||
284 | case CONTEXT_FM: | ||
285 | return button_context_radio; | ||
286 | #endif | ||
287 | case CONTEXT_LIST: | ||
288 | return button_context_list; | ||
289 | case CONTEXT_TREE: | ||
290 | return button_context_tree; | ||
291 | case CONTEXT_SETTINGS_EQ: | ||
292 | return button_context_eq; | ||
293 | #ifdef HAVE_RECORDING | ||
294 | case CONTEXT_RECSCREEN: | ||
295 | return button_context_recscreen; | ||
296 | #endif | ||
297 | case CONTEXT_QUICKSCREEN: | ||
298 | return button_context_quickscreen; | ||
299 | case CONTEXT_BOOKMARKSCREEN: | ||
300 | return button_context_bmark; | ||
301 | case CONTEXT_PITCHSCREEN: | ||
302 | return button_context_pitchscreen; | ||
303 | case CONTEXT_SETTINGS_COLOURCHOOSER: | ||
304 | return button_context_colorchooser; | ||
305 | case CONTEXT_SETTINGS_RECTRIGGER: | ||
306 | return button_context_settings; | ||
307 | case CONTEXT_CUSTOM|CONTEXT_SETTINGS: | ||
308 | return button_context_settings; | ||
309 | #ifdef USB_ENABLE_HID | ||
310 | case CONTEXT_USB_HID: | ||
311 | return button_context_usb_hid; | ||
312 | case CONTEXT_USB_HID_MODE_MULTIMEDIA: | ||
313 | return button_context_usb_hid_mode_multimedia; | ||
314 | case CONTEXT_USB_HID_MODE_PRESENTATION: | ||
315 | return button_context_usb_hid_mode_presentation; | ||
316 | case CONTEXT_USB_HID_MODE_BROWSER: | ||
317 | return button_context_usb_hid_mode_browser; | ||
318 | #ifdef HAVE_USB_HID_MOUSE | ||
319 | case CONTEXT_USB_HID_MODE_MOUSE: | ||
320 | return button_context_usb_hid_mode_mouse; | ||
321 | #endif | ||
322 | #endif | ||
323 | default: | ||
324 | return button_context_standard; | ||
325 | } | ||
326 | return button_context_standard; | ||
327 | } | ||