skin tags: fix the id3 track/disc numbers in conditionals
[maemo-rb.git] / apps / action.h
blobe54d5deacfd2b139ccafa38ea274f7264acd4565
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
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 ****************************************************************************/
20 #ifndef __ACTION_H__
21 #define __ACTION_H__
23 #include "stdbool.h"
24 #include "button.h"
25 #include "viewport.h"
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() */
41 #else
42 #define ALLOW_SOFTLOCK 0
43 #endif
45 enum {
46 CONTEXT_STD = 0,
47 /* These CONTEXT_ values were here before me,
48 there values may have significance, so dont touch! */
49 CONTEXT_WPS = 1,
50 CONTEXT_TREE = 2,
51 CONTEXT_RECORD = 3,
52 CONTEXT_MAINMENU = 4, /* uses CONTEXT_TREE and ACTION_TREE_* */
53 CONTEXT_ID3DB = 5,
54 /* Add new contexts here, no need to explicitly define a value for them */
55 CONTEXT_LIST,
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] */
62 CONTEXT_SETTINGS_EQ,
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 */
76 CONTEXT_RECSCREEN,
77 CONTEXT_KEYBOARD,
78 CONTEXT_MORSE_INPUT,
79 CONTEXT_FM,
80 CONTEXT_USB_HID,
81 CONTEXT_USB_HID_MODE_MULTIMEDIA,
82 CONTEXT_USB_HID_MODE_PRESENTATION,
83 CONTEXT_USB_HID_MODE_BROWSER,
84 CONTEXT_USB_HID_MODE_MOUSE,
88 enum {
90 ACTION_NONE = BUTTON_NONE,
91 ACTION_UNKNOWN,
92 ACTION_REDRAW, /* returned if keys are locked and we splash()'ed */
93 ACTION_TOUCHSCREEN,
94 ACTION_TOUCHSCREEN_MODE, /* toggle the touchscreen mode */
95 ACTION_TOUCHSCREEN_IGNORE, /* used for the 'none' action in skins */
97 /* standard actions, use these first */
98 ACTION_STD_PREV,
99 ACTION_STD_PREVREPEAT,
100 ACTION_STD_NEXT,
101 ACTION_STD_NEXTREPEAT,
103 ACTION_STD_OK,
104 ACTION_STD_CANCEL,
105 ACTION_STD_CONTEXT,
106 ACTION_STD_MENU,
107 ACTION_STD_QUICKSCREEN,
108 ACTION_STD_KEYLOCK,
109 ACTION_STD_REC,
110 ACTION_STD_HOTKEY,
112 ACTION_F3, /* just so everything works again, possibly change me */
113 /* code context actions */
115 /* WPS codes */
116 ACTION_WPS_BROWSE,
117 ACTION_WPS_PLAY,
118 ACTION_WPS_SEEKBACK,
119 ACTION_WPS_SEEKFWD,
120 ACTION_WPS_STOPSEEK,
121 ACTION_WPS_SKIPNEXT,
122 ACTION_WPS_SKIPPREV,
123 ACTION_WPS_STOP,
124 ACTION_WPS_VOLDOWN,
125 ACTION_WPS_VOLUP,
126 ACTION_WPS_PITCHSCREEN,/* optional */
127 ACTION_WPS_ID3SCREEN,/* optional */
128 ACTION_WPS_CONTEXT,
129 ACTION_WPS_QUICKSCREEN,/* optional */
130 ACTION_WPS_MENU, /*this should be the same as ACTION_STD_MENU */
131 ACTION_WPS_VIEW_PLAYLIST,
132 ACTION_WPS_LIST_BOOKMARKS,/* optional */
133 ACTION_WPS_CREATE_BOOKMARK,/* optional */
134 ACTION_WPS_REC,
135 #if 0
136 ACTION_WPSAB_SINGLE, /* This needs to be #defined in
137 the config-<target>.h to one of the ACTION_WPS_ actions
138 so it can be used */
139 #endif
140 ACTION_WPS_ABSETA_PREVDIR, /* these should be safe to put together seen as */
141 ACTION_WPS_ABSETB_NEXTDIR, /* you shouldnt want to change dir in ab-mode */
142 ACTION_WPS_ABRESET,
143 ACTION_WPS_HOTKEY,
145 /* list and tree page up/down */
146 ACTION_LISTTREE_PGUP,/* optional */
147 ACTION_LISTTREE_PGDOWN,/* optional */
148 #ifdef HAVE_VOLUME_IN_LIST
149 ACTION_LIST_VOLUP,
150 ACTION_LIST_VOLDOWN,
151 #endif
153 /* tree */
154 ACTION_TREE_ROOT_INIT,
155 ACTION_TREE_PGLEFT,/* optional */
156 ACTION_TREE_PGRIGHT,/* optional */
157 ACTION_TREE_STOP,
158 ACTION_TREE_WPS,
159 ACTION_TREE_HOTKEY,
161 /* radio */
162 ACTION_FM_MENU,
163 ACTION_FM_PRESET,
164 ACTION_FM_RECORD,
165 ACTION_FM_FREEZE,
166 ACTION_FM_STOP,
167 ACTION_FM_MODE,
168 ACTION_FM_EXIT,
169 ACTION_FM_PLAY,
170 ACTION_FM_RECORD_DBLPRE,
171 ACTION_FM_NEXT_PRESET,
172 ACTION_FM_PREV_PRESET,
174 /* recording screen */
175 ACTION_REC_LCD,
176 ACTION_REC_PAUSE,
177 ACTION_REC_NEWFILE,
178 ACTION_REC_F2,
179 ACTION_REC_F3,
181 /* main menu */
182 /* These are not strictly actions, but must be here
183 so they dont conflict with real actions in the menu code */
184 ACTION_REQUEST_MENUITEM,
185 ACTION_EXIT_MENUITEM,
186 ACTION_EXIT_AFTER_THIS_MENUITEM, /* if a menu returns this the menu will exit
187 once the subitem returns */
188 ACTION_ENTER_MENUITEM,
190 /* id3db */
192 /* list */
194 /* settings */
195 ACTION_SETTINGS_INC,
196 ACTION_SETTINGS_INCREPEAT,
197 ACTION_SETTINGS_INCBIGSTEP,
198 ACTION_SETTINGS_DEC,
199 ACTION_SETTINGS_DECREPEAT,
200 ACTION_SETTINGS_DECBIGSTEP,
201 ACTION_SETTINGS_RESET,
202 ACTION_SETTINGS_SET, /* Used by touchscreen targets */
204 /* bookmark screen */
205 ACTION_BMS_DELETE,
207 /* quickscreen */
208 ACTION_QS_LEFT,
209 ACTION_QS_RIGHT,
210 ACTION_QS_DOWN,
211 ACTION_QS_TOP,
213 /* pitchscreen */
214 /* obviously ignore if you dont have thise screen */
215 ACTION_PS_INC_SMALL,
216 ACTION_PS_INC_BIG,
217 ACTION_PS_DEC_SMALL,
218 ACTION_PS_DEC_BIG,
219 ACTION_PS_NUDGE_LEFT,
220 ACTION_PS_NUDGE_RIGHT,
221 ACTION_PS_NUDGE_LEFTOFF,
222 ACTION_PS_NUDGE_RIGHTOFF,
223 ACTION_PS_TOGGLE_MODE,
224 ACTION_PS_RESET,
225 ACTION_PS_EXIT, /* _STD_* isnt going to work here */
226 ACTION_PS_SLOWER,
227 ACTION_PS_FASTER,
229 /* yesno screen */
230 ACTION_YESNO_ACCEPT,
232 /* keyboard screen */
233 ACTION_KBD_LEFT,
234 ACTION_KBD_RIGHT,
235 ACTION_KBD_CURSOR_LEFT,
236 ACTION_KBD_CURSOR_RIGHT,
237 ACTION_KBD_SELECT,
238 ACTION_KBD_PAGE_FLIP,
239 ACTION_KBD_DONE,
240 ACTION_KBD_ABORT,
241 ACTION_KBD_BACKSPACE,
242 ACTION_KBD_UP,
243 ACTION_KBD_DOWN,
244 ACTION_KBD_MORSE_INPUT,
245 ACTION_KBD_MORSE_SELECT,
247 #ifdef HAVE_TOUCHSCREEN
248 /* the following are helper actions for touchscreen targets,
249 * These are for actions which are not doable or required if buttons are
250 * being used, but are nice additions if the touchscreen is used */
251 ACTION_TOUCH_SHUFFLE,
252 ACTION_TOUCH_REPMODE,
253 ACTION_TOUCH_MUTE,
254 ACTION_TOUCH_SCROLLBAR,
255 ACTION_TOUCH_VOLUME,
256 ACTION_TOUCH_SOFTLOCK,
257 ACTION_TOUCH_SETTING,
258 #endif
260 /* USB HID codes */
261 ACTION_USB_HID_FIRST, /* Place holder */
262 ACTION_USB_HID_NONE,
263 ACTION_USB_HID_MODE_SWITCH_NEXT,
264 ACTION_USB_HID_MODE_SWITCH_PREV,
265 ACTION_USB_HID_MULTIMEDIA_VOLUME_UP,
266 ACTION_USB_HID_MULTIMEDIA_VOLUME_DOWN,
267 ACTION_USB_HID_MULTIMEDIA_VOLUME_MUTE,
268 ACTION_USB_HID_MULTIMEDIA_PLAYBACK_PLAY_PAUSE,
269 ACTION_USB_HID_MULTIMEDIA_PLAYBACK_STOP,
270 ACTION_USB_HID_MULTIMEDIA_PLAYBACK_TRACK_PREV,
271 ACTION_USB_HID_MULTIMEDIA_PLAYBACK_TRACK_NEXT,
272 ACTION_USB_HID_PRESENTATION_SLIDESHOW_START,
273 ACTION_USB_HID_PRESENTATION_SLIDESHOW_LEAVE,
274 ACTION_USB_HID_PRESENTATION_SLIDE_PREV,
275 ACTION_USB_HID_PRESENTATION_SLIDE_NEXT,
276 ACTION_USB_HID_PRESENTATION_SLIDE_FIRST,
277 ACTION_USB_HID_PRESENTATION_SLIDE_LAST,
278 ACTION_USB_HID_PRESENTATION_SCREEN_BLACK,
279 ACTION_USB_HID_PRESENTATION_SCREEN_WHITE,
280 ACTION_USB_HID_PRESENTATION_LINK_PREV,
281 ACTION_USB_HID_PRESENTATION_LINK_NEXT,
282 ACTION_USB_HID_PRESENTATION_MOUSE_CLICK,
283 ACTION_USB_HID_PRESENTATION_MOUSE_OVER,
284 ACTION_USB_HID_BROWSER_SCROLL_UP,
285 ACTION_USB_HID_BROWSER_SCROLL_DOWN,
286 ACTION_USB_HID_BROWSER_SCROLL_PAGE_DOWN,
287 ACTION_USB_HID_BROWSER_SCROLL_PAGE_UP,
288 ACTION_USB_HID_BROWSER_ZOOM_IN,
289 ACTION_USB_HID_BROWSER_ZOOM_OUT,
290 ACTION_USB_HID_BROWSER_ZOOM_RESET,
291 ACTION_USB_HID_BROWSER_TAB_PREV,
292 ACTION_USB_HID_BROWSER_TAB_NEXT,
293 ACTION_USB_HID_BROWSER_TAB_CLOSE,
294 ACTION_USB_HID_BROWSER_HISTORY_BACK,
295 ACTION_USB_HID_BROWSER_HISTORY_FORWARD,
296 ACTION_USB_HID_BROWSER_VIEW_FULL_SCREEN,
297 ACTION_USB_HID_MOUSE_UP,
298 ACTION_USB_HID_MOUSE_UP_REP,
299 ACTION_USB_HID_MOUSE_DOWN,
300 ACTION_USB_HID_MOUSE_DOWN_REP,
301 ACTION_USB_HID_MOUSE_LEFT,
302 ACTION_USB_HID_MOUSE_LEFT_REP,
303 ACTION_USB_HID_MOUSE_RIGHT,
304 ACTION_USB_HID_MOUSE_RIGHT_REP,
305 ACTION_USB_HID_MOUSE_LDRAG_UP,
306 ACTION_USB_HID_MOUSE_LDRAG_UP_REP,
307 ACTION_USB_HID_MOUSE_LDRAG_DOWN,
308 ACTION_USB_HID_MOUSE_LDRAG_DOWN_REP,
309 ACTION_USB_HID_MOUSE_LDRAG_LEFT,
310 ACTION_USB_HID_MOUSE_LDRAG_LEFT_REP,
311 ACTION_USB_HID_MOUSE_LDRAG_RIGHT,
312 ACTION_USB_HID_MOUSE_LDRAG_RIGHT_REP,
313 ACTION_USB_HID_MOUSE_RDRAG_UP,
314 ACTION_USB_HID_MOUSE_RDRAG_UP_REP,
315 ACTION_USB_HID_MOUSE_RDRAG_DOWN,
316 ACTION_USB_HID_MOUSE_RDRAG_DOWN_REP,
317 ACTION_USB_HID_MOUSE_RDRAG_LEFT,
318 ACTION_USB_HID_MOUSE_RDRAG_LEFT_REP,
319 ACTION_USB_HID_MOUSE_RDRAG_RIGHT,
320 ACTION_USB_HID_MOUSE_RDRAG_RIGHT_REP,
321 ACTION_USB_HID_MOUSE_BUTTON_LEFT,
322 ACTION_USB_HID_MOUSE_BUTTON_LEFT_REL,
323 ACTION_USB_HID_MOUSE_BUTTON_RIGHT,
324 ACTION_USB_HID_MOUSE_BUTTON_RIGHT_REL,
325 ACTION_USB_HID_MOUSE_WHEEL_SCROLL_UP,
326 ACTION_USB_HID_MOUSE_WHEEL_SCROLL_DOWN,
327 ACTION_USB_HID_LAST, /* Place holder */
329 LAST_ACTION_PLACEHOLDER, /* custom actions should be this + something */
332 struct button_mapping {
333 int action_code;
334 int button_code;
335 int pre_button_code;
337 /* use if you want to supply your own button mappings, PLUGINS ONLY */
338 /* get_context_map is a function which returns a button_mapping* depedning on the given context */
339 /* custom button_mappings may "chain" to inbuilt CONTEXT's */
340 int get_custom_action(int context,int timeout,
341 const struct button_mapping* (*get_context_map)(int));
342 /* use if one of the standard CONTEXT_ mappings will work (ALL the core should be using this! */
343 int get_action(int context, int timeout);
345 /* call this if you need to check for ACTION_STD_CANCEL only (i.e user abort! */
346 bool action_userabort(int timeout);
348 /* no other code should need this apart from action.c */
349 const struct button_mapping* get_context_mapping(int context);
350 #ifndef HAS_BUTTON_HOLD
351 bool is_keys_locked(void);
352 #endif
354 /* returns the status code variable from action.c for the button just pressed
355 If button != NULL it will be set to the actual button code */
356 #define ACTION_REMOTE 0x1 /* remote was pressed */
357 #define ACTION_REPEAT 0x2 /* action was repeated (NOT button) */
358 int get_action_statuscode(int *button);
360 /* returns the data value associated with the last action that is not
361 BUTTON_NONE or flagged with SYS_EVENT */
362 intptr_t get_action_data(void);
364 #ifdef HAVE_TOUCHSCREEN
365 /* return BUTTON_NONE on error
366 * BUTTON_REPEAT if repeated press
367 * BUTTON_REPEAT|BUTTON_REL if release after repeated press
368 * BUTTON_REL if it's a short press = release after press
369 * BUTTON_TOUCHSCREEN if press
371 int action_get_touchscreen_press(short *x, short *y);
374 * wrapper action_get_touchscreen_press()
375 * to filter the touchscreen coordinates through a viewport
377 * returns the action and x1, y1 relative to the viewport if
378 * the press was within the viewport,
379 * ACTION_UNKNOWN (and x1, y1 untouched) if the press was outside
380 * BUTTON_NONE else
383 int action_get_touchscreen_press_in_vp(short *x1, short *y1, struct viewport *vp);
384 #endif
386 /* Don't let get_action*() return any ACTION_* values until the current buttons
387 * have been released. SYS_* and BUTTON_NONE will go through.
388 * Any actions relying on _RELEASE won't get seen.
390 void action_wait_for_release(void);
392 #endif /* __ACTION_H__ */