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