1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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 touchscreen targets */
32 const struct button_mapping
* target_get_context_mapping(int context
);
33 /* How this file is used:
34 get_context_mapping() at the bottom of the file is called by action.c as usual.
35 if the context is for the remote control its then passed straight to
36 target_get_context_mapping().
37 These tables are only used for the touchscreen buttons, so at the end of each
38 CONTEXT_CUSTOM2 is OR'ed with the context and then sent to target_get_context_mapping()
39 (NOTE: CONTEXT_CUSTOM2 will be stripped before being sent to make it easier.)
40 In the target keymap, remember to |CONTEXT_CUSTOM2 in the LAST_ITEM_IN_LIST__NEXTLIST() macro
41 to speed it up a tiny bit... if you dont it will go through these tables first before going
42 back to the target file.
46 /* touchscreen "buttons"
47 screen is split into a 3x3 grid for buttons...
48 BUTTON_TOPLEFT BUTTON_TOPMIDDLE BUTTON_TOPRIGHT
49 BUTTON_MIDLEFT BUTTON_CENTER BUTTON_MIDRIGHT
50 BUTTON_BOTTOMLEFT BUTTON_BOTTOMMIDDLE BUTTON_BOTTOMRIGHT
53 static const struct button_mapping button_context_standard
[] = {
54 { ACTION_STD_PREV
, BUTTON_TOPMIDDLE
, BUTTON_NONE
},
55 { ACTION_STD_PREVREPEAT
, BUTTON_TOPMIDDLE
|BUTTON_REPEAT
, BUTTON_NONE
},
56 { ACTION_STD_NEXT
, BUTTON_BOTTOMMIDDLE
, BUTTON_NONE
},
57 { ACTION_STD_NEXTREPEAT
, BUTTON_BOTTOMMIDDLE
|BUTTON_REPEAT
, BUTTON_NONE
},
59 { ACTION_STD_OK
, BUTTON_CENTER
|BUTTON_REL
, BUTTON_CENTER
},
60 { ACTION_STD_OK
, BUTTON_MIDRIGHT
|BUTTON_REL
, BUTTON_MIDRIGHT
},
61 { ACTION_STD_OK
, BUTTON_MIDRIGHT
|BUTTON_REPEAT
, BUTTON_MIDRIGHT
},
62 { ACTION_STD_CANCEL
, BUTTON_MIDLEFT
, BUTTON_NONE
},
63 { ACTION_STD_CANCEL
, BUTTON_MIDLEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
65 { ACTION_STD_MENU
, BUTTON_TOPLEFT
, BUTTON_NONE
},
66 { ACTION_STD_QUICKSCREEN
, BUTTON_TOPLEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
67 { ACTION_STD_CONTEXT
, BUTTON_CENTER
|BUTTON_REPEAT
, BUTTON_CENTER
},
69 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2
|CONTEXT_STD
)
70 }; /* button_context_standard */
72 static const struct button_mapping button_context_wps
[] = {
74 { ACTION_WPS_PLAY
, BUTTON_TOPRIGHT
|BUTTON_REL
, BUTTON_TOPRIGHT
},
75 { ACTION_WPS_SKIPNEXT
, BUTTON_MIDRIGHT
|BUTTON_REL
, BUTTON_MIDRIGHT
},
76 { ACTION_WPS_SKIPPREV
, BUTTON_MIDLEFT
|BUTTON_REL
, BUTTON_MIDLEFT
},
78 { ACTION_WPS_SEEKBACK
, BUTTON_MIDLEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
79 { ACTION_WPS_SEEKFWD
, BUTTON_MIDRIGHT
|BUTTON_REPEAT
, BUTTON_NONE
},
80 { ACTION_WPS_STOPSEEK
, BUTTON_MIDLEFT
|BUTTON_REL
, BUTTON_MIDLEFT
|BUTTON_REPEAT
},
81 { ACTION_WPS_STOPSEEK
, BUTTON_MIDRIGHT
|BUTTON_REL
, BUTTON_MIDRIGHT
|BUTTON_REPEAT
},
83 { ACTION_WPS_BROWSE
, BUTTON_CENTER
|BUTTON_REL
, BUTTON_CENTER
},
84 { ACTION_WPS_CONTEXT
, BUTTON_CENTER
|BUTTON_REPEAT
, BUTTON_CENTER
},
85 { ACTION_WPS_QUICKSCREEN
, BUTTON_TOPLEFT
|BUTTON_REPEAT
, BUTTON_TOPLEFT
},
87 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2
|CONTEXT_WPS
)
88 }; /* button_context_wps */
90 static const struct button_mapping button_context_list
[] = {
92 /* this is all to show how the poor-mans-gestures can be used... */
93 { ACTION_LISTTREE_PGUP
, BUTTON_TOPRIGHT
, BUTTON_NONE
},
94 { ACTION_LISTTREE_PGUP
, BUTTON_TOPRIGHT
|BUTTON_REPEAT
, BUTTON_TOPRIGHT
},
95 { ACTION_STD_NEXTREPEAT
, BUTTON_CENTER
, BUTTON_TOPMIDDLE
},
96 { ACTION_STD_NEXTREPEAT
, BUTTON_BOTTOMMIDDLE
, BUTTON_CENTER
},
97 { ACTION_NONE
, BUTTON_TOPMIDDLE
, BUTTON_NONE
},
98 { ACTION_NONE
, BUTTON_BOTTOMMIDDLE
, BUTTON_NONE
},
99 { ACTION_STD_PREV
, BUTTON_TOPMIDDLE
|BUTTON_REL
, BUTTON_NONE
},
100 { ACTION_STD_NEXT
, BUTTON_BOTTOMMIDDLE
|BUTTON_REL
, BUTTON_NONE
},
101 { ACTION_LISTTREE_PGDOWN
, BUTTON_BOTTOMRIGHT
, BUTTON_NONE
},
102 { ACTION_LISTTREE_PGDOWN
, BUTTON_BOTTOMRIGHT
|BUTTON_REPEAT
, BUTTON_BOTTOMRIGHT
},
103 { ACTION_STD_PREVREPEAT
, BUTTON_TOPMIDDLE
, BUTTON_CENTER
},
104 { ACTION_STD_PREVREPEAT
, BUTTON_CENTER
, BUTTON_BOTTOMMIDDLE
},
106 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2
|CONTEXT_LIST
)
107 }; /* button_context_list */
109 static const struct button_mapping button_context_tree
[] = {
110 { ACTION_TREE_WPS
, BUTTON_TOPRIGHT
|BUTTON_REL
, BUTTON_TOPRIGHT
},
112 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2
|CONTEXT_CUSTOM2
|CONTEXT_TREE
)
113 }; /* button_context_tree */
115 static const struct button_mapping button_context_listtree_scroll_with_combo
[] = {
116 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2
|CONTEXT_CUSTOM
|CONTEXT_TREE
),
119 static const struct button_mapping button_context_listtree_scroll_without_combo
[] = {
120 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2
|CONTEXT_CUSTOM
|CONTEXT_TREE
),
123 static const struct button_mapping button_context_settings
[] = {
124 { ACTION_SETTINGS_INC
, BUTTON_TOPMIDDLE
, BUTTON_NONE
},
125 { ACTION_SETTINGS_INCREPEAT
, BUTTON_TOPMIDDLE
|BUTTON_REPEAT
, BUTTON_NONE
},
126 { ACTION_SETTINGS_DEC
, BUTTON_BOTTOMMIDDLE
, BUTTON_NONE
},
127 { ACTION_SETTINGS_DECREPEAT
, BUTTON_BOTTOMMIDDLE
|BUTTON_REPEAT
, BUTTON_NONE
},
128 { ACTION_STD_OK
, BUTTON_CENTER
, BUTTON_NONE
},
129 { ACTION_STD_CANCEL
, BUTTON_MIDLEFT
, BUTTON_NONE
},
131 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2
|CONTEXT_SETTINGS
)
132 }; /* button_context_settings */
134 static const struct button_mapping button_context_settings_right_is_inc
[] = {
135 { ACTION_STD_PREV
, BUTTON_TOPMIDDLE
, BUTTON_NONE
},
136 { ACTION_STD_PREVREPEAT
, BUTTON_TOPMIDDLE
|BUTTON_REPEAT
, BUTTON_NONE
},
137 { ACTION_STD_NEXT
, BUTTON_BOTTOMMIDDLE
, BUTTON_NONE
},
138 { ACTION_STD_NEXTREPEAT
, BUTTON_BOTTOMMIDDLE
|BUTTON_REPEAT
, BUTTON_NONE
},
139 { ACTION_SETTINGS_INC
, BUTTON_MIDRIGHT
, BUTTON_NONE
},
140 { ACTION_SETTINGS_INCREPEAT
, BUTTON_MIDRIGHT
|BUTTON_REPEAT
, BUTTON_NONE
},
141 { ACTION_SETTINGS_DEC
, BUTTON_MIDLEFT
, BUTTON_NONE
},
142 { ACTION_SETTINGS_DECREPEAT
, BUTTON_MIDLEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
143 { ACTION_STD_OK
, BUTTON_CENTER
, BUTTON_NONE
},
144 { ACTION_STD_CANCEL
, BUTTON_TOPLEFT
, BUTTON_NONE
},
146 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2
|CONTEXT_CUSTOM
|CONTEXT_SETTINGS
)
147 }; /* button_context_settingsgraphical */
149 static const struct button_mapping button_context_yesno
[] = {
150 { ACTION_YESNO_ACCEPT
, BUTTON_TOPRIGHT
, BUTTON_NONE
},
151 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2
|CONTEXT_YESNOSCREEN
)
152 }; /* button_context_settings_yesno */
154 static const struct button_mapping button_context_colorchooser
[] = {
155 { ACTION_STD_OK
, BUTTON_CENTER
|BUTTON_REL
, BUTTON_NONE
},
156 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2
|CONTEXT_SETTINGS_COLOURCHOOSER
),
157 }; /* button_context_colorchooser */
159 static const struct button_mapping button_context_eq
[] = {
160 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2
|CONTEXT_SETTINGS_EQ
),
161 }; /* button_context_eq */
163 /* Bookmark Screen */
164 static const struct button_mapping button_context_bmark
[] = {
165 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2
|CONTEXT_BOOKMARKSCREEN
),
166 }; /* button_context_bmark */
168 static const struct button_mapping button_context_time
[] = {
169 { ACTION_SETTINGS_INC
, BUTTON_TOPMIDDLE
, BUTTON_NONE
},
170 { ACTION_SETTINGS_INCREPEAT
, BUTTON_TOPMIDDLE
|BUTTON_REPEAT
, BUTTON_NONE
},
171 { ACTION_SETTINGS_DEC
, BUTTON_BOTTOMMIDDLE
, BUTTON_NONE
},
172 { ACTION_SETTINGS_DECREPEAT
, BUTTON_BOTTOMMIDDLE
|BUTTON_REPEAT
, BUTTON_NONE
},
173 { ACTION_STD_PREV
, BUTTON_MIDLEFT
, BUTTON_NONE
},
174 { ACTION_STD_PREVREPEAT
, BUTTON_MIDLEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
175 { ACTION_STD_NEXT
, BUTTON_MIDRIGHT
, BUTTON_NONE
},
176 { ACTION_STD_NEXTREPEAT
, BUTTON_MIDRIGHT
|BUTTON_REPEAT
, BUTTON_NONE
},
177 { ACTION_STD_OK
, BUTTON_CENTER
|BUTTON_REL
, BUTTON_CENTER
},
178 { ACTION_STD_CANCEL
, BUTTON_TOPLEFT
|BUTTON_REL
, BUTTON_TOPLEFT
},
179 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2
|CONTEXT_SETTINGS_TIME
),
180 }; /* button_context_time */
182 static const struct button_mapping button_context_quickscreen
[] = {
184 { ACTION_STD_CANCEL
, BUTTON_CENTER
|BUTTON_REL
, BUTTON_NONE
},
185 { ACTION_QS_DOWNINV
, BUTTON_TOPMIDDLE
|BUTTON_REL
, BUTTON_NONE
},
186 { ACTION_QS_DOWNINV
, BUTTON_TOPMIDDLE
|BUTTON_REPEAT
, BUTTON_NONE
},
187 { ACTION_QS_DOWN
, BUTTON_BOTTOMMIDDLE
|BUTTON_REL
, BUTTON_NONE
},
188 { ACTION_QS_DOWN
, BUTTON_BOTTOMMIDDLE
|BUTTON_REPEAT
, BUTTON_NONE
},
189 { ACTION_QS_LEFT
, BUTTON_MIDLEFT
|BUTTON_REL
, BUTTON_NONE
},
190 { ACTION_QS_LEFT
, BUTTON_MIDLEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
191 { ACTION_QS_RIGHT
, BUTTON_MIDRIGHT
|BUTTON_REL
, BUTTON_NONE
},
192 { ACTION_QS_RIGHT
, BUTTON_MIDRIGHT
|BUTTON_REPEAT
, BUTTON_NONE
},
193 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2
|CONTEXT_QUICKSCREEN
)
194 }; /* button_context_quickscreen */
196 static const struct button_mapping button_context_pitchscreen
[] = {
198 { ACTION_PS_INC_SMALL
, BUTTON_TOPMIDDLE
, BUTTON_NONE
},
199 { ACTION_PS_INC_BIG
, BUTTON_TOPMIDDLE
|BUTTON_REPEAT
, BUTTON_NONE
},
200 { ACTION_PS_DEC_SMALL
, BUTTON_BOTTOMMIDDLE
, BUTTON_NONE
},
201 { ACTION_PS_DEC_BIG
, BUTTON_BOTTOMMIDDLE
|BUTTON_REPEAT
, BUTTON_NONE
},
202 { ACTION_PS_NUDGE_LEFT
, BUTTON_MIDLEFT
, BUTTON_NONE
},
203 { ACTION_PS_NUDGE_LEFTOFF
, BUTTON_MIDLEFT
|BUTTON_REL
, BUTTON_NONE
},
204 { ACTION_PS_NUDGE_RIGHT
, BUTTON_MIDRIGHT
, BUTTON_NONE
},
205 { ACTION_PS_NUDGE_RIGHTOFF
, BUTTON_MIDRIGHT
|BUTTON_REL
, BUTTON_NONE
},
206 { ACTION_PS_TOGGLE_MODE
, BUTTON_BOTTOMRIGHT
, BUTTON_NONE
},
207 { ACTION_PS_RESET
, BUTTON_CENTER
, BUTTON_NONE
},
208 { ACTION_PS_EXIT
, BUTTON_TOPLEFT
, BUTTON_NONE
},
209 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2
|CONTEXT_PITCHSCREEN
)
210 }; /* button_context_pitchcreen */
212 static const struct button_mapping button_context_keyboard
[] = {
214 { ACTION_KBD_LEFT
, BUTTON_MIDLEFT
, BUTTON_NONE
},
215 { ACTION_KBD_LEFT
, BUTTON_MIDLEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
216 { ACTION_KBD_RIGHT
, BUTTON_MIDRIGHT
, BUTTON_NONE
},
217 { ACTION_KBD_RIGHT
, BUTTON_MIDRIGHT
|BUTTON_REPEAT
, BUTTON_NONE
},
218 { ACTION_KBD_CURSOR_LEFT
, BUTTON_TOPLEFT
, BUTTON_NONE
},
219 { ACTION_KBD_CURSOR_LEFT
, BUTTON_TOPLEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
220 { ACTION_KBD_CURSOR_RIGHT
, BUTTON_TOPRIGHT
, BUTTON_NONE
},
221 { ACTION_KBD_CURSOR_RIGHT
, BUTTON_TOPRIGHT
|BUTTON_REPEAT
, BUTTON_NONE
},
222 { ACTION_KBD_SELECT
, BUTTON_CENTER
|BUTTON_REL
, BUTTON_NONE
},
223 { ACTION_KBD_DONE
, BUTTON_CENTER
|BUTTON_REPEAT
, BUTTON_CENTER
},
224 { ACTION_KBD_ABORT
, BUTTON_POWER
, BUTTON_NONE
},
225 { ACTION_KBD_BACKSPACE
, BUTTON_BOTTOMLEFT
, BUTTON_NONE
},
226 { ACTION_KBD_BACKSPACE
, BUTTON_BOTTOMLEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
227 { ACTION_KBD_UP
, BUTTON_TOPMIDDLE
, BUTTON_NONE
},
228 { ACTION_KBD_UP
, BUTTON_TOPMIDDLE
|BUTTON_REPEAT
, BUTTON_NONE
},
229 { ACTION_KBD_DOWN
, BUTTON_BOTTOMMIDDLE
, BUTTON_NONE
},
230 { ACTION_KBD_DOWN
, BUTTON_BOTTOMMIDDLE
|BUTTON_REPEAT
, BUTTON_NONE
},
232 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2
|CONTEXT_KEYBOARD
)
233 }; /* button_context_keyboard */
235 static const struct button_mapping button_context_radio
[] = {
236 { ACTION_STD_PREV
, BUTTON_MIDLEFT
, BUTTON_NONE
},
237 { ACTION_STD_PREVREPEAT
, BUTTON_MIDLEFT
|BUTTON_REPEAT
, BUTTON_NONE
},
238 { ACTION_STD_NEXT
, BUTTON_MIDRIGHT
, BUTTON_NONE
},
239 { ACTION_STD_NEXTREPEAT
, BUTTON_MIDRIGHT
|BUTTON_REPEAT
, BUTTON_NONE
},
240 { ACTION_FM_MENU
, BUTTON_CENTER
|BUTTON_REPEAT
, BUTTON_CENTER
},
241 { ACTION_FM_PRESET
, BUTTON_CENTER
|BUTTON_REL
, BUTTON_NONE
},
242 { ACTION_FM_EXIT
, BUTTON_TOPLEFT
|BUTTON_REL
, BUTTON_NONE
},
243 { ACTION_FM_MODE
, BUTTON_BOTTOMLEFT
|BUTTON_REL
, BUTTON_NONE
},
244 { ACTION_FM_PLAY
, BUTTON_TOPRIGHT
|BUTTON_REL
, BUTTON_NONE
},
245 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2
|CONTEXT_FM
)
246 }; /* button_context_radio */
249 static const struct button_mapping button_context_usb_hid
[] = {
250 { ACTION_USB_HID_PLAY
, BUTTON_TOPRIGHT
, BUTTON_NONE
},
251 { ACTION_USB_HID_SKIPPREV
, BUTTON_MIDLEFT
, BUTTON_NONE
},
252 { ACTION_USB_HID_SKIPNEXT
, BUTTON_MIDRIGHT
, BUTTON_NONE
},
253 { ACTION_USB_HID_MUTE
, BUTTON_CENTER
, BUTTON_NONE
},
254 { ACTION_USB_HID_MENU
, BUTTON_TOPLEFT
, BUTTON_NONE
},
256 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2
|CONTEXT_USB_HID
)
257 }; /* button_context_usb_hid */
260 const struct button_mapping
* get_context_mapping(int context
)
262 if (context
& CONTEXT_CUSTOM2
263 #if BUTTON_REMOTE != 0
264 || context
& CONTEXT_REMOTE
267 return target_get_context_mapping(context
& ~CONTEXT_CUSTOM2
);
272 return button_context_standard
;
274 return button_context_wps
;
277 return button_context_list
;
278 case CONTEXT_MAINMENU
:
280 if (global_settings
.hold_lr_for_scroll_in_list
)
281 return button_context_listtree_scroll_without_combo
;
283 return button_context_listtree_scroll_with_combo
;
284 case CONTEXT_CUSTOM
|CONTEXT_TREE
:
285 return button_context_tree
;
287 case CONTEXT_SETTINGS
:
288 return button_context_settings
;
289 case CONTEXT_CUSTOM
|CONTEXT_SETTINGS
:
290 return button_context_settings_right_is_inc
;
292 case CONTEXT_SETTINGS_COLOURCHOOSER
:
293 return button_context_colorchooser
;
294 case CONTEXT_SETTINGS_EQ
:
295 return button_context_eq
;
297 case CONTEXT_SETTINGS_TIME
:
298 return button_context_time
;
300 case CONTEXT_YESNOSCREEN
:
301 return button_context_yesno
;
303 return button_context_radio
;
304 case CONTEXT_BOOKMARKSCREEN
:
305 return button_context_bmark
;
306 case CONTEXT_QUICKSCREEN
:
307 return button_context_quickscreen
;
308 case CONTEXT_PITCHSCREEN
:
309 return button_context_pitchscreen
;
310 case CONTEXT_KEYBOARD
:
311 return button_context_keyboard
;
313 case CONTEXT_USB_HID
:
314 return button_context_usb_hid
;
317 return button_context_standard
;