Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 431 lines (385 sloc) 11.991 kb
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
bbb93d2 remove remote button checking for taregts with no remote
jdgordon authored
8 * $Id$
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
9 *
10 * Copyright (C) 2006 Jonathan Gordon
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
11 *
eeae738 Updated our source code header to explicitly mention that we are GPL v2 ...
bagder authored
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21 #include <stdio.h>
22 #include <string.h>
23 #include <stdlib.h>
24
25 #include "config.h"
bf6c597 forgot to translate the splash messages
jdgordon authored
26 #include "lang.h"
27
b616b8c redo how the statusbar updates are done. send the EVENT_GUI_ACTIONUPDATE...
jdgordon authored
28 #include "appevents.h"
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
29 #include "button.h"
30 #include "action.h"
31 #include "kernel.h"
32 #include "debug.h"
ca1b0c8 software keylock works again
jdgordon authored
33 #include "splash.h"
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
34 #include "settings.h"
35 #include "pcmbuf.h"
6e9040a call default_event_handler() in action_userabort() for events other than...
gevaerts authored
36 #include "misc.h"
6bb363e Invert buttons in RTL mode
tomers authored
37 #if defined(HAVE_LCD_BITMAP) && !defined(BOOTLOADER)
38 #include "language.h"
39 #endif
024f974 Add a action helper for touchscreen targets to only receive the touchpre...
kugel authored
40 #include "viewport.h"
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
41
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
42 static int last_button = BUTTON_NONE|BUTTON_REL; /* allow the ipod wheel to
c66d7a5 remove the need for action_signalscreenchange().
jdgordon authored
43 work on startup */
64366dc Wheel acceleration for e200. A general acceleration interface intended f...
jethead71 authored
44 static intptr_t last_data = 0;
c150fbe Add a function to get the actual button that was pressed (and some
jdgordon authored
45 static int last_action = ACTION_NONE;
46 static bool repeated = false;
38e8fab Fix the bug where the short-long fwd/back action would ffwd/rewind the n...
jdgordon authored
47 static bool wait_for_release = false;
ca1b0c8 software keylock works again
jdgordon authored
48
516a969 Commit FS#9308: differentiate between TOUCHPAD & TOUCHSCREEN
mcuelenaere authored
49 #ifdef HAVE_TOUCHSCREEN
386c1a9 First go at getting the touchpad working in the ui. lists only for now.
jdgordon authored
50 static bool short_press = false;
51 #endif
52
9ebff58 Fix FS#7242 - the action code now checks the time difference between eve...
jdgordon authored
53 #define REPEAT_WINDOW_TICKS HZ/10
54 static int last_action_tick = 0;
55
ca1b0c8 software keylock works again
jdgordon authored
56 /* software keylock stuff */
57 #ifndef HAS_BUTTON_HOLD
d801ff1 Action code: Made all private functions & variables static. Better modul...
amiconn authored
58 static bool keys_locked = false;
59 static int unlock_combo = BUTTON_NONE;
60 static bool screen_has_lock = false;
ca1b0c8 software keylock works again
jdgordon authored
61 #endif /* HAVE_SOFTWARE_KEYLOCK */
62
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
63 /*
64 * do_button_check is the worker function for get_default_action.
65 * returns ACTION_UNKNOWN or the requested return value from the list.
66 */
d801ff1 Action code: Made all private functions & variables static. Better modul...
amiconn authored
67 static inline int do_button_check(const struct button_mapping *items,
68 int button, int last_button, int *start)
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
69 {
70 int i = 0;
71 int ret = ACTION_UNKNOWN;
72
73 while (items[i].button_code != BUTTON_NONE)
74 {
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
75 if (items[i].button_code == button)
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
76 {
bc212ff Changed the button action code to allow both single-fire and multi-fire ...
amiconn authored
77 if ((items[i].pre_button_code == BUTTON_NONE)
78 || (items[i].pre_button_code == last_button))
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
79 {
80 ret = items[i].action_code;
81 break;
82 }
83 }
84 i++;
85 }
86 *start = i;
87 return ret;
88 }
89
1de00b3 Fix red: Invert buttons in RTL mode
tomers authored
90 #if defined(HAVE_LCD_BITMAP) && !defined(BOOTLOADER)
91 /*
92 * button is horizontally inverted to support RTL language if the given language
93 * and context combination require that
94 */
95 static int button_flip_horizontally(int context, int button)
96 {
97 int newbutton;
98
99 if (!(lang_is_rtl() && ((context == CONTEXT_STD) ||
fe36b35 RTL: Fix context regarded as bit-field value, resulted in wrong contexts...
tomers authored
100 (context == CONTEXT_TREE) || (context == CONTEXT_LIST) ||
101 (context == CONTEXT_MAINMENU))))
1de00b3 Fix red: Invert buttons in RTL mode
tomers authored
102 {
103 return button;
104 }
105
106 newbutton = button &
107 ~(BUTTON_LEFT | BUTTON_RIGHT
396ca9c RTL: No need to swap *scrollwheel* in simulator, as it is being simulate...
tomers authored
108 #if defined(BUTTON_SCROLL_BACK) && defined(BUTTON_SCROLL_FWD) && \
109 !defined(SIMULATOR)
1de00b3 Fix red: Invert buttons in RTL mode
tomers authored
110 | BUTTON_SCROLL_BACK | BUTTON_SCROLL_FWD
111 #endif
0831050 On RTL mode, flip + and - buttons (Cowon D2)
tomers authored
112 #if defined(BUTTON_MINUS) && defined(BUTTON_PLUS) && \
113 !defined(SIMULATOR)
114 | BUTTON_MINUS | BUTTON_PLUS
115 #endif
1de00b3 Fix red: Invert buttons in RTL mode
tomers authored
116 );
117
118 if (button & BUTTON_LEFT)
119 newbutton |= BUTTON_RIGHT;
120 if (button & BUTTON_RIGHT)
121 newbutton |= BUTTON_LEFT;
396ca9c RTL: No need to swap *scrollwheel* in simulator, as it is being simulate...
tomers authored
122 #if defined(BUTTON_SCROLL_BACK) && defined(BUTTON_SCROLL_FWD) && \
123 !defined(SIMULATOR)
1de00b3 Fix red: Invert buttons in RTL mode
tomers authored
124 if (button & BUTTON_SCROLL_BACK)
125 newbutton |= BUTTON_SCROLL_FWD;
126 if (button & BUTTON_SCROLL_FWD)
127 newbutton |= BUTTON_SCROLL_BACK;
128 #endif
0831050 On RTL mode, flip + and - buttons (Cowon D2)
tomers authored
129 #if defined(BUTTON_MINUS) && defined(BUTTON_PLUS) && \
130 !defined(SIMULATOR)
131 if (button & BUTTON_MINUS)
132 newbutton |= BUTTON_PLUS;
133 if (button & BUTTON_PLUS)
134 newbutton |= BUTTON_MINUS;
135 #endif
1de00b3 Fix red: Invert buttons in RTL mode
tomers authored
136
137 return newbutton;
138 }
139 #endif
140
d801ff1 Action code: Made all private functions & variables static. Better modul...
amiconn authored
141 static inline int get_next_context(const struct button_mapping *items, int i)
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
142 {
143 while (items[i].button_code != BUTTON_NONE)
144 i++;
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
145 return (items[i].action_code == ACTION_NONE ) ?
146 CONTEXT_STD :
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
147 items[i].action_code;
148 }
149 /*
150 * int get_action_worker(int context, struct button_mapping *user_mappings,
151 int timeout)
152 This function searches the button list for the given context for the just
153 pressed button.
154 If there is a match it returns the value from the list.
155 If there is no match..
156 the last item in the list "points" to the next context in a chain
157 so the "chain" is followed until the button is found.
158 putting ACTION_NONE will get CONTEXT_STD which is always the last list checked.
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
159
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
160 Timeout can be TIMEOUT_NOBLOCK to return immediatly
161 TIMEOUT_BLOCK to wait for a button press
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
162 Any number >0 to wait that many ticks for a press
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
163 */
d801ff1 Action code: Made all private functions & variables static. Better modul...
amiconn authored
164 static int get_action_worker(int context, int timeout,
165 const struct button_mapping* (*get_context_map)(int) )
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
166 {
bc212ff Changed the button action code to allow both single-fire and multi-fire ...
amiconn authored
167 const struct button_mapping *items = NULL;
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
168 int button;
169 int i=0;
170 int ret = ACTION_UNKNOWN;
c66d7a5 remove the need for action_signalscreenchange().
jdgordon authored
171 static int last_context = CONTEXT_STD;
b616b8c redo how the statusbar updates are done. send the EVENT_GUI_ACTIONUPDATE...
jdgordon authored
172
173
174 send_event(GUI_EVENT_ACTIONUPDATE, NULL);
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
175
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
176 if (timeout == TIMEOUT_NOBLOCK)
177 button = button_get(false);
178 else if (timeout == TIMEOUT_BLOCK)
179 button = button_get(true);
180 else
181 button = button_get_w_tmo(timeout);
182
64366dc Wheel acceleration for e200. A general acceleration interface intended f...
jethead71 authored
183 /* Data from sys events can be pulled with button_get_data */
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
184 if (button == BUTTON_NONE || button & SYS_EVENT)
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
185 return button;
38e8fab Fix the bug where the short-long fwd/back action would ffwd/rewind the n...
jdgordon authored
186 /* Don't send any buttons through untill we see the release event */
187 if (wait_for_release)
188 {
189 if (button&BUTTON_REL)
190 {
191 wait_for_release = false;
192 }
193 return ACTION_NONE;
194 }
195
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
196
197 #if CONFIG_CODEC == SWCODEC
198 /* Produce keyclick */
199 if (global_settings.keyclick && !(button & BUTTON_REL))
200 if (!(button & BUTTON_REPEAT) || global_settings.keyclick_repeats)
ebff7d6 Keyclick fixup take two. It is only 88 samples (2msec) long so keep a sm...
jethead71 authored
201 pcmbuf_beep(4000, KEYCLICK_DURATION, 2500*global_settings.keyclick);
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
202 #endif
203
204 if ((context != last_context) && ((last_button & BUTTON_REL) == 0))
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
205 {
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
206 if (button & BUTTON_REL)
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
207 {
c66d7a5 remove the need for action_signalscreenchange().
jdgordon authored
208 last_button = button;
209 last_action = ACTION_NONE;
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
210 }
c66d7a5 remove the need for action_signalscreenchange().
jdgordon authored
211 /* eat all buttons until the previous button was |BUTTON_REL
212 (also eat the |BUTTON_REL button) */
c0ea99f really fix the yes/no screen now, also id3 viewer shows the status bar
jdgordon authored
213 return ACTION_NONE; /* "safest" return value */
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
214 }
c66d7a5 remove the need for action_signalscreenchange().
jdgordon authored
215 last_context = context;
ca1b0c8 software keylock works again
jdgordon authored
216 #ifndef HAS_BUTTON_HOLD
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
217 screen_has_lock = ((context & ALLOW_SOFTLOCK) == ALLOW_SOFTLOCK);
cf12066 Simplify some redundant boolean expressions
bertrik authored
218 if (screen_has_lock && keys_locked)
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
219 {
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
220 if (button == unlock_combo)
ca1b0c8 software keylock works again
jdgordon authored
221 {
222 last_button = BUTTON_NONE;
223 keys_locked = false;
a83c935 FS#9281 Rename of splash functions.
nls authored
224 splash(HZ/2, str(LANG_KEYLOCK_OFF));
ca1b0c8 software keylock works again
jdgordon authored
225 return ACTION_REDRAW;
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
226 }
227 else
228 #if (BUTTON_REMOTE != 0)
229 if ((button & BUTTON_REMOTE) == 0)
bbb93d2 remove remote button checking for taregts with no remote
jdgordon authored
230 #endif
ca1b0c8 software keylock works again
jdgordon authored
231 {
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
232 if ((button & BUTTON_REL))
a83c935 FS#9281 Rename of splash functions.
nls authored
233 splash(HZ/2, str(LANG_KEYLOCK_ON));
ca1b0c8 software keylock works again
jdgordon authored
234 return ACTION_REDRAW;
235 }
236 }
237 context &= ~ALLOW_SOFTLOCK;
238 #endif /* HAS_BUTTON_HOLD */
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
239
d8b59f9 Touchscreen targets: fix software hold not locking touchscreen
mcuelenaere authored
240 #ifdef HAVE_TOUCHSCREEN
241 if (button & BUTTON_TOUCHSCREEN)
242 {
243 repeated = false;
244 short_press = false;
245 if (last_button & BUTTON_TOUCHSCREEN)
246 {
247 if ((button & BUTTON_REL) &&
248 ((last_button & BUTTON_REPEAT)==0))
249 {
250 short_press = true;
251 }
252 else if (button & BUTTON_REPEAT)
253 repeated = true;
254 }
255 last_button = button;
256 return ACTION_TOUCHSCREEN;
257 }
258 #endif
259
6bb363e Invert buttons in RTL mode
tomers authored
260 #if defined(HAVE_LCD_BITMAP) && !defined(BOOTLOADER)
1de00b3 Fix red: Invert buttons in RTL mode
tomers authored
261 button = button_flip_horizontally(context, button);
6bb363e Invert buttons in RTL mode
tomers authored
262 #endif
263
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
264 /* logf("%x,%x",last_button,button); */
b3d60cf Gigabeat S: Get remote keymaps up to snuff and working. Do a couple twea...
jethead71 authored
265 while (1)
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
266 {
267 /* logf("context = %x",context); */
268 #if (BUTTON_REMOTE != 0)
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
269 if (button & BUTTON_REMOTE)
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
270 context |= CONTEXT_REMOTE;
271 #endif
a0e342b Replace use of CONTEXT_CUSTOM by get_custom_action with new CONTEXT_PLUG...
unhelpful authored
272 if ((context & CONTEXT_PLUGIN) && get_context_map)
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
273 items = get_context_map(context);
274 else
275 items = get_context_mapping(context);
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
276
b3d60cf Gigabeat S: Get remote keymaps up to snuff and working. Do a couple twea...
jethead71 authored
277 if (items == NULL)
d557db3 Action lists no longer automatically "chain" to the CONTEXT_STD unless e...
jdgordon authored
278 break;
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
279
b3d60cf Gigabeat S: Get remote keymaps up to snuff and working. Do a couple twea...
jethead71 authored
280 ret = do_button_check(items,button,last_button,&i);
281
282 if (ret == ACTION_UNKNOWN)
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
283 {
284 context = get_next_context(items,i);
b3d60cf Gigabeat S: Get remote keymaps up to snuff and working. Do a couple twea...
jethead71 authored
285
286 if (context != (int)CONTEXT_STOPSEARCHING)
287 {
288 i = 0;
289 continue;
290 }
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
291 }
b3d60cf Gigabeat S: Get remote keymaps up to snuff and working. Do a couple twea...
jethead71 authored
292
293 /* Action was found or STOPSEARCHING was specified */
294 break;
295 }
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
296 /* DEBUGF("ret = %x\n",ret); */
ca1b0c8 software keylock works again
jdgordon authored
297 #ifndef HAS_BUTTON_HOLD
298 if (screen_has_lock && (ret == ACTION_STD_KEYLOCK))
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
299 {
ca1b0c8 software keylock works again
jdgordon authored
300 unlock_combo = button;
301 keys_locked = true;
a83c935 FS#9281 Rename of splash functions.
nls authored
302 splash(HZ/2, str(LANG_KEYLOCK_ON));
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
303
ca1b0c8 software keylock works again
jdgordon authored
304 button_clear_queue();
305 return ACTION_REDRAW;
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
306 }
ca1b0c8 software keylock works again
jdgordon authored
307 #endif
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
308 if ((current_tick - last_action_tick < REPEAT_WINDOW_TICKS)
9ebff58 Fix FS#7242 - the action code now checks the time difference between eve...
jdgordon authored
309 && (ret == last_action))
c150fbe Add a function to get the actual button that was pressed (and some
jdgordon authored
310 repeated = true;
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
311 else
c150fbe Add a function to get the actual button that was pressed (and some
jdgordon authored
312 repeated = false;
313
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
314 last_button = button;
02c4d6a Fix bug in action_getstatus() where it didnt store the last action so it
jdgordon authored
315 last_action = ret;
64366dc Wheel acceleration for e200. A general acceleration interface intended f...
jethead71 authored
316 last_data = button_get_data();
9ebff58 Fix FS#7242 - the action code now checks the time difference between eve...
jdgordon authored
317 last_action_tick = current_tick;
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
318 return ret;
319 }
320
321 int get_action(int context, int timeout)
322 {
323 return get_action_worker(context,timeout,NULL);
324 }
325
326 int get_custom_action(int context,int timeout,
bc212ff Changed the button action code to allow both single-fire and multi-fire ...
amiconn authored
327 const struct button_mapping* (*get_context_map)(int))
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
328 {
329 return get_action_worker(context,timeout,get_context_map);
330 }
331
332 bool action_userabort(int timeout)
333 {
334 int action = get_action_worker(CONTEXT_STD,timeout,NULL);
335 bool ret = (action == ACTION_STD_CANCEL);
6e9040a call default_event_handler() in action_userabort() for events other than...
gevaerts authored
336 if(!ret)
337 {
338 default_event_handler(action);
339 }
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
340 return ret;
341 }
342
ca1b0c8 software keylock works again
jdgordon authored
343 #ifndef HAS_BUTTON_HOLD
344 bool is_keys_locked(void)
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
345 {
cf12066 Simplify some redundant boolean expressions
bertrik authored
346 return (screen_has_lock && keys_locked);
5b3fe93 Finally, the new button action system is here, thanks to Jonathan Gordon...
linus authored
347 }
ca1b0c8 software keylock works again
jdgordon authored
348 #endif
c150fbe Add a function to get the actual button that was pressed (and some
jdgordon authored
349
64366dc Wheel acceleration for e200. A general acceleration interface intended f...
jethead71 authored
350 intptr_t get_action_data(void)
351 {
352 return last_data;
353 }
354
c150fbe Add a function to get the actual button that was pressed (and some
jdgordon authored
355 int get_action_statuscode(int *button)
356 {
357 int ret = 0;
358 if (button)
359 *button = last_button;
360
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
361 if (last_button & BUTTON_REMOTE)
c150fbe Add a function to get the actual button that was pressed (and some
jdgordon authored
362 ret |= ACTION_REMOTE;
363 if (repeated)
364 ret |= ACTION_REPEAT;
365 return ret;
366 }
386c1a9 First go at getting the touchpad working in the ui. lists only for now.
jdgordon authored
367
516a969 Commit FS#9308: differentiate between TOUCHPAD & TOUCHSCREEN
mcuelenaere authored
368 #ifdef HAVE_TOUCHSCREEN
554d5c3 1) Make touchscreen interface more intuitive
mcuelenaere authored
369 /* return BUTTON_NONE on error
370 * BUTTON_REPEAT if repeated press
371 * BUTTON_REPEAT|BUTTON_REL if release after repeated press
372 * BUTTON_REL if its a short press = release after press
516a969 Commit FS#9308: differentiate between TOUCHPAD & TOUCHSCREEN
mcuelenaere authored
373 * BUTTON_TOUCHSCREEN if press
554d5c3 1) Make touchscreen interface more intuitive
mcuelenaere authored
374 */
516a969 Commit FS#9308: differentiate between TOUCHPAD & TOUCHSCREEN
mcuelenaere authored
375 int action_get_touchscreen_press(short *x, short *y)
386c1a9 First go at getting the touchpad working in the ui. lists only for now.
jdgordon authored
376 {
377 static int last_data = 0;
378 int data;
516a969 Commit FS#9308: differentiate between TOUCHPAD & TOUCHSCREEN
mcuelenaere authored
379 if ((last_button & BUTTON_TOUCHSCREEN) == 0)
386c1a9 First go at getting the touchpad working in the ui. lists only for now.
jdgordon authored
380 return BUTTON_NONE;
381 data = button_get_data();
cfdbf59 Keyclick option (FS#7307). Disabled by default, go into System settings ...
pondlife authored
382 if (last_button & BUTTON_REL)
386c1a9 First go at getting the touchpad working in the ui. lists only for now.
jdgordon authored
383 {
384 *x = (last_data&0xffff0000)>>16;
385 *y = (last_data&0xffff);
386 }
387 else
388 {
389 *x = (data&0xffff0000)>>16;
390 *y = (data&0xffff);
391 }
392 last_data = data;
393 if (repeated)
394 return BUTTON_REPEAT;
395 if (short_press)
396 return BUTTON_REL;
554d5c3 1) Make touchscreen interface more intuitive
mcuelenaere authored
397 /* This is to return a BUTTON_REL after a BUTTON_REPEAT. */
9c67594 (Simulator) Touchscreen improvements.
mcuelenaere authored
398 if (last_button & BUTTON_REL)
22d24bf Even more touchscreen improvements.
mcuelenaere authored
399 return BUTTON_REPEAT|BUTTON_REL;
516a969 Commit FS#9308: differentiate between TOUCHPAD & TOUCHSCREEN
mcuelenaere authored
400 return BUTTON_TOUCHSCREEN;
386c1a9 First go at getting the touchpad working in the ui. lists only for now.
jdgordon authored
401 }
024f974 Add a action helper for touchscreen targets to only receive the touchpre...
kugel authored
402
403 int action_get_touchscreen_press_in_vp(short *x1, short *y1, struct viewport *vp)
404 {
405 short x, y;
406 int ret;
407
408 ret = action_get_touchscreen_press(&x, &y);
409
410 if (ret != BUTTON_NONE && viewport_point_within_vp(vp, x, y))
411 {
412 *x1 = x - vp->x;
413 *y1 = y - vp->y;
414 return ret;
415 }
416 if (ret & BUTTON_TOUCHSCREEN)
417 return ACTION_UNKNOWN;
418 return BUTTON_NONE;
419 }
386c1a9 First go at getting the touchpad working in the ui. lists only for now.
jdgordon authored
420 #endif
38e8fab Fix the bug where the short-long fwd/back action would ffwd/rewind the n...
jdgordon authored
421
422 /* Don't let get_action*() return any ACTION_* values untill the current buttons
423 * have ben release. SYS_* and BUTTON_NONE will go through.
424 * Any actions relying on _RELEASE won't get seen
425 */
426 void action_wait_for_release(void)
427 {
428 wait_for_release = true;
429 }
430
Something went wrong with that request. Please try again.