CPU model must be compared to CONFIG_CPU.
[kugel-rb.git] / apps / action.h
blob96e8086baa49572cbfc9787644c847d17e7d392a
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2004 Brent Coutts
11 * All files in this archive are subject to the GNU General Public License.
12 * See the file COPYING in the source tree root for full license agreement.
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
17 ****************************************************************************/
18 #ifndef __ACTION_H__
19 #define __ACTION_H__
21 #include "stdbool.h"
22 #include "button.h"
24 #define TIMEOUT_BLOCK -1
25 #define TIMEOUT_NOBLOCK 0
27 #define CONTEXT_STOPSEARCHING 0xFFFFFFFF
28 #define CONTEXT_REMOTE 0x80000000 /* | this against another context to get remote buttons for that context */
29 #define CONTEXT_CUSTOM 0x40000000 /* | this against anything to get your context number */
30 #define CONTEXT_CUSTOM2 0x20000000 /* as above */
32 #define LAST_ITEM_IN_LIST { CONTEXT_STOPSEARCHING, BUTTON_NONE, BUTTON_NONE }
33 #define LAST_ITEM_IN_LIST__NEXTLIST(a) { a, BUTTON_NONE, BUTTON_NONE }
35 #ifndef HAS_BUTTON_HOLD
36 #define ALLOW_SOFTLOCK 0x10000000 /* will be stripped.. never needed except in calls to get_action() */
37 #else
38 #define ALLOW_SOFTLOCK 0
39 #endif
41 enum {
42 CONTEXT_STD = 0,
43 /* These CONTEXT_ values were here before me,
44 there values may have significance, so dont touch! */
45 CONTEXT_WPS = 1,
46 CONTEXT_TREE = 2,
47 CONTEXT_RECORD = 3,
48 CONTEXT_MAINMENU = 4, /* uses CONTEXT_TREE and ACTION_TREE_* */
49 CONTEXT_ID3DB = 5,
50 /* Add new contexts here, no need to explicitly define a value for them */
51 CONTEXT_LIST,
52 CONTEXT_SETTINGS, /* regular setting screens (and debug screens) */
53 /* bellow are setting screens which may need to redefine the standard
54 setting screen keys, targets should return the CONTEXT_SETTINGS
55 keymap unless they are not adequate for the screen
56 NOTE: uses ACTION_STD_[NEXT|PREV] so make sure they are there also
57 and (possibly) ACTION_SETTINGS_[INC|DEC] */
58 CONTEXT_SETTINGS_EQ,
59 CONTEXT_SETTINGS_COLOURCHOOSER,
60 CONTEXT_SETTINGS_TIME,
62 /* The following contexts should use ACTION_STD_[NEXT|PREV]
63 and (possibly) ACTION_SETTINGS_[INC|DEC]
64 Also add any extra actions they need */
65 CONTEXT_BOOKMARKSCREEN, /* uses ACTION_BMS_ defines */
66 CONTEXT_ALARMSCREEN, /* uses ACTION_AS_ defines */
67 CONTEXT_QUICKSCREEN, /* uses ACTION_QS_ defines below */
68 CONTEXT_PITCHSCREEN, /* uses ACTION_PS_ defines below */
70 CONTEXT_YESNOSCREEN, /*NOTE: make sure your target has this and ACTION_YESNO_ACCEPT */
71 CONTEXT_RECSCREEN,
72 CONTEXT_KEYBOARD,
73 CONTEXT_FM,
77 enum {
79 ACTION_NONE = BUTTON_NONE,
80 ACTION_UNKNOWN,
81 ACTION_REDRAW, /* returned if keys are locked and we splash()'ed */
82 ACTION_TOUCHPAD,
83 ACTION_TOUCHPAD_MODE, /* toggle the touchpad mode */
85 /* standard actions, use these first */
86 ACTION_STD_PREV,
87 ACTION_STD_PREVREPEAT,
88 ACTION_STD_NEXT,
89 ACTION_STD_NEXTREPEAT,
91 ACTION_STD_OK,
92 ACTION_STD_CANCEL,
93 ACTION_STD_CONTEXT,
94 ACTION_STD_MENU,
95 ACTION_STD_QUICKSCREEN,
96 ACTION_STD_KEYLOCK,
97 ACTION_STD_REC,
99 ACTION_F3, /* just so everything works again, possibly change me */
100 /* code context actions */
102 /* WPS codes */
103 ACTION_WPS_BROWSE,
104 ACTION_WPS_PLAY,
105 ACTION_WPS_SEEKBACK,
106 ACTION_WPS_SEEKFWD,
107 ACTION_WPS_STOPSEEK,
108 ACTION_WPS_SKIPNEXT,
109 ACTION_WPS_SKIPPREV,
110 ACTION_WPS_STOP,
111 ACTION_WPS_VOLDOWN,
112 ACTION_WPS_VOLUP,
113 ACTION_WPS_PITCHSCREEN,/* optional */
114 ACTION_WPS_ID3SCREEN,/* optional */
115 ACTION_WPS_CONTEXT,
116 ACTION_WPS_QUICKSCREEN,/* optional */
117 ACTION_WPS_MENU, /*this should be the same as ACTION_STD_MENU */
118 ACTION_WPS_REC,
119 #if 0
120 ACTION_WPSAB_SINGLE, /* This needs to be #defined in
121 the config-<target>.h to one of the ACTION_WPS_ actions
122 so it can be used */
123 #endif
124 ACTION_WPS_ABSETA_PREVDIR, /* these should be safe to put together seen as */
125 ACTION_WPS_ABSETB_NEXTDIR, /* you shouldnt want to change dir in ab-mode */
126 ACTION_WPS_ABRESET,
128 /* list and tree page up/down */
129 ACTION_LISTTREE_PGUP,/* optional */
130 ACTION_LISTTREE_PGDOWN,/* optional */
131 #ifdef HAVE_VOLUME_IN_LIST
132 ACTION_LIST_VOLUP,
133 ACTION_LIST_VOLDOWN,
134 #endif
136 /* tree */
137 ACTION_TREE_ROOT_INIT,
138 ACTION_TREE_PGLEFT,/* optional */
139 ACTION_TREE_PGRIGHT,/* optional */
140 ACTION_TREE_STOP,
141 ACTION_TREE_WPS,
143 /* radio */
144 ACTION_FM_MENU,
145 ACTION_FM_PRESET,
146 ACTION_FM_RECORD,
147 ACTION_FM_FREEZE,
148 ACTION_FM_STOP,
149 ACTION_FM_MODE,
150 ACTION_FM_EXIT,
151 ACTION_FM_PLAY,
152 ACTION_FM_RECORD_DBLPRE,
153 ACTION_FM_NEXT_PRESET,
154 ACTION_FM_PREV_PRESET,
156 /* recording screen */
157 ACTION_REC_LCD,
158 ACTION_REC_PAUSE,
159 ACTION_REC_NEWFILE,
160 ACTION_REC_F2,
161 ACTION_REC_F3,
163 /* main menu */
164 /* These are not strictly actions, but must be here
165 so they dont conflict with real actions in the menu code */
166 ACTION_REQUEST_MENUITEM,
167 ACTION_EXIT_MENUITEM,
168 ACTION_EXIT_AFTER_THIS_MENUITEM, /* if a menu returns this the menu will exit
169 once the subitem returns */
170 ACTION_ENTER_MENUITEM,
172 /* id3db */
174 /* list */
176 /* settings */
177 ACTION_SETTINGS_INC,
178 ACTION_SETTINGS_INCREPEAT,
179 ACTION_SETTINGS_INCBIGSTEP,
180 ACTION_SETTINGS_DEC,
181 ACTION_SETTINGS_DECREPEAT,
182 ACTION_SETTINGS_DECBIGSTEP,
183 ACTION_SETTINGS_RESET,
185 /* bookmark screen */
186 ACTION_BMS_DELETE,
188 /* alarm menu screen */
190 /* quickscreen */
191 ACTION_QS_LEFT,
192 ACTION_QS_RIGHT,
193 ACTION_QS_DOWN,
194 ACTION_QS_DOWNINV, /* why is this not called up?? :p */
196 /* pitchscreen */
197 /* obviously ignore if you dont have thise screen */
198 ACTION_PS_INC_SMALL,
199 ACTION_PS_INC_BIG,
200 ACTION_PS_DEC_SMALL,
201 ACTION_PS_DEC_BIG,
202 ACTION_PS_NUDGE_LEFT,
203 ACTION_PS_NUDGE_RIGHT,
204 ACTION_PS_NUDGE_LEFTOFF,
205 ACTION_PS_NUDGE_RIGHTOFF,
206 ACTION_PS_TOGGLE_MODE,
207 ACTION_PS_RESET,
208 ACTION_PS_EXIT, /* _STD_* isnt going to work here */
210 /* yesno screen */
211 ACTION_YESNO_ACCEPT,
213 /* keyboard screen */
214 ACTION_KBD_LEFT,
215 ACTION_KBD_RIGHT,
216 ACTION_KBD_CURSOR_LEFT,
217 ACTION_KBD_CURSOR_RIGHT,
218 ACTION_KBD_SELECT,
219 ACTION_KBD_SELECT_REM,
220 ACTION_KBD_PAGE_FLIP,
221 ACTION_KBD_DONE,
222 ACTION_KBD_ABORT,
223 ACTION_KBD_BACKSPACE,
224 ACTION_KBD_UP,
225 ACTION_KBD_DOWN,
226 ACTION_KBD_MORSE_INPUT,
227 ACTION_KBD_MORSE_SELECT,
230 LAST_ACTION_PLACEHOLDER, /* custom actions should be this + something */
233 struct button_mapping {
234 int action_code;
235 int button_code;
236 int pre_button_code;
238 /* use if you want to supply your own button mappings, PLUGINS ONLY */
239 /* get_context_map is a function which returns a button_mapping* depedning on the given context */
240 /* custom button_mappings may "chain" to inbuilt CONTEXT's */
241 int get_custom_action(int context,int timeout,
242 const struct button_mapping* (*get_context_map)(int));
243 /* use if one of the standard CONTEXT_ mappings will work (ALL the core should be using this! */
244 int get_action(int context, int timeout);
246 /* call this if you need to check for ACTION_STD_CANCEL only (i.e user abort! */
247 bool action_userabort(int timeout);
249 /* no other code should need this apart from action.c */
250 const struct button_mapping* get_context_mapping(int context);
251 #ifndef HAS_BUTTON_HOLD
252 bool is_keys_locked(void);
253 #endif
255 /* returns the status code variable from action.c for the button just pressed
256 If button != NULL it will be set to the actual button code */
257 #define ACTION_REMOTE 0x1 /* remote was pressed */
258 #define ACTION_REPEAT 0x2 /* action was repeated (NOT button) */
259 int get_action_statuscode(int *button);
261 /* returns the data value associated with the last action that is not
262 BUTTON_NONE or flagged with SYS_EVENT */
263 intptr_t get_action_data(void);
265 #ifdef HAVE_TOUCHPAD
266 /* return BUTTON_NONE on error
267 BUTTON_REPEAT if repeated press
268 BUTTON_REL if its a short press
269 BUTTON_TOUCHPAD otherwise
271 int action_get_touchpad_press(short *x, short *y);
272 #endif
274 #endif /* __ACTION_H__ */