feat: Carousel Launcher & Triple Click Home

This commit is contained in:
dark98
2026-09-25 21:23:57 +01:00
parent ea3ccd3b83
commit 0426ea79f5
5 changed files with 56 additions and 38 deletions
+5 -4
View File
@@ -12,10 +12,11 @@ extern "C" {
typedef enum {
INPUT_ACTION_NONE = 0,
INPUT_ACTION_CLICK, /* Short press (Next / Step / Advance) */
INPUT_ACTION_DOUBLE_CLICK,/* Double click (Back / Cancel) */
INPUT_ACTION_LONG_PRESS, /* Hold > 400ms (Select / Confirm / Open) */
INPUT_ACTION_HOLD_HOME, /* Hold > 1500ms (Return to App Launcher) */
INPUT_ACTION_CLICK, /* Short press (Next / Step / Advance) */
INPUT_ACTION_DOUBLE_CLICK, /* Double click (Back / Cancel) */
INPUT_ACTION_TRIPLE_CLICK, /* Triple click (Global Home / Launcher) */
INPUT_ACTION_LONG_PRESS, /* Hold > 380ms (Select / Confirm / Open) */
INPUT_ACTION_HOLD_HOME, /* Hold > 1400ms (Return to App Launcher) */
} input_action_t;
typedef void (*sys_input_handler_t)(input_action_t action, void *user_arg);
+21 -9
View File
@@ -32,12 +32,13 @@ static void dispatch_action(input_action_t action)
case INPUT_ACTION_DOUBLE_CLICK:
evt_id = SYS_EVENT_INPUT_DOUBLE_CLICK;
break;
case INPUT_ACTION_LONG_PRESS:
evt_id = SYS_EVENT_INPUT_LONG_PRESS;
break;
case INPUT_ACTION_TRIPLE_CLICK:
case INPUT_ACTION_HOLD_HOME:
evt_id = SYS_EVENT_INPUT_EXTRA_LONG_PRESS;
break;
case INPUT_ACTION_LONG_PRESS:
evt_id = SYS_EVENT_INPUT_LONG_PRESS;
break;
default:
return;
}
@@ -70,7 +71,8 @@ static void button_scanner_task(void *pvParameters)
{
bool last_state = false;
uint32_t press_start_ms = 0;
uint32_t last_click_time_ms = 0;
uint32_t last_release_time_ms = 0;
uint8_t tap_count = 0;
bool long_press_fired = false;
bool home_press_fired = false;
@@ -89,22 +91,32 @@ static void button_scanner_task(void *pvParameters)
uint32_t held_duration = now_ms - press_start_ms;
if (!home_press_fired && held_duration >= HOME_PRESS_TIME_MS) {
home_press_fired = true;
tap_count = 0;
dispatch_action(INPUT_ACTION_HOLD_HOME);
} else if (!long_press_fired && !home_press_fired && held_duration >= LONG_PRESS_TIME_MS) {
long_press_fired = true;
tap_count = 0;
dispatch_action(INPUT_ACTION_LONG_PRESS);
}
} else if (!current_state && last_state) {
// Button released
uint32_t press_duration = now_ms - press_start_ms;
if (press_duration >= DEBOUNCE_TIME_MS && !long_press_fired && !home_press_fired) {
if ((now_ms - last_click_time_ms) <= DOUBLE_CLICK_GAP_MS) {
dispatch_action(INPUT_ACTION_DOUBLE_CLICK);
last_click_time_ms = 0;
if ((now_ms - last_release_time_ms) <= DOUBLE_CLICK_GAP_MS) {
tap_count++;
} else {
// Instant click dispatch upon tap release (no 280ms lag penalty!)
tap_count = 1;
}
last_release_time_ms = now_ms;
if (tap_count == 1) {
dispatch_action(INPUT_ACTION_CLICK);
last_click_time_ms = now_ms;
} else if (tap_count == 2) {
dispatch_action(INPUT_ACTION_DOUBLE_CLICK);
} else if (tap_count >= 3) {
dispatch_action(INPUT_ACTION_TRIPLE_CLICK);
tap_count = 0;
last_release_time_ms = 0;
}
}
}