Inhibit auto lock/shutdown on ASCII input

This commit is contained in:
Willy-JL
2024-01-17 22:43:36 +00:00
parent 9d877eb59d
commit 3406f005c4
4 changed files with 36 additions and 13 deletions

View File

@@ -145,14 +145,12 @@ static void desktop_tick_event_callback(void* context) {
scene_manager_handle_tick_event(app->scene_manager);
}
static void desktop_input_event_callback(const void* value, void* context) {
static void desktop_auto_lock_callback(const void* value, void* context) {
furi_assert(value);
furi_assert(context);
const InputEvent* event = value;
UNUSED(value);
Desktop* desktop = context;
if(event->type == InputTypePress) {
desktop_start_auto_lock_timer(desktop);
}
desktop_start_auto_lock_timer(desktop);
}
static void desktop_auto_lock_timer_callback(void* context) {
@@ -172,8 +170,14 @@ static void desktop_stop_auto_lock_timer(Desktop* desktop) {
static void desktop_auto_lock_arm(Desktop* desktop) {
if(desktop->settings.auto_lock_delay_ms) {
desktop->input_events_subscription = furi_pubsub_subscribe(
desktop->input_events_pubsub, desktop_input_event_callback, desktop);
if(desktop->input_events_subscription == NULL) {
desktop->input_events_subscription = furi_pubsub_subscribe(
desktop->input_events_pubsub, desktop_auto_lock_callback, desktop);
}
if(desktop->ascii_events_subscription == NULL) {
desktop->ascii_events_subscription = furi_pubsub_subscribe(
desktop->ascii_events_pubsub, desktop_auto_lock_callback, desktop);
}
desktop_start_auto_lock_timer(desktop);
}
}
@@ -184,6 +188,10 @@ static void desktop_auto_lock_inhibit(Desktop* desktop) {
furi_pubsub_unsubscribe(desktop->input_events_pubsub, desktop->input_events_subscription);
desktop->input_events_subscription = NULL;
}
if(desktop->ascii_events_subscription) {
furi_pubsub_unsubscribe(desktop->ascii_events_pubsub, desktop->ascii_events_subscription);
desktop->ascii_events_subscription = NULL;
}
}
static void desktop_clock_timer_callback(void* context) {
@@ -372,6 +380,8 @@ Desktop* desktop_alloc() {
desktop->input_events_pubsub = furi_record_open(RECORD_INPUT_EVENTS);
desktop->input_events_subscription = NULL;
desktop->ascii_events_pubsub = furi_record_open(RECORD_ASCII_EVENTS);
desktop->ascii_events_subscription = NULL;
desktop->auto_lock_timer =
furi_timer_alloc(desktop_auto_lock_timer_callback, FuriTimerTypeOnce, desktop);