Fully fill the table headers with color
[kugel-rb/myfork.git] / apps / action.h
blobeae5f1249b53279b122d510c7f5ab658dc4f4840
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"
26 #define TIMEOUT_BLOCK -1
27 #define TIMEOUT_NOBLOCK 0
29 #define CONTEXT_STOPSEARCHING 0xFFFFFFFF
30 #define CONTEXT_REMOTE 0x80000000 /* | this against another context to get remote buttons for that context */
31 #define CONTEXT_CUSTOM 0x40000000 /* | this against anything to get your context number */
32 #define CONTEXT_CUSTOM2 0x20000000 /* as above */
33 #define CONTEXT_PLUGIN 0x10000000 /* for plugins using get_custom_action */
35 #define LAST_ITEM_IN_LIST { CONTEXT_STOPSEARCHING, BUTTON_NONE, BUTTON_NONE }
36 #define LAST_ITEM_IN_LIST__NEXTLIST(a) { a, BUTTON_NONE, BUTTON_NONE }
38 #ifndef HAS_BUTTON_HOLD
39 #define ALLOW_SOFTLOCK 0x08000000 /* will be stripped.. never needed except in calls to get_action() */
40 #else
41 #define ALLOW_SOFTLOCK 0
42 #endif
44 enum {
45 CONTEXT_STD = 0,
46 /* These CONTEXT_ values were here before me,
47 there values may have significance, so dont touch! */
48 CONTEXT_WPS = 1,
49 CONTEXT_TREE = 2,
50 CONTEXT_RECORD = 3,
51 CONTEXT_MAINMENU = 4, /* uses CONTEXT_TREE and ACTION_TREE_* */
52 CONTEXT_ID3DB = 5,
53 /* Add new contexts here, no need to explicitly define a value for them */
54 CONTEXT_LIST,
55 CONTEXT_SETTINGS, /* regular setting screens (and debug screens) */
56 /* bellow are setting screens which may need to redefine the standard
57 setting screen keys, targets should return the CONTEXT_SETTINGS
58 keymap unless they are not adequate for the screen
59 NOTE: uses ACTION_STD_[NEXT|PREV] so make sure they are there also
60 and (possibly) ACTION_SETTINGS_[INC|DEC] */
61 CONTEXT_SETTINGS_EQ,
62 CONTEXT_SETTINGS_COLOURCHOOSER,
63 CONTEXT_SETTINGS_TIME,
64 CONTEXT_SETTINGS_RECTRIGGER,
66 /* The following contexts should use ACTION_STD_[NEXT|PREV]
67 and (possibly) ACTION_SETTINGS_[INC|DEC]
68 Also add any extra actions they need */
69 CONTEXT_BOOKMARKSCREEN, /* uses ACTION_BMS_ defines */
70 CONTEXT_ALARMSCREEN, /* uses ACTION_AS_ defines */
71 CONTEXT_QUICKSCREEN, /* uses ACTION_QS_ defines below */
72 CONTEXT_PITCHSCREEN, /* uses ACTION_PS_ defines below */
74 CONTEXT_YESNOSCREEN, /*NOTE: make sure your target has this and ACTION_YESNO_ACCEPT */
75 CONTEXT_RECSCREEN,
76 CONTEXT_KEYBOARD,
77 CONTEXT_FM,
78 CONTEXT_USB_HID,
82 enum {
84 ACTION_NONE = BUTTON_NONE,
85 ACTION_UNKNOWN,
86 ACTION_REDRAW, /* returned if keys are locked and we splash()'ed */
87 ACTION_TOUCHSCREEN,
88 ACTION_TOUCHSCREEN_MODE, /* toggle the touchscreen mode */
90 /* standard actions, use these first */
91 ACTION_STD_PREV,
92 ACTION_STD_PREVREPEAT,
93 ACTION_STD_NEXT,
94 ACTION_STD_NEXTREPEAT,
96 ACTION_STD_OK,
97 ACTION_STD_CANCEL,
98 ACTION_STD_CONTEXT,
99 ACTION_STD_MENU,
100 ACTION_STD_QUICKSCREEN,
101 ACTION_STD_KEYLOCK,
102 ACTION_STD_REC,
104 ACTION_F3, /* just so everything works again, possibly change me */
105 /* code context actions */
107 /* WPS codes */
108 ACTION_WPS_BROWSE,
109 ACTION_WPS_PLAY,
110 ACTION_WPS_SEEKBACK,
111 ACTION_WPS_SEEKFWD,
112 ACTION_WPS_STOPSEEK,
113 ACTION_WPS_SKIPNEXT,
114 ACTION_WPS_SKIPPREV,
115 ACTION_WPS_STOP,
116 ACTION_WPS_VOLDOWN,
117 ACTION_WPS_VOLUP,
118 ACTION_WPS_PITCHSCREEN,/* optional */
119 ACTION_WPS_ID3SCREEN,/* optional */
120 ACTION_WPS_CONTEXT,
121 ACTION_WPS_QUICKSCREEN,/* optional */
122 ACTION_WPS_MENU, /*this should be the same as ACTION_STD_MENU */
123 ACTION_WPS_VIEW_PLAYLIST,
124 ACTION_WPS_REC,
125 #if 0
126 ACTION_WPSAB_SINGLE, /* This needs to be #defined in
127 the config-<target>.h to one of the ACTION_WPS_ actions
128 so it can be used */
129 #endif
130 ACTION_WPS_ABSETA_PREVDIR, /* these should be safe to put together seen as */
131 ACTION_WPS_ABSETB_NEXTDIR, /* you shouldnt want to change dir in ab-mode */
132 ACTION_WPS_ABRESET,
134 /* list and tree page up/down */
135 ACTION_LISTTREE_PGUP,/* optional */
136 ACTION_LISTTREE_PGDOWN,/* optional */
137 #ifdef HAVE_VOLUME_IN_LIST
138 ACTION_LIST_VOLUP,
139 ACTION_LIST_VOLDOWN,
140 #endif
142 /* tree */
143 ACTION_TREE_ROOT_INIT,
144 ACTION_TREE_PGLEFT,/* optional */
145 ACTION_TREE_PGRIGHT,/* optional */
146 ACTION_TREE_STOP,
147 ACTION_TREE_WPS,
149 /* radio */
150 ACTION_FM_MENU,
151 ACTION_FM_PRESET,
152 ACTION_FM_RECORD,
153 ACTION_FM_FREEZE,
154 ACTION_FM_STOP,
155 ACTION_FM_MODE,
156 ACTION_FM_EXIT,
157 ACTION_FM_PLAY,
158 ACTION_FM_RECORD_DBLPRE,
159 ACTION_FM_NEXT_PRESET,
160 ACTION_FM_PREV_PRESET,
162 /* recording screen */
163 ACTION_REC_LCD,
164 ACTION_REC_PAUSE,
165 ACTION_REC_NEWFILE,
166 ACTION_REC_F2,
167 ACTION_REC_F3,
169 /* main menu */
170 /* These are not strictly actions, but must be here
171 so they dont conflict with real actions in the menu code */
172 ACTION_REQUEST_MENUITEM,
173 ACTION_EXIT_MENUITEM,
174 ACTION_EXIT_AFTER_THIS_MENUITEM, /* if a menu returns this the menu will exit
175 once the subitem returns */
176 ACTION_ENTER_MENUITEM,
178 /* id3db */
180 /* list */
182 /* settings */
183 ACTION_SETTINGS_INC,
184 ACTION_SETTINGS_INCREPEAT,
185 ACTION_SETTINGS_INCBIGSTEP,
186 ACTION_SETTINGS_DEC,
187 ACTION_SETTINGS_DECREPEAT,
188 ACTION_SETTINGS_DECBIGSTEP,
189 ACTION_SETTINGS_RESET,
191 /* bookmark screen */
192 ACTION_BMS_DELETE,
194 /* alarm menu screen */
196 /* quickscreen */
197 ACTION_QS_LEFT,
198 ACTION_QS_RIGHT,
199 ACTION_QS_DOWN,
200 ACTION_QS_DOWNINV, /* why is this not called up?? :p */
202 /* pitchscreen */
203 /* obviously ignore if you dont have thise screen */
204 ACTION_PS_INC_SMALL,
205 ACTION_PS_INC_BIG,
206 ACTION_PS_DEC_SMALL,
207 ACTION_PS_DEC_BIG,
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,
213 ACTION_PS_RESET,
214 ACTION_PS_EXIT, /* _STD_* isnt going to work here */
215 ACTION_PS_SLOWER,
216 ACTION_PS_FASTER,
218 /* yesno screen */
219 ACTION_YESNO_ACCEPT,
221 /* keyboard screen */
222 ACTION_KBD_LEFT,
223 ACTION_KBD_RIGHT,
224 ACTION_KBD_CURSOR_LEFT,
225 ACTION_KBD_CURSOR_RIGHT,
226 ACTION_KBD_SELECT,
227 ACTION_KBD_SELECT_REM,
228 ACTION_KBD_PAGE_FLIP,
229 ACTION_KBD_DONE,
230 ACTION_KBD_ABORT,
231 ACTION_KBD_BACKSPACE,
232 ACTION_KBD_UP,
233 ACTION_KBD_DOWN,
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,
243 #endif
245 /* USB HID codes */
246 ACTION_USB_HID_PLAY,
247 ACTION_USB_HID_STOP,
248 ACTION_USB_HID_SKIPPREV,
249 ACTION_USB_HID_SKIPNEXT,
250 ACTION_USB_HID_VOLDOWN,
251 ACTION_USB_HID_VOLUP,
252 ACTION_USB_HID_MUTE,
253 ACTION_USB_HID_MENU,
255 LAST_ACTION_PLACEHOLDER, /* custom actions should be this + something */
258 struct button_mapping {
259 int action_code;
260 int button_code;
261 int pre_button_code;
263 /* use if you want to supply your own button mappings, PLUGINS ONLY */
264 /* get_context_map is a function which returns a button_mapping* depedning on the given context */
265 /* custom button_mappings may "chain" to inbuilt CONTEXT's */
266 int get_custom_action(int context,int timeout,
267 const struct button_mapping* (*get_context_map)(int));
268 /* use if one of the standard CONTEXT_ mappings will work (ALL the core should be using this! */
269 int get_action(int context, int timeout);
271 /* call this if you need to check for ACTION_STD_CANCEL only (i.e user abort! */
272 bool action_userabort(int timeout);
274 /* no other code should need this apart from action.c */
275 const struct button_mapping* get_context_mapping(int context);
276 #ifndef HAS_BUTTON_HOLD
277 bool is_keys_locked(void);
278 #endif
280 /* returns the status code variable from action.c for the button just pressed
281 If button != NULL it will be set to the actual button code */
282 #define ACTION_REMOTE 0x1 /* remote was pressed */
283 #define ACTION_REPEAT 0x2 /* action was repeated (NOT button) */
284 int get_action_statuscode(int *button);
286 /* returns the data value associated with the last action that is not
287 BUTTON_NONE or flagged with SYS_EVENT */
288 intptr_t get_action_data(void);
290 #ifdef HAVE_TOUCHSCREEN
291 /* return BUTTON_NONE on error
292 BUTTON_REPEAT if repeated press
293 BUTTON_REL if its a short press
294 BUTTON_TOUCHSCREEN otherwise
296 int action_get_touchscreen_press(short *x, short *y);
297 #endif
299 /* Don't let get_action*() return any ACTION_* values untill the current buttons
300 * have ben release. SYS_* and BUTTON_NONE will go through.
301 * Any actions relying on _RELEASE won't get seen
303 void action_wait_for_release(void);
305 #endif /* __ACTION_H__ */