mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-12 17:48:35 -07:00
Inhibit auto lock/shutdown on ASCII input
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user