summaryrefslogtreecommitdiff
path: root/apps/action.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/action.c')
-rw-r--r--apps/action.c56
1 files changed, 55 insertions, 1 deletions
diff --git a/apps/action.c b/apps/action.c
index 5aeab25e1d..989313f41c 100644
--- a/apps/action.c
+++ b/apps/action.c
@@ -35,6 +35,10 @@ static intptr_t last_data = 0;
35static int last_action = ACTION_NONE; 35static int last_action = ACTION_NONE;
36static bool repeated = false; 36static bool repeated = false;
37 37
38#ifdef HAVE_TOUCHPAD
39static bool short_press = false;
40#endif
41
38#define REPEAT_WINDOW_TICKS HZ/10 42#define REPEAT_WINDOW_TICKS HZ/10
39static int last_action_tick = 0; 43static int last_action_tick = 0;
40 44
@@ -132,7 +136,25 @@ static int get_action_worker(int context, int timeout,
132 return ACTION_NONE; /* "safest" return value */ 136 return ACTION_NONE; /* "safest" return value */
133 } 137 }
134 last_context = context; 138 last_context = context;
135 139#ifdef HAVE_TOUCHPAD
140 if (button&BUTTON_TOUCHPAD)
141 {
142 repeated = false;
143 short_press = false;
144 if (last_button&BUTTON_TOUCHPAD)
145 {
146 if ((button&BUTTON_REL) &&
147 ((last_button&BUTTON_REPEAT)==0))
148 {
149 short_press = true;
150 }
151 else if (button&BUTTON_REPEAT)
152 repeated = true;
153 }
154 last_button = button;
155 return ACTION_TOUCHPAD;
156 }
157#endif
136#ifndef HAS_BUTTON_HOLD 158#ifndef HAS_BUTTON_HOLD
137 screen_has_lock = ((context&ALLOW_SOFTLOCK)==ALLOW_SOFTLOCK); 159 screen_has_lock = ((context&ALLOW_SOFTLOCK)==ALLOW_SOFTLOCK);
138 if (screen_has_lock && (keys_locked == true)) 160 if (screen_has_lock && (keys_locked == true))
@@ -250,3 +272,35 @@ int get_action_statuscode(int *button)
250 ret |= ACTION_REPEAT; 272 ret |= ACTION_REPEAT;
251 return ret; 273 return ret;
252} 274}
275
276#ifdef HAVE_TOUCHPAD
277/* return BUTTON_NONE on error
278 BUTTON_REPEAT if repeated press
279 BUTTON_REL if its a short press
280 BUTTON_TOUCHPAD otherwise
281*/
282int action_get_touchpad_press(short *x, short *y)
283{
284 static int last_data = 0;
285 int data;
286 if ((last_button&BUTTON_TOUCHPAD) == 0)
287 return BUTTON_NONE;
288 data = button_get_data();
289 if (last_button&BUTTON_REL)
290 {
291 *x = (last_data&0xffff0000)>>16;
292 *y = (last_data&0xffff);
293 }
294 else
295 {
296 *x = (data&0xffff0000)>>16;
297 *y = (data&0xffff);
298 }
299 last_data = data;
300 if (repeated)
301 return BUTTON_REPEAT;
302 if (short_press)
303 return BUTTON_REL;
304 return BUTTON_NONE;
305}
306#endif