Wheel acceleration for e200. A general acceleration interface intended for use on...
[Rockbox.git] / apps / action.h
blob5beacaa0e257360cbbc4d040a30a803eadde0a99
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 */
31 #define LAST_ITEM_IN_LIST { CONTEXT_STOPSEARCHING, BUTTON_NONE, BUTTON_NONE }
32 #define LAST_ITEM_IN_LIST__NEXTLIST(a) { a, BUTTON_NONE, BUTTON_NONE }
34 #ifndef HAS_BUTTON_HOLD
35 #define ALLOW_SOFTLOCK 0x20000000 /* will be stripped.. never needed except in calls to get_action() */
36 #else
37 #define ALLOW_SOFTLOCK 0
38 #endif
40 enum {
41 CONTEXT_STD = 0,
42 /* These CONTEXT_ values were here before me,
43 there values may have significance, so dont touch! */
44 CONTEXT_WPS = 1,
45 CONTEXT_TREE = 2,
46 CONTEXT_RECORD = 3,
47 CONTEXT_MAINMENU = 4, /* uses CONTEXT_TREE and ACTION_TREE_* */
48 CONTEXT_ID3DB = 5,
49 /* Add new contexts here, no need to explicitly define a value for them */
50 CONTEXT_LIST,
51 CONTEXT_SETTINGS, /* regular setting screens (and debug screens) */
52 /* bellow are setting screens which may need to redefine the standard
53 setting screen keys, targets should return the CONTEXT_SETTINGS
54 keymap unless they are not adequate for the screen
55 NOTE: uses ACTION_STD_[NEXT|PREV] so make sure they are there also
56 and (possibly) ACTION_SETTINGS_[INC|DEC] */
57 CONTEXT_SETTINGS_EQ,
58 CONTEXT_SETTINGS_COLOURCHOOSER,
59 CONTEXT_SETTINGS_TIME,
61 /* The following contexts should use ACTION_STD_[NEXT|PREV]
62 and (possibly) ACTION_SETTINGS_[INC|DEC]
63 Also add any extra actions they need */
64 CONTEXT_BOOKMARKSCREEN, /* uses ACTION_BMS_ defines */
65 CONTEXT_ALARMSCREEN, /* uses ACTION_AS_ defines */
66 CONTEXT_QUICKSCREEN, /* uses ACTION_QS_ defines below */
67 CONTEXT_PITCHSCREEN, /* uses ACTION_PS_ defines below */
69 CONTEXT_YESNOSCREEN, /*NOTE: make sure your target has this and ACTION_YESNO_ACCEPT */
70 CONTEXT_RECSCREEN,
71 CONTEXT_KEYBOARD,
72 CONTEXT_FM,
76 enum {
78 ACTION_NONE = BUTTON_NONE,
79 ACTION_UNKNOWN,
80 ACTION_REDRAW, /* returned if keys are locked and we splash()'ed */
82 /* standard actions, use these first */
83 ACTION_STD_PREV,
84 ACTION_STD_PREVREPEAT,
85 ACTION_STD_NEXT,
86 ACTION_STD_NEXTREPEAT,
88 ACTION_STD_OK,
89 ACTION_STD_CANCEL,
90 ACTION_STD_CONTEXT,
91 ACTION_STD_MENU,
92 ACTION_STD_QUICKSCREEN,
93 ACTION_STD_KEYLOCK,
95 ACTION_F3, /* just so everything works again, possibly change me */
96 /* code context actions */
98 /* WPS codes */
99 ACTION_WPS_BROWSE,
100 ACTION_WPS_PLAY,
101 ACTION_WPS_SEEKBACK,
102 ACTION_WPS_SEEKFWD,
103 ACTION_WPS_STOPSEEK,
104 ACTION_WPS_SKIPNEXT,
105 ACTION_WPS_SKIPPREV,
106 ACTION_WPS_STOP,
107 ACTION_WPS_VOLDOWN,
108 ACTION_WPS_VOLUP,
109 ACTION_WPS_PITCHSCREEN,/* optional */
110 ACTION_WPS_ID3SCREEN,/* optional */
111 ACTION_WPS_CONTEXT,
112 ACTION_WPS_QUICKSCREEN,/* optional */
113 ACTION_WPS_MENU, /*this should be the same as ACTION_STD_MENU */
114 #if 0
115 ACTION_WPSAB_SINGLE, /* This needs to be #defined in
116 the config-<target>.h to one of the ACTION_WPS_ actions
117 so it can be used */
118 #endif
119 ACTION_WPS_ABSETA_PREVDIR, /* these should be safe to put together seen as */
120 ACTION_WPS_ABSETB_NEXTDIR, /* you shouldnt want to change dir in ab-mode */
121 ACTION_WPS_ABRESET,
123 /* list and tree page up/down */
124 ACTION_LISTTREE_PGUP,/* optional */
125 ACTION_LISTTREE_PGDOWN,/* optional */
126 #ifdef HAVE_VOLUME_IN_LIST
127 ACTION_LIST_VOLUP,
128 ACTION_LIST_VOLDOWN,
129 #endif
131 /* tree */
132 ACTION_TREE_ROOT_INIT,
133 ACTION_TREE_PGLEFT,/* optional */
134 ACTION_TREE_PGRIGHT,/* optional */
135 ACTION_TREE_STOP,
136 ACTION_TREE_WPS,
138 /* radio */
139 ACTION_FM_MENU,
140 ACTION_FM_PRESET,
141 ACTION_FM_RECORD,
142 ACTION_FM_FREEZE,
143 ACTION_FM_STOP,
144 ACTION_FM_MODE,
145 ACTION_FM_EXIT,
146 ACTION_FM_PLAY,
147 ACTION_FM_RECORD_DBLPRE,
148 ACTION_FM_NEXT_PRESET,
149 ACTION_FM_PREV_PRESET,
151 /* recording screen */
152 ACTION_REC_LCD,
153 ACTION_REC_PAUSE,
154 ACTION_REC_NEWFILE,
155 ACTION_REC_F2,
156 ACTION_REC_F3,
158 /* main menu */
159 /* These are not strictly actions, but must be here
160 so they dont conflict with real actions in the menu code */
161 ACTION_REQUEST_MENUITEM,
162 ACTION_EXIT_MENUITEM,
163 ACTION_EXIT_AFTER_THIS_MENUITEM, /* if a menu returns this the menu will exit
164 once the subitem returns */
165 ACTION_ENTER_MENUITEM,
167 /* id3db */
169 /* list */
171 /* settings */
172 ACTION_SETTINGS_INC,
173 ACTION_SETTINGS_INCREPEAT,
174 ACTION_SETTINGS_INCBIGSTEP,
175 ACTION_SETTINGS_DEC,
176 ACTION_SETTINGS_DECREPEAT,
177 ACTION_SETTINGS_DECBIGSTEP,
178 ACTION_SETTINGS_RESET,
180 /* bookmark screen */
181 ACTION_BMS_DELETE,
183 /* alarm menu screen */
185 /* quickscreen */
186 ACTION_QS_LEFT,
187 ACTION_QS_RIGHT,
188 ACTION_QS_DOWN,
189 ACTION_QS_DOWNINV, /* why is this not called up?? :p */
191 /* pitchscreen */
192 /* obviously ignore if you dont have thise screen */
193 ACTION_PS_INC_SMALL,
194 ACTION_PS_INC_BIG,
195 ACTION_PS_DEC_SMALL,
196 ACTION_PS_DEC_BIG,
197 ACTION_PS_NUDGE_LEFT,
198 ACTION_PS_NUDGE_RIGHT,
199 ACTION_PS_NUDGE_LEFTOFF,
200 ACTION_PS_NUDGE_RIGHTOFF,
201 ACTION_PS_TOGGLE_MODE,
202 ACTION_PS_RESET,
203 ACTION_PS_EXIT, /* _STD_* isnt going to work here */
205 /* yesno screen */
206 ACTION_YESNO_ACCEPT,
208 /* keyboard screen */
209 ACTION_KBD_LEFT,
210 ACTION_KBD_RIGHT,
211 ACTION_KBD_CURSOR_LEFT,
212 ACTION_KBD_CURSOR_RIGHT,
213 ACTION_KBD_SELECT,
214 ACTION_KBD_SELECT_REM,
215 ACTION_KBD_PAGE_FLIP,
216 ACTION_KBD_DONE,
217 ACTION_KBD_ABORT,
218 ACTION_KBD_BACKSPACE,
219 ACTION_KBD_UP,
220 ACTION_KBD_DOWN,
221 ACTION_KBD_MORSE_INPUT,
222 ACTION_KBD_MORSE_SELECT,
225 LAST_ACTION_PLACEHOLDER, /* custom actions should be this + something */
228 struct button_mapping {
229 int action_code;
230 int button_code;
231 int pre_button_code;
233 /* use if you want to supply your own button mappings, PLUGINS ONLY */
234 /* get_context_map is a function which returns a button_mapping* depedning on the given context */
235 /* custom button_mappings may "chain" to inbuilt CONTEXT's */
236 int get_custom_action(int context,int timeout,
237 const struct button_mapping* (*get_context_map)(int));
238 /* use if one of the standard CONTEXT_ mappings will work (ALL the core should be using this! */
239 int get_action(int context, int timeout);
241 /* call this if you need to check for ACTION_STD_CANCEL only (i.e user abort! */
242 bool action_userabort(int timeout);
244 /* no other code should need this apart from action.c */
245 const struct button_mapping* get_context_mapping(int context);
246 #ifndef HAS_BUTTON_HOLD
247 bool is_keys_locked(void);
248 #endif
250 /* returns the status code variable from action.c for the button just pressed
251 If button != NULL it will be set to the actual button code */
252 #define ACTION_REMOTE 0x1 /* remote was pressed */
253 #define ACTION_REPEAT 0x2 /* action was repeated (NOT button) */
254 int get_action_statuscode(int *button);
256 /* returns the data value associated with the last action that is not
257 BUTTON_NONE or flagged with SYS_EVENT */
258 intptr_t get_action_data(void);
260 #endif /* __ACTION_H__ */