1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2004 Brent Coutts
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
19 ****************************************************************************/
27 #define TIMEOUT_BLOCK -1
28 #define TIMEOUT_NOBLOCK 0
30 #define CONTEXT_STOPSEARCHING 0xFFFFFFFF
31 #define CONTEXT_REMOTE 0x80000000 /* | this against another context to get remote buttons for that context */
32 #define CONTEXT_CUSTOM 0x40000000 /* | this against anything to get your context number */
33 #define CONTEXT_CUSTOM2 0x20000000 /* as above */
34 #define CONTEXT_PLUGIN 0x10000000 /* for plugins using get_custom_action */
36 #define LAST_ITEM_IN_LIST { CONTEXT_STOPSEARCHING, BUTTON_NONE, BUTTON_NONE }
37 #define LAST_ITEM_IN_LIST__NEXTLIST(a) { a, BUTTON_NONE, BUTTON_NONE }
39 #ifndef HAS_BUTTON_HOLD
40 #define ALLOW_SOFTLOCK 0x08000000 /* will be stripped.. never needed except in calls to get_action() */
42 #define ALLOW_SOFTLOCK 0
47 /* These CONTEXT_ values were here before me,
48 there values may have significance, so dont touch! */
52 CONTEXT_MAINMENU
= 4, /* uses CONTEXT_TREE and ACTION_TREE_* */
54 /* Add new contexts here, no need to explicitly define a value for them */
56 CONTEXT_SETTINGS
, /* regular setting screens (and debug screens) */
57 /* bellow are setting screens which may need to redefine the standard
58 setting screen keys, targets should return the CONTEXT_SETTINGS
59 keymap unless they are not adequate for the screen
60 NOTE: uses ACTION_STD_[NEXT|PREV] so make sure they are there also
61 and (possibly) ACTION_SETTINGS_[INC|DEC] */
63 CONTEXT_SETTINGS_COLOURCHOOSER
,
64 CONTEXT_SETTINGS_TIME
,
65 CONTEXT_SETTINGS_RECTRIGGER
,
67 /* The following contexts should use ACTION_STD_[NEXT|PREV]
68 and (possibly) ACTION_SETTINGS_[INC|DEC]
69 Also add any extra actions they need */
70 CONTEXT_BOOKMARKSCREEN
, /* uses ACTION_BMS_ defines */
71 CONTEXT_ALARMSCREEN
, /* uses ACTION_AS_ defines */
72 CONTEXT_QUICKSCREEN
, /* uses ACTION_QS_ defines below */
73 CONTEXT_PITCHSCREEN
, /* uses ACTION_PS_ defines below */
75 CONTEXT_YESNOSCREEN
, /*NOTE: make sure your target has this and ACTION_YESNO_ACCEPT */
80 CONTEXT_USB_HID_MOUSE
,
86 ACTION_NONE
= BUTTON_NONE
,
88 ACTION_REDRAW
, /* returned if keys are locked and we splash()'ed */
90 ACTION_TOUCHSCREEN_MODE
, /* toggle the touchscreen mode */
92 /* standard actions, use these first */
94 ACTION_STD_PREVREPEAT
,
96 ACTION_STD_NEXTREPEAT
,
102 ACTION_STD_QUICKSCREEN
,
106 ACTION_F3
, /* just so everything works again, possibly change me */
107 /* code context actions */
120 ACTION_WPS_PITCHSCREEN
,/* optional */
121 ACTION_WPS_ID3SCREEN
,/* optional */
123 ACTION_WPS_QUICKSCREEN
,/* optional */
124 ACTION_WPS_MENU
, /*this should be the same as ACTION_STD_MENU */
125 ACTION_WPS_VIEW_PLAYLIST
,
128 ACTION_WPSAB_SINGLE
, /* This needs to be #defined in
129 the config-<target>.h to one of the ACTION_WPS_ actions
132 ACTION_WPS_ABSETA_PREVDIR
, /* these should be safe to put together seen as */
133 ACTION_WPS_ABSETB_NEXTDIR
, /* you shouldnt want to change dir in ab-mode */
136 /* list and tree page up/down */
137 ACTION_LISTTREE_PGUP
,/* optional */
138 ACTION_LISTTREE_PGDOWN
,/* optional */
139 #ifdef HAVE_VOLUME_IN_LIST
145 ACTION_TREE_ROOT_INIT
,
146 ACTION_TREE_PGLEFT
,/* optional */
147 ACTION_TREE_PGRIGHT
,/* optional */
160 ACTION_FM_RECORD_DBLPRE
,
161 ACTION_FM_NEXT_PRESET
,
162 ACTION_FM_PREV_PRESET
,
164 /* recording screen */
172 /* These are not strictly actions, but must be here
173 so they dont conflict with real actions in the menu code */
174 ACTION_REQUEST_MENUITEM
,
175 ACTION_EXIT_MENUITEM
,
176 ACTION_EXIT_AFTER_THIS_MENUITEM
, /* if a menu returns this the menu will exit
177 once the subitem returns */
178 ACTION_ENTER_MENUITEM
,
186 ACTION_SETTINGS_INCREPEAT
,
187 ACTION_SETTINGS_INCBIGSTEP
,
189 ACTION_SETTINGS_DECREPEAT
,
190 ACTION_SETTINGS_DECBIGSTEP
,
191 ACTION_SETTINGS_RESET
,
193 /* bookmark screen */
203 /* obviously ignore if you dont have thise screen */
208 ACTION_PS_NUDGE_LEFT
,
209 ACTION_PS_NUDGE_RIGHT
,
210 ACTION_PS_NUDGE_LEFTOFF
,
211 ACTION_PS_NUDGE_RIGHTOFF
,
212 ACTION_PS_TOGGLE_MODE
,
214 ACTION_PS_EXIT
, /* _STD_* isnt going to work here */
221 /* keyboard screen */
224 ACTION_KBD_CURSOR_LEFT
,
225 ACTION_KBD_CURSOR_RIGHT
,
227 ACTION_KBD_SELECT_REM
,
228 ACTION_KBD_PAGE_FLIP
,
231 ACTION_KBD_BACKSPACE
,
234 ACTION_KBD_MORSE_INPUT
,
235 ACTION_KBD_MORSE_SELECT
,
237 #ifdef HAVE_TOUCHSCREEN
238 /* the following are helper actions for touchscreen targets,
239 * These are for actions which are not doable or required if buttons are
240 * being used, but are nice additions if the touchscreen is used */
241 ACTION_TOUCH_SHUFFLE
,
242 ACTION_TOUCH_REPMODE
,
246 ACTION_USB_HID_FIRST
, /* Place holder */
249 ACTION_USB_HID_START
,
250 ACTION_USB_HID_START_LONG
,
252 ACTION_USB_HID_QUIT_LONG
,
254 ACTION_USB_HID_LEFT_LONG
,
255 ACTION_USB_HID_RIGHT
,
256 ACTION_USB_HID_RIGHT_LONG
,
257 ACTION_USB_HID_SELECT
,
258 ACTION_USB_HID_SELECT_LONG
,
260 ACTION_USB_HID_MENU_LONG
,
262 ACTION_USB_HID_MODE_LONG
,
263 ACTION_USB_HID_MOUSE_UP
,
264 ACTION_USB_HID_MOUSE_UP_REP
,
265 ACTION_USB_HID_MOUSE_DOWN
,
266 ACTION_USB_HID_MOUSE_DOWN_REP
,
267 ACTION_USB_HID_MOUSE_LEFT
,
268 ACTION_USB_HID_MOUSE_LEFT_REP
,
269 ACTION_USB_HID_MOUSE_RIGHT
,
270 ACTION_USB_HID_MOUSE_RIGHT_REP
,
271 ACTION_USB_HID_MOUSE_LDRAG_UP
,
272 ACTION_USB_HID_MOUSE_LDRAG_UP_REP
,
273 ACTION_USB_HID_MOUSE_LDRAG_DOWN
,
274 ACTION_USB_HID_MOUSE_LDRAG_DOWN_REP
,
275 ACTION_USB_HID_MOUSE_LDRAG_LEFT
,
276 ACTION_USB_HID_MOUSE_LDRAG_LEFT_REP
,
277 ACTION_USB_HID_MOUSE_LDRAG_RIGHT
,
278 ACTION_USB_HID_MOUSE_LDRAG_RIGHT_REP
,
279 ACTION_USB_HID_MOUSE_RDRAG_UP
,
280 ACTION_USB_HID_MOUSE_RDRAG_UP_REP
,
281 ACTION_USB_HID_MOUSE_RDRAG_DOWN
,
282 ACTION_USB_HID_MOUSE_RDRAG_DOWN_REP
,
283 ACTION_USB_HID_MOUSE_RDRAG_LEFT
,
284 ACTION_USB_HID_MOUSE_RDRAG_LEFT_REP
,
285 ACTION_USB_HID_MOUSE_RDRAG_RIGHT
,
286 ACTION_USB_HID_MOUSE_RDRAG_RIGHT_REP
,
287 ACTION_USB_HID_MOUSE_BUTTON_LEFT
,
288 ACTION_USB_HID_MOUSE_BUTTON_LEFT_REL
,
289 ACTION_USB_HID_MOUSE_BUTTON_RIGHT
,
290 ACTION_USB_HID_MOUSE_BUTTON_RIGHT_REL
,
291 ACTION_USB_HID_MOUSE_WHEEL_SCROLL_UP
,
292 ACTION_USB_HID_MOUSE_WHEEL_SCROLL_DOWN
,
293 ACTION_USB_HID_LAST
, /* Place holder */
295 LAST_ACTION_PLACEHOLDER
, /* custom actions should be this + something */
298 struct button_mapping
{
303 /* use if you want to supply your own button mappings, PLUGINS ONLY */
304 /* get_context_map is a function which returns a button_mapping* depedning on the given context */
305 /* custom button_mappings may "chain" to inbuilt CONTEXT's */
306 int get_custom_action(int context
,int timeout
,
307 const struct button_mapping
* (*get_context_map
)(int));
308 /* use if one of the standard CONTEXT_ mappings will work (ALL the core should be using this! */
309 int get_action(int context
, int timeout
);
311 /* call this if you need to check for ACTION_STD_CANCEL only (i.e user abort! */
312 bool action_userabort(int timeout
);
314 /* no other code should need this apart from action.c */
315 const struct button_mapping
* get_context_mapping(int context
);
316 #ifndef HAS_BUTTON_HOLD
317 bool is_keys_locked(void);
320 /* returns the status code variable from action.c for the button just pressed
321 If button != NULL it will be set to the actual button code */
322 #define ACTION_REMOTE 0x1 /* remote was pressed */
323 #define ACTION_REPEAT 0x2 /* action was repeated (NOT button) */
324 int get_action_statuscode(int *button
);
326 /* returns the data value associated with the last action that is not
327 BUTTON_NONE or flagged with SYS_EVENT */
328 intptr_t get_action_data(void);
330 #ifdef HAVE_TOUCHSCREEN
331 /* return BUTTON_NONE on error
332 * BUTTON_REPEAT if repeated press
333 * BUTTON_REPEAT|BUTTON_REL if release after repeated press
334 * BUTTON_REL if its a short press = release after press
335 * BUTTON_TOUCHSCREEN if press
337 int action_get_touchscreen_press(short *x
, short *y
);
340 * wrapper action_get_touchscreen_press()
341 * to filter the touchscreen coordinates through a viewport
343 * returns the action and x1, y1 relative to the viewport if
344 * the press was within the viewport,
345 * ACTION_UNKNOWN (and x1, y1 untouched) if the press was outside
349 int action_get_touchscreen_press_in_vp(short *x1
, short *y1
, struct viewport
*vp
);
352 /* Don't let get_action*() return any ACTION_* values untill the current buttons
353 * have ben release. SYS_* and BUTTON_NONE will go through.
354 * Any actions relying on _RELEASE won't get seen
356 void action_wait_for_release(void);
358 #endif /* __ACTION_H__ */