1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright © Rafaël Carré 2008
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 ****************************************************************************/
21 /* Button Code Definitions for Sansa Clip target */
28 /* {Action Code, Button code, Prereq button code } */
31 * The format of the list is as follows
32 * { Action Code, Button code, Prereq button code }
33 * if there's no need to check the previous button's value, use BUTTON_NONE
34 * Insert LAST_ITEM_IN_LIST at the end of each mapping
36 static const struct button_mapping button_context_standard
[] = {
37 { ACTION_STD_PREV
, BUTTON_UP
, BUTTON_NONE
},
38 { ACTION_STD_PREVREPEAT
, BUTTON_UP
|BUTTON_REPEAT
, BUTTON_NONE
},
39 { ACTION_STD_NEXT
, BUTTON_DOWN
, BUTTON_NONE
},
40 { ACTION_STD_NEXTREPEAT
, BUTTON_DOWN
|BUTTON_REPEAT
, BUTTON_NONE
},
42 { ACTION_STD_MENU
, BUTTON_HOME
|BUTTON_REL
, BUTTON_HOME
},
43 { ACTION_STD_REC
, BUTTON_HOME
|BUTTON_REPEAT
, BUTTON_NONE
},
45 { ACTION_STD_OK
, BUTTON_SELECT
|BUTTON_REL
, BUTTON_SELECT
},
46 { ACTION_STD_OK
, BUTTON_RIGHT
, BUTTON_NONE
},
47 { ACTION_STD_CANCEL
, BUTTON_LEFT
, BUTTON_NONE
},
48 { ACTION_STD_CANCEL
, BUTTON_POWER
, BUTTON_NONE
},
50 { ACTION_STD_QUICKSCREEN
, BUTTON_DOWN
|BUTTON_REPEAT
, BUTTON_DOWN
},
51 { ACTION_STD_CONTEXT
, BUTTON_SELECT
|BUTTON_REPEAT
, BUTTON_SELECT
},
54 }; /* button_context_standard */
57 static const struct button_mapping button_context_wps
[] = {
58 { ACTION_WPS_PLAY
, BUTTON_UP
|BUTTON_REL
, BUTTON_UP
},
59 { ACTION_WPS_STOP
, BUTTON_POWER
|BUTTON_REL
, BUTTON_POWER
},
61 { ACTION_WPS_SKIPPREV
, BUTTON_LEFT
|BUTTON_REL
, BUTTON_LEFT
},
62 { ACTION_WPS_SEEKBACK
, BUTTON_LEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
63 { ACTION_WPS_STOPSEEK
, BUTTON_LEFT
|BUTTON_REL
, BUTTON_LEFT
|BUTTON_REPEAT
},
65 { ACTION_WPS_SKIPNEXT
, BUTTON_RIGHT
|BUTTON_REL
, BUTTON_RIGHT
},
66 { ACTION_WPS_SEEKFWD
, BUTTON_RIGHT
|BUTTON_REPEAT
, BUTTON_NONE
},
67 { ACTION_WPS_STOPSEEK
, BUTTON_RIGHT
|BUTTON_REL
, BUTTON_RIGHT
|BUTTON_REPEAT
},
69 { ACTION_WPS_ABSETB_NEXTDIR
, BUTTON_POWER
|BUTTON_RIGHT
, BUTTON_POWER
},
70 { ACTION_WPS_ABSETA_PREVDIR
, BUTTON_POWER
|BUTTON_LEFT
, BUTTON_POWER
},
71 { ACTION_WPS_ABRESET
, BUTTON_POWER
|BUTTON_UP
, BUTTON_POWER
},
73 { ACTION_WPS_VOLUP
, BUTTON_VOL_UP
, BUTTON_NONE
},
74 { ACTION_WPS_VOLUP
, BUTTON_VOL_UP
|BUTTON_REPEAT
, BUTTON_NONE
},
75 { ACTION_WPS_VOLDOWN
, BUTTON_VOL_DOWN
, BUTTON_NONE
},
76 { ACTION_WPS_VOLDOWN
, BUTTON_VOL_DOWN
|BUTTON_REPEAT
, BUTTON_NONE
},
78 { ACTION_WPS_BROWSE
, BUTTON_SELECT
|BUTTON_REL
, BUTTON_SELECT
},
80 { ACTION_WPS_CONTEXT
, BUTTON_SELECT
|BUTTON_REPEAT
, BUTTON_SELECT
},
81 { ACTION_WPS_QUICKSCREEN
, BUTTON_DOWN
|BUTTON_REPEAT
, BUTTON_DOWN
},
83 { ACTION_WPS_MENU
, BUTTON_DOWN
|BUTTON_REL
, BUTTON_DOWN
},
84 { ACTION_WPS_REC
, BUTTON_HOME
|BUTTON_REPEAT
, BUTTON_NONE
},
86 { ACTION_WPS_PITCHSCREEN
, BUTTON_SELECT
|BUTTON_UP
, BUTTON_SELECT
},
87 { ACTION_WPS_ID3SCREEN
, BUTTON_SELECT
|BUTTON_DOWN
, BUTTON_SELECT
},
90 }; /* button_context_wps */
92 static const struct button_mapping button_context_settings
[] = {
93 { ACTION_STD_CANCEL
, BUTTON_POWER
, BUTTON_NONE
},
94 { ACTION_SETTINGS_INC
, BUTTON_UP
, BUTTON_NONE
},
95 { ACTION_SETTINGS_INCREPEAT
,BUTTON_UP
|BUTTON_REPEAT
, BUTTON_NONE
},
96 { ACTION_SETTINGS_DEC
, BUTTON_DOWN
, BUTTON_NONE
},
97 { ACTION_SETTINGS_DECREPEAT
,BUTTON_DOWN
|BUTTON_REPEAT
, BUTTON_NONE
},
99 { ACTION_STD_PREV
, BUTTON_LEFT
, BUTTON_NONE
},
100 { ACTION_STD_PREVREPEAT
, BUTTON_LEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
101 { ACTION_STD_NEXT
, BUTTON_RIGHT
, BUTTON_NONE
},
102 { ACTION_STD_NEXTREPEAT
, BUTTON_RIGHT
|BUTTON_REPEAT
, BUTTON_NONE
},
103 { ACTION_SETTINGS_RESET
, BUTTON_SELECT
, BUTTON_NONE
},
105 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD
),
106 }; /* button_context_settings */
108 static const struct button_mapping button_context_list
[] = {
109 { ACTION_LISTTREE_PGUP
, BUTTON_HOME
|BUTTON_LEFT
, BUTTON_HOME
},
110 { ACTION_LISTTREE_PGDOWN
, BUTTON_HOME
|BUTTON_RIGHT
, BUTTON_HOME
},
112 #ifdef HAVE_VOLUME_IN_LIST
113 { ACTION_LIST_VOLUP
, BUTTON_VOL_UP
|BUTTON_REPEAT
, BUTTON_NONE
},
114 { ACTION_LIST_VOLUP
, BUTTON_VOL_UP
, BUTTON_NONE
},
116 { ACTION_LIST_VOLDOWN
, BUTTON_VOL_DOWN
, BUTTON_NONE
},
117 { ACTION_LIST_VOLDOWN
, BUTTON_VOL_DOWN
|BUTTON_REPEAT
, BUTTON_NONE
},
119 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD
)
120 }; /* button_context_list */
122 static const struct button_mapping button_context_tree
[] = {
123 { ACTION_TREE_STOP
, BUTTON_POWER
|BUTTON_REL
, BUTTON_POWER
},
125 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST
),
126 }; /* button_context_tree */
128 static const struct button_mapping button_context_listtree_scroll_without_combo
[] = {
129 { ACTION_NONE
, BUTTON_LEFT
, BUTTON_NONE
},
130 { ACTION_STD_CANCEL
, BUTTON_LEFT
|BUTTON_REL
, BUTTON_LEFT
},
131 { ACTION_TREE_ROOT_INIT
, BUTTON_LEFT
|BUTTON_REPEAT
, BUTTON_LEFT
},
132 { ACTION_TREE_PGLEFT
, BUTTON_LEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
133 { ACTION_TREE_PGLEFT
, BUTTON_LEFT
|BUTTON_REL
, BUTTON_LEFT
|BUTTON_REPEAT
},
134 { ACTION_NONE
, BUTTON_RIGHT
, BUTTON_NONE
},
135 { ACTION_STD_OK
, BUTTON_RIGHT
|BUTTON_REL
, BUTTON_RIGHT
},
136 { ACTION_TREE_PGRIGHT
, BUTTON_RIGHT
|BUTTON_REPEAT
, BUTTON_NONE
},
137 { ACTION_TREE_PGRIGHT
, BUTTON_RIGHT
|BUTTON_REL
, BUTTON_RIGHT
|BUTTON_REPEAT
},
139 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM
|CONTEXT_TREE
),
140 }; /* button_context_listtree_scroll_without_combo */
142 static const struct button_mapping button_context_listtree_scroll_with_combo
[] = {
143 { ACTION_TREE_ROOT_INIT
,BUTTON_LEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
144 { ACTION_TREE_PGLEFT
, BUTTON_HOME
|BUTTON_LEFT
, BUTTON_HOME
},
145 { ACTION_TREE_PGLEFT
, BUTTON_HOME
|BUTTON_LEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
146 { ACTION_TREE_PGRIGHT
, BUTTON_HOME
|BUTTON_RIGHT
, BUTTON_HOME
},
147 { ACTION_TREE_PGRIGHT
, BUTTON_HOME
|BUTTON_RIGHT
|BUTTON_REPEAT
,BUTTON_NONE
},
149 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM
|CONTEXT_TREE
),
150 }; /* button_context_listtree_scroll_with_combo */
152 static const struct button_mapping button_context_yesno
[] = {
153 { ACTION_YESNO_ACCEPT
, BUTTON_SELECT
, BUTTON_NONE
},
155 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD
),
156 }; /* button_context_settings_yesno */
158 static const struct button_mapping button_context_quickscreen
[] = {
159 { ACTION_NONE
, BUTTON_LEFT
, BUTTON_NONE
},
160 { ACTION_STD_CANCEL
, BUTTON_POWER
|BUTTON_REL
, BUTTON_NONE
},
161 { ACTION_QS_DOWNINV
, BUTTON_UP
|BUTTON_REL
, BUTTON_NONE
},
162 { ACTION_QS_DOWNINV
, BUTTON_UP
|BUTTON_REPEAT
, BUTTON_NONE
},
163 { ACTION_QS_DOWN
, BUTTON_DOWN
|BUTTON_REL
, BUTTON_NONE
},
164 { ACTION_QS_DOWN
, BUTTON_DOWN
|BUTTON_REPEAT
, BUTTON_NONE
},
165 { ACTION_QS_LEFT
, BUTTON_LEFT
|BUTTON_REL
, BUTTON_NONE
},
166 { ACTION_QS_LEFT
, BUTTON_LEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
167 { ACTION_QS_RIGHT
, BUTTON_RIGHT
|BUTTON_REL
, BUTTON_NONE
},
168 { ACTION_QS_RIGHT
, BUTTON_RIGHT
|BUTTON_REPEAT
, BUTTON_NONE
},
170 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD
),
171 }; /* button_context_quickscreen */
173 static const struct button_mapping button_context_settings_right_is_inc
[] = {
174 { ACTION_SETTINGS_INC
, BUTTON_RIGHT
, BUTTON_NONE
},
175 { ACTION_SETTINGS_INCREPEAT
,BUTTON_RIGHT
|BUTTON_REPEAT
, BUTTON_NONE
},
176 { ACTION_SETTINGS_DEC
, BUTTON_LEFT
, BUTTON_NONE
},
177 { ACTION_SETTINGS_DECREPEAT
,BUTTON_LEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
179 { ACTION_STD_CANCEL
, BUTTON_POWER
, BUTTON_NONE
},
181 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD
),
182 }; /* button_context_settings_right_is_inc */
184 static const struct button_mapping button_context_pitchscreen
[] = {
185 { ACTION_PS_INC_SMALL
, BUTTON_RIGHT
, BUTTON_NONE
},
186 { ACTION_PS_INC_BIG
, BUTTON_RIGHT
|BUTTON_REPEAT
, BUTTON_NONE
},
187 { ACTION_PS_DEC_SMALL
, BUTTON_LEFT
, BUTTON_NONE
},
188 { ACTION_PS_DEC_BIG
, BUTTON_LEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
189 { ACTION_PS_NUDGE_LEFT
, BUTTON_LEFT
, BUTTON_NONE
},
190 { ACTION_PS_NUDGE_LEFTOFF
, BUTTON_LEFT
|BUTTON_REL
, BUTTON_NONE
},
191 { ACTION_PS_NUDGE_RIGHT
, BUTTON_RIGHT
, BUTTON_NONE
},
192 { ACTION_PS_NUDGE_RIGHTOFF
, BUTTON_RIGHT
|BUTTON_REL
, BUTTON_NONE
},
193 { ACTION_PS_TOGGLE_MODE
, BUTTON_HOME
, BUTTON_NONE
},
194 { ACTION_PS_RESET
, BUTTON_SELECT
, BUTTON_NONE
},
195 { ACTION_PS_EXIT
, BUTTON_POWER
, BUTTON_NONE
},
196 { ACTION_PS_EXIT
, BUTTON_UP
, BUTTON_NONE
},
198 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD
),
199 }; /* button_context_pitchscreen */
201 /** Recording Screen **/
202 static const struct button_mapping button_context_recscreen
[] = {
203 { ACTION_REC_PAUSE
, BUTTON_UP
|BUTTON_REL
, BUTTON_UP
},
204 { ACTION_STD_CANCEL
, BUTTON_POWER
|BUTTON_REL
, BUTTON_POWER
},
205 { ACTION_REC_NEWFILE
, BUTTON_HOME
|BUTTON_REL
, BUTTON_HOME
},
206 { ACTION_STD_MENU
, BUTTON_SELECT
|BUTTON_REPEAT
, BUTTON_SELECT
},
207 { ACTION_SETTINGS_INC
, BUTTON_RIGHT
, BUTTON_NONE
},
208 { ACTION_SETTINGS_INCREPEAT
, BUTTON_RIGHT
|BUTTON_REPEAT
, BUTTON_NONE
},
209 { ACTION_SETTINGS_DEC
, BUTTON_LEFT
, BUTTON_NONE
},
210 { ACTION_SETTINGS_DECREPEAT
, BUTTON_LEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
211 { ACTION_STD_PREV
, BUTTON_LEFT
, BUTTON_NONE
},
212 { ACTION_STD_PREV
, BUTTON_LEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
213 { ACTION_STD_NEXT
, BUTTON_RIGHT
, BUTTON_NONE
},
214 { ACTION_STD_NEXT
, BUTTON_RIGHT
|BUTTON_REPEAT
, BUTTON_NONE
},
215 { ACTION_NONE
, BUTTON_DOWN
|BUTTON_REL
, BUTTON_DOWN
},
216 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD
)
217 }; /* button_context_recscreen */
219 /** FM Radio Screen **/
220 static const struct button_mapping button_context_radio
[] = {
221 /* Copied from keymap-c200.c 20081207. Feel free to suggest a better one.*/
222 { ACTION_NONE
, BUTTON_UP
, BUTTON_NONE
},
223 { ACTION_FM_MENU
, BUTTON_DOWN
, BUTTON_NONE
},
224 { ACTION_FM_PRESET
, BUTTON_SELECT
, BUTTON_NONE
},
225 { ACTION_FM_STOP
, BUTTON_UP
|BUTTON_REPEAT
, BUTTON_UP
},
226 { ACTION_FM_MODE
, BUTTON_HOME
, BUTTON_NONE
},
227 { ACTION_FM_EXIT
, BUTTON_POWER
|BUTTON_REL
, BUTTON_POWER
},
228 { ACTION_FM_PLAY
, BUTTON_UP
|BUTTON_REL
, BUTTON_UP
},
229 { ACTION_SETTINGS_INC
, BUTTON_VOL_UP
, BUTTON_NONE
},
230 { ACTION_SETTINGS_INCREPEAT
,BUTTON_VOL_UP
|BUTTON_REPEAT
, BUTTON_NONE
},
231 { ACTION_SETTINGS_DEC
, BUTTON_VOL_DOWN
, BUTTON_NONE
},
232 { ACTION_SETTINGS_DECREPEAT
,BUTTON_VOL_DOWN
|BUTTON_REPEAT
, BUTTON_NONE
},
234 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS
)
235 }; /* button_context_radio */
237 static const struct button_mapping button_context_keyboard
[] = {
238 { ACTION_KBD_LEFT
, BUTTON_LEFT
, BUTTON_NONE
},
239 { ACTION_KBD_LEFT
, BUTTON_LEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
240 { ACTION_KBD_RIGHT
, BUTTON_RIGHT
, BUTTON_NONE
},
241 { ACTION_KBD_RIGHT
, BUTTON_RIGHT
|BUTTON_REPEAT
, BUTTON_NONE
},
242 { ACTION_KBD_UP
, BUTTON_UP
, BUTTON_NONE
},
243 { ACTION_KBD_UP
, BUTTON_UP
|BUTTON_REPEAT
, BUTTON_NONE
},
244 { ACTION_KBD_DOWN
, BUTTON_DOWN
, BUTTON_NONE
},
245 { ACTION_KBD_DOWN
, BUTTON_DOWN
|BUTTON_REPEAT
, BUTTON_NONE
},
247 { ACTION_KBD_CURSOR_LEFT
, BUTTON_VOL_UP
, BUTTON_NONE
},
248 { ACTION_KBD_CURSOR_LEFT
, BUTTON_VOL_UP
|BUTTON_REPEAT
, BUTTON_NONE
},
249 { ACTION_KBD_CURSOR_RIGHT
, BUTTON_VOL_DOWN
, BUTTON_NONE
},
250 { ACTION_KBD_CURSOR_RIGHT
, BUTTON_VOL_DOWN
|BUTTON_REPEAT
, BUTTON_NONE
},
252 /*{ ACTION_KBD_PAGE_FLIP, , BUTTON_NONE },*/
253 { ACTION_KBD_BACKSPACE
, BUTTON_HOME
, BUTTON_NONE
},
254 { ACTION_KBD_BACKSPACE
, BUTTON_HOME
|BUTTON_REPEAT
, BUTTON_NONE
},
255 { ACTION_KBD_SELECT
, BUTTON_SELECT
|BUTTON_REL
, BUTTON_NONE
},
256 { ACTION_KBD_DONE
, BUTTON_SELECT
|BUTTON_REPEAT
, BUTTON_NONE
},
257 { ACTION_KBD_ABORT
, BUTTON_POWER
, BUTTON_NONE
},
260 }; /* button_context_keyboard */
262 static const struct button_mapping button_context_bmark
[] = {
263 { ACTION_BMS_DELETE
, BUTTON_HOME
, BUTTON_NONE
},
265 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST
),
266 }; /* button_context_bmark */
268 /* get_context_mapping returns a pointer to one of the above defined arrays depending on the context */
269 const struct button_mapping
* get_context_mapping(int context
)
274 return button_context_standard
;
277 return button_context_wps
;
280 return button_context_list
;
282 case CONTEXT_MAINMENU
:
283 if (global_settings
.hold_lr_for_scroll_in_list
)
284 return button_context_listtree_scroll_without_combo
;
286 return button_context_listtree_scroll_with_combo
;
287 case CONTEXT_CUSTOM
|CONTEXT_TREE
:
288 return button_context_tree
;
290 case CONTEXT_SETTINGS
:
291 case CONTEXT_SETTINGS_TIME
:
292 return button_context_settings
;
293 case CONTEXT_CUSTOM
|CONTEXT_SETTINGS
:
294 case CONTEXT_SETTINGS_COLOURCHOOSER
:
295 case CONTEXT_SETTINGS_EQ
:
296 case CONTEXT_SETTINGS_RECTRIGGER
:
297 return button_context_settings_right_is_inc
;
299 case CONTEXT_YESNOSCREEN
:
300 return button_context_yesno
;
302 return button_context_radio
;
303 case CONTEXT_BOOKMARKSCREEN
:
304 return button_context_bmark
;
305 case CONTEXT_QUICKSCREEN
:
306 return button_context_quickscreen
;
307 case CONTEXT_PITCHSCREEN
:
308 return button_context_pitchscreen
;
309 case CONTEXT_RECSCREEN
:
310 return button_context_recscreen
;
311 case CONTEXT_KEYBOARD
:
312 return button_context_keyboard
;
315 return button_context_standard
;
317 return button_context_standard
;