diff --git a/applications/services/desktop/desktop.c b/applications/services/desktop/desktop.c index 5917cfb7a..7327ced14 100644 --- a/applications/services/desktop/desktop.c +++ b/applications/services/desktop/desktop.c @@ -8,7 +8,6 @@ #include #include #include -#include #include diff --git a/applications/services/desktop/desktop_i.h b/applications/services/desktop/desktop_i.h index 0aaee4d36..91b7060ce 100644 --- a/applications/services/desktop/desktop_i.h +++ b/applications/services/desktop/desktop_i.h @@ -87,7 +87,6 @@ struct Desktop { bool app_running; bool locked; - Keybinds keybinds; FuriPubSub* ascii_events_pubsub; FuriPubSubSubscription* ascii_events_subscription; }; diff --git a/applications/services/desktop/desktop_keybinds.c b/applications/services/desktop/desktop_keybinds.c index 8feee7764..903944f7e 100644 --- a/applications/services/desktop/desktop_keybinds.c +++ b/applications/services/desktop/desktop_keybinds.c @@ -2,8 +2,11 @@ #include "desktop_keybinds_filename.h" #include "desktop_i.h" +#include #include #include +#include +#include #define TAG "DesktopKeybinds" @@ -31,7 +34,7 @@ void desktop_keybinds_migrate(Desktop* desktop) { DesktopKeybinds new; for(DesktopKeybindType type = 0; type < DesktopKeybindTypeMAX; type++) { for(DesktopKeybindKey key = 0; key < DesktopKeybindKeyMAX; key++) { - FuriString* keybind = furi_string_alloc_set(old[type][key]); + FuriString* keybind = furi_string_alloc_set(old[type][key].data); if(furi_string_equal(keybind, EXT_PATH("apps/Misc/nightstand.fap"))) { furi_string_set(keybind, "Clock"); } else if(furi_string_equal(keybind, "RFID")) { @@ -88,9 +91,8 @@ static FuriString* if(flipper_format_file_open_existing(file, DESKTOP_KEYBINDS_PATH)) { FuriString* keybind_name = furi_string_alloc_printf( - keybind_name, "%s%s", desktop_keybind_types[type], desktop_keybind_keys[type]); - success = flipper_format_read_string( - file, furi_string_get_cstr(keybind_name), keybinds[type][key]); + "%s%s", desktop_keybind_types[type], desktop_keybind_keys[type]); + success = flipper_format_read_string(file, furi_string_get_cstr(keybind_name), keybind); furi_string_free(keybind_name); } @@ -167,12 +169,12 @@ void desktop_keybinds_free(DesktopKeybinds* keybinds) { } } -static const DesktopKeybindType keybind_types[DesktopKeybindTypeMAX] = { +static const DesktopKeybindType keybind_types[] = { [InputTypeShort] = DesktopKeybindTypePress, [InputTypeLong] = DesktopKeybindTypeHold, }; -static const DesktopKeybindKey keybind_keys[DesktopKeybindKeyMAX] = { +static const DesktopKeybindKey keybind_keys[] = { [InputKeyUp] = DesktopKeybindKeyUp, [InputKeyDown] = DesktopKeybindKeyDown, [InputKeyRight] = DesktopKeybindKeyRight, @@ -189,27 +191,30 @@ void desktop_run_keybind(Desktop* desktop, InputType _type, InputKey _key) { FuriString* keybind = desktop_keybinds_load_one(desktop, type, key); if(furi_string_equal(keybind, "Apps Menu")) { - loader_start_detached_with_gui_error(instance->loader, LOADER_APPLICATIONS_NAME, NULL); + loader_start_detached_with_gui_error(desktop->loader, LOADER_APPLICATIONS_NAME, NULL); } else if(furi_string_equal(keybind, "Archive")) { - view_dispatcher_send_custom_event(instance->view_dispatcher, DesktopMainEventOpenArchive); + view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopMainEventOpenArchive); } else if(furi_string_equal(keybind, "Clock")) { loader_start_detached_with_gui_error( - instance->loader, EXT_PATH("apps/Tools/nightstand.fap"), ""); + desktop->loader, EXT_PATH("apps/Tools/nightstand.fap"), ""); } else if(furi_string_equal(keybind, "Device Info")) { - loader_start_detached_with_gui_error(instance->loader, "Power", "about_battery"); + loader_start_detached_with_gui_error(desktop->loader, "Power", "about_battery"); } else if(furi_string_equal(keybind, "Lock Menu")) { - view_dispatcher_send_custom_event(instance->view_dispatcher, DesktopMainEventOpenLockMenu); + view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopMainEventOpenLockMenu); } else if(furi_string_equal(keybind, "Lock Keypad")) { - view_dispatcher_send_custom_event(instance->view_dispatcher, DesktopMainEventLockKeypad); + view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopMainEventLockKeypad); } else if(furi_string_equal(keybind, "Lock with PIN")) { - view_dispatcher_send_custom_event(instance->view_dispatcher, DesktopMainEventLockWithPin); + view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopMainEventLockWithPin); } else if(furi_string_equal(keybind, "Wipe Device")) { - loader_start_detached_with_gui_error(instance->loader, "Storage", "wipe"); + loader_start_detached_with_gui_error(desktop->loader, "Storage", "wipe"); } else { - if(storage_common_exists(desktop->storage, keybind)) { - run_with_default_app(keybind); + if(storage_common_exists(desktop->storage, furi_string_get_cstr(keybind))) { + run_with_default_app(furi_string_get_cstr(keybind)); } else { - loader_start_detached_with_gui_error(instance->loader, keybind, NULL); + loader_start_detached_with_gui_error( + desktop->loader, furi_string_get_cstr(keybind), NULL); } } + + furi_string_free(keybind); } diff --git a/applications/settings/desktop_settings/desktop_settings_app.h b/applications/settings/desktop_settings/desktop_settings_app.h index 9dee1a8b0..d501bfcec 100644 --- a/applications/settings/desktop_settings/desktop_settings_app.h +++ b/applications/settings/desktop_settings/desktop_settings_app.h @@ -9,8 +9,11 @@ #include #include #include +#include #include +#include +#include #include #include "views/desktop_settings_view_pin_setup_howto.h" #include "views/desktop_settings_view_pin_setup_howto2.h" diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_keybinds_reset.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_keybinds_reset.c index 99d70f662..79e014890 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_keybinds_reset.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_keybinds_reset.c @@ -33,7 +33,6 @@ bool desktop_settings_scene_keybinds_reset_on_event(void* context, SceneManagerE case DialogExResultRight: storage_common_remove(furi_record_open(RECORD_STORAGE), DESKTOP_KEYBINDS_PATH); furi_record_close(RECORD_STORAGE); - DESKTOP_KEYBINDS_LOAD(&app->desktop->keybinds, sizeof(app->desktop->keybinds)); /* fall through */ case DialogExResultLeft: consumed = scene_manager_previous_scene(app->scene_manager);