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
+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;
}
}
}