diff options
-rw-r--r-- | apps/action.c | 75 |
1 files changed, 46 insertions, 29 deletions
diff --git a/apps/action.c b/apps/action.c index 5533c00241..b31c4fa927 100644 --- a/apps/action.c +++ b/apps/action.c | |||
@@ -405,6 +405,7 @@ static inline bool get_action_touchscreen(action_last_t *last, action_cur_t *cur | |||
405 | } | 405 | } |
406 | 406 | ||
407 | last->button = cur->button; | 407 | last->button = cur->button; |
408 | last->tick = current_tick; | ||
408 | cur->action = ACTION_TOUCHSCREEN; | 409 | cur->action = ACTION_TOUCHSCREEN; |
409 | return true; | 410 | return true; |
410 | } | 411 | } |
@@ -684,13 +685,25 @@ static inline int do_auto_softlock(action_last_t *last, action_cur_t *cur) | |||
684 | { | 685 | { |
685 | do_key_lock(true); | 686 | do_key_lock(true); |
686 | 687 | ||
687 | #if defined(HAVE_TOUCHPAD) | 688 | #if defined(HAVE_TOUCHPAD) || defined(HAVE_TOUCHSCREEN) |
688 | /* if the touchpad is supposed to be off and the current buttonpress | 689 | /* if the touchpad is supposed to be off and the current buttonpress |
689 | * is from the touchpad, nullify both button and action. */ | 690 | * is from the touchpad, nullify both button and action. */ |
690 | if (!has_flag(action_last.softlock_mask, SEL_ACTION_ENABLED) || | 691 | if (!has_flag(action_last.softlock_mask, SEL_ACTION_ENABLED) || |
691 | has_flag(action_last.softlock_mask, SEL_ACTION_NOTOUCH)) | 692 | has_flag(action_last.softlock_mask, SEL_ACTION_NOTOUCH)) |
692 | { | 693 | { |
694 | #if defined(HAVE_TOUCHPAD) | ||
693 | cur->button = touchpad_filter(cur->button); | 695 | cur->button = touchpad_filter(cur->button); |
696 | #endif | ||
697 | #if defined(HAVE_TOUCHSCREEN) | ||
698 | const int touch_fakebuttons = | ||
699 | BUTTON_TOPLEFT | BUTTON_TOPMIDDLE | BUTTON_TOPRIGHT | | ||
700 | BUTTON_LEFT | BUTTON_CENTER | BUTTON_RIGHT | | ||
701 | BUTTON_BOTTOMLEFT | BUTTON_BOTTOMMIDDLE | BUTTON_BOTTOMRIGHT; | ||
702 | if (has_flag(cur->button, BUTTON_TOUCHSCREEN)) | ||
703 | cur->button = BUTTON_NONE; | ||
704 | else | ||
705 | cur->button &= ~touch_fakebuttons; | ||
706 | #endif | ||
694 | if (cur->button == BUTTON_NONE) | 707 | if (cur->button == BUTTON_NONE) |
695 | { | 708 | { |
696 | action = ACTION_NONE; | 709 | action = ACTION_NONE; |
@@ -1008,6 +1021,7 @@ static int get_action_worker(action_last_t *last, action_cur_t *cur) | |||
1008 | 1021 | ||
1009 | if (get_action_touchscreen(last, cur)) | 1022 | if (get_action_touchscreen(last, cur)) |
1010 | { | 1023 | { |
1024 | do_softlock(last, cur); | ||
1011 | return cur->action; | 1025 | return cur->action; |
1012 | } | 1026 | } |
1013 | 1027 | ||
@@ -1214,41 +1228,44 @@ void set_selective_softlock_actions(bool selective, unsigned int mask) | |||
1214 | } | 1228 | } |
1215 | } | 1229 | } |
1216 | 1230 | ||
1217 | 1231 | /* look for an action in the given context, return button which triggers it. | |
1218 | void action_autosoftlock_init(void) | 1232 | * (note: pre_button isn't taken into account here) */ |
1233 | static int find_button_for_action(int context, int action) | ||
1219 | { | 1234 | { |
1220 | action_cur_t cur; | 1235 | const struct button_mapping *items; |
1221 | int i = 0; | 1236 | int i; |
1222 | 1237 | ||
1223 | if (action_last.unlock_combo == BUTTON_NONE) | 1238 | do |
1224 | { | 1239 | { |
1225 | /* search CONTEXT_WPS, should be here */ | 1240 | items = get_context_mapping(context); |
1226 | cur.items = get_context_mapping(CONTEXT_WPS); | 1241 | if (items == NULL) |
1227 | while (cur.items[i].button_code != BUTTON_NONE) | 1242 | break; |
1243 | |||
1244 | for (i = 0; items[i].button_code != BUTTON_NONE; ++i) | ||
1228 | { | 1245 | { |
1229 | if (cur.items[i].action_code == ACTION_STD_KEYLOCK) | 1246 | if (items[i].action_code == action) |
1230 | { | 1247 | return items[i].button_code; |
1231 | action_last.unlock_combo = cur.items[i].button_code; | ||
1232 | break; | ||
1233 | } | ||
1234 | i = i + 1; | ||
1235 | } | 1248 | } |
1236 | 1249 | ||
1237 | /* not there... let's try std | 1250 | /* get chained context, if none it will be CONTEXT_STOPSEARCHING */ |
1238 | * I doubt any targets will need this, but... */ | 1251 | context = items[i].action_code; |
1239 | if (action_last.unlock_combo == BUTTON_NONE) | 1252 | } while (context != (int)CONTEXT_STOPSEARCHING); |
1253 | |||
1254 | return BUTTON_NONE; | ||
1255 | } | ||
1256 | |||
1257 | void action_autosoftlock_init(void) | ||
1258 | { | ||
1259 | /* search in WPS and STD contexts for the keylock button combo */ | ||
1260 | static const int contexts[2] = { CONTEXT_WPS, CONTEXT_STD }; | ||
1261 | |||
1262 | for (int i = 0; i < 2; ++i) | ||
1263 | { | ||
1264 | int button = find_button_for_action(contexts[i], ACTION_STD_KEYLOCK); | ||
1265 | if (button != BUTTON_NONE) | ||
1240 | { | 1266 | { |
1241 | i = 0; | 1267 | action_last.unlock_combo = button; |
1242 | cur.items = get_context_mapping(CONTEXT_STD); | 1268 | break; |
1243 | while (cur.items[i].button_code != BUTTON_NONE) | ||
1244 | { | ||
1245 | if (cur.items[i].action_code == ACTION_STD_KEYLOCK) | ||
1246 | { | ||
1247 | action_last.unlock_combo = cur.items[i].button_code; | ||
1248 | break; | ||
1249 | } | ||
1250 | i = i + 1; | ||
1251 | } | ||
1252 | } | 1269 | } |
1253 | } | 1270 | } |
1254 | 1271 | ||