[FL-2815, FL-2821] Dummy mode (#1739)
* Dummy mode implementation * dumb -> dummy * F7: Add new api_symbols: game icon * Starting snake game from dummy mode Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
parent
3d3c422751
commit
d80329b323
@ -270,7 +270,7 @@ void archive_file_array_load(ArchiveBrowserView* browser, int8_t dir) {
|
||||
ArchiveFile_t* archive_get_current_file(ArchiveBrowserView* browser) {
|
||||
furi_assert(browser);
|
||||
|
||||
ArchiveFile_t* selected;
|
||||
ArchiveFile_t* selected = NULL;
|
||||
with_view_model(
|
||||
browser->view, (ArchiveBrowserViewModel * model) {
|
||||
selected = files_array_size(model->files) ?
|
||||
@ -284,7 +284,7 @@ ArchiveFile_t* archive_get_current_file(ArchiveBrowserView* browser) {
|
||||
ArchiveFile_t* archive_get_file_at(ArchiveBrowserView* browser, size_t idx) {
|
||||
furi_assert(browser);
|
||||
|
||||
ArchiveFile_t* selected;
|
||||
ArchiveFile_t* selected = NULL;
|
||||
|
||||
with_view_model(
|
||||
browser->view, (ArchiveBrowserViewModel * model) {
|
||||
@ -298,7 +298,7 @@ ArchiveFile_t* archive_get_file_at(ArchiveBrowserView* browser, size_t idx) {
|
||||
ArchiveTabEnum archive_get_tab(ArchiveBrowserView* browser) {
|
||||
furi_assert(browser);
|
||||
|
||||
ArchiveTabEnum tab_id;
|
||||
ArchiveTabEnum tab_id = 0;
|
||||
with_view_model(
|
||||
browser->view, (ArchiveBrowserViewModel * model) {
|
||||
tab_id = model->tab_idx;
|
||||
@ -451,8 +451,6 @@ void archive_switch_tab(ArchiveBrowserView* browser, InputKey key) {
|
||||
archive_file_browser_set_path(
|
||||
browser, browser->path, archive_get_tab_ext(tab), skip_assets);
|
||||
tab_empty = false; // Empty check will be performed later
|
||||
} else {
|
||||
tab_empty = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,13 +32,18 @@ static void desktop_loader_callback(const void* message, void* context) {
|
||||
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopGlobalAfterAppFinished);
|
||||
}
|
||||
}
|
||||
|
||||
static void desktop_lock_icon_callback(Canvas* canvas, void* context) {
|
||||
static void desktop_lock_icon_draw_callback(Canvas* canvas, void* context) {
|
||||
UNUSED(context);
|
||||
furi_assert(canvas);
|
||||
canvas_draw_icon(canvas, 0, 0, &I_Lock_8x8);
|
||||
}
|
||||
|
||||
static void desktop_dummy_mode_icon_draw_callback(Canvas* canvas, void* context) {
|
||||
UNUSED(context);
|
||||
furi_assert(canvas);
|
||||
canvas_draw_icon(canvas, 0, 0, &I_GameMode_11x8);
|
||||
}
|
||||
|
||||
static bool desktop_custom_event_callback(void* context, uint32_t event) {
|
||||
furi_assert(context);
|
||||
Desktop* desktop = (Desktop*)context;
|
||||
@ -52,7 +57,7 @@ static bool desktop_custom_event_callback(void* context, uint32_t event) {
|
||||
animation_manager_load_and_continue_animation(desktop->animation_manager);
|
||||
// TODO: Implement a message mechanism for loading settings and (optionally)
|
||||
// locking and unlocking
|
||||
LOAD_DESKTOP_SETTINGS(&desktop->settings);
|
||||
DESKTOP_SETTINGS_LOAD(&desktop->settings);
|
||||
desktop_auto_lock_arm(desktop);
|
||||
return true;
|
||||
case DesktopGlobalAutoLock:
|
||||
@ -127,7 +132,7 @@ void desktop_lock(Desktop* desktop) {
|
||||
}
|
||||
|
||||
void desktop_unlock(Desktop* desktop) {
|
||||
view_port_enabled_set(desktop->lock_viewport, false);
|
||||
view_port_enabled_set(desktop->lock_icon_viewport, false);
|
||||
Gui* gui = furi_record_open(RECORD_GUI);
|
||||
gui_set_lockdown(gui, false);
|
||||
furi_record_close(RECORD_GUI);
|
||||
@ -136,6 +141,13 @@ void desktop_unlock(Desktop* desktop) {
|
||||
desktop_auto_lock_arm(desktop);
|
||||
}
|
||||
|
||||
void desktop_set_dummy_mode_state(Desktop* desktop, bool enabled) {
|
||||
view_port_enabled_set(desktop->dummy_mode_icon_viewport, enabled);
|
||||
desktop_main_set_dummy_mode_state(desktop->main_view, enabled);
|
||||
desktop->settings.dummy_mode = enabled;
|
||||
DESKTOP_SETTINGS_SAVE(&desktop->settings);
|
||||
}
|
||||
|
||||
Desktop* desktop_alloc() {
|
||||
Desktop* desktop = malloc(sizeof(Desktop));
|
||||
|
||||
@ -212,11 +224,20 @@ Desktop* desktop_alloc() {
|
||||
desktop_view_slideshow_get_view(desktop->slideshow_view));
|
||||
|
||||
// Lock icon
|
||||
desktop->lock_viewport = view_port_alloc();
|
||||
view_port_set_width(desktop->lock_viewport, icon_get_width(&I_Lock_8x8));
|
||||
view_port_draw_callback_set(desktop->lock_viewport, desktop_lock_icon_callback, desktop);
|
||||
view_port_enabled_set(desktop->lock_viewport, false);
|
||||
gui_add_view_port(desktop->gui, desktop->lock_viewport, GuiLayerStatusBarLeft);
|
||||
desktop->lock_icon_viewport = view_port_alloc();
|
||||
view_port_set_width(desktop->lock_icon_viewport, icon_get_width(&I_Lock_8x8));
|
||||
view_port_draw_callback_set(
|
||||
desktop->lock_icon_viewport, desktop_lock_icon_draw_callback, desktop);
|
||||
view_port_enabled_set(desktop->lock_icon_viewport, false);
|
||||
gui_add_view_port(desktop->gui, desktop->lock_icon_viewport, GuiLayerStatusBarLeft);
|
||||
|
||||
// Dummy mode icon
|
||||
desktop->dummy_mode_icon_viewport = view_port_alloc();
|
||||
view_port_set_width(desktop->dummy_mode_icon_viewport, icon_get_width(&I_GameMode_11x8));
|
||||
view_port_draw_callback_set(
|
||||
desktop->dummy_mode_icon_viewport, desktop_dummy_mode_icon_draw_callback, desktop);
|
||||
view_port_enabled_set(desktop->dummy_mode_icon_viewport, false);
|
||||
gui_add_view_port(desktop->gui, desktop->dummy_mode_icon_viewport, GuiLayerStatusBarLeft);
|
||||
|
||||
// Special case: autostart application is already running
|
||||
desktop->loader = furi_record_open(RECORD_LOADER);
|
||||
@ -301,12 +322,15 @@ int32_t desktop_srv(void* p) {
|
||||
UNUSED(p);
|
||||
Desktop* desktop = desktop_alloc();
|
||||
|
||||
bool loaded = LOAD_DESKTOP_SETTINGS(&desktop->settings);
|
||||
bool loaded = DESKTOP_SETTINGS_LOAD(&desktop->settings);
|
||||
if(!loaded) {
|
||||
memset(&desktop->settings, 0, sizeof(desktop->settings));
|
||||
SAVE_DESKTOP_SETTINGS(&desktop->settings);
|
||||
DESKTOP_SETTINGS_SAVE(&desktop->settings);
|
||||
}
|
||||
|
||||
view_port_enabled_set(desktop->dummy_mode_icon_viewport, desktop->settings.dummy_mode);
|
||||
desktop_main_set_dummy_mode_state(desktop->main_view, desktop->settings.dummy_mode);
|
||||
|
||||
scene_manager_next_scene(desktop->scene_manager, DesktopSceneMain);
|
||||
|
||||
desktop_pin_lock_init(&desktop->settings);
|
||||
|
@ -57,7 +57,8 @@ struct Desktop {
|
||||
DesktopSettings settings;
|
||||
DesktopViewPinInput* pin_input_view;
|
||||
|
||||
ViewPort* lock_viewport;
|
||||
ViewPort* lock_icon_viewport;
|
||||
ViewPort* dummy_mode_icon_viewport;
|
||||
|
||||
AnimationManager* animation_manager;
|
||||
|
||||
@ -75,3 +76,4 @@ Desktop* desktop_alloc();
|
||||
void desktop_free(Desktop* desktop);
|
||||
void desktop_lock(Desktop* desktop);
|
||||
void desktop_unlock(Desktop* desktop);
|
||||
void desktop_set_dummy_mode_state(Desktop* desktop, bool enabled);
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <toolbox/saved_struct.h>
|
||||
#include <storage/storage.h>
|
||||
|
||||
#define DESKTOP_SETTINGS_VER (4)
|
||||
#define DESKTOP_SETTINGS_VER (5)
|
||||
|
||||
#define DESKTOP_SETTINGS_PATH INT_PATH(DESKTOP_SETTINGS_FILE_NAME)
|
||||
#define DESKTOP_SETTINGS_MAGIC (0x17)
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
#define DESKTOP_SETTINGS_RUN_PIN_SETUP_ARG "run_pin_setup"
|
||||
|
||||
#define SAVE_DESKTOP_SETTINGS(x) \
|
||||
#define DESKTOP_SETTINGS_SAVE(x) \
|
||||
saved_struct_save( \
|
||||
DESKTOP_SETTINGS_PATH, \
|
||||
(x), \
|
||||
@ -24,7 +24,7 @@
|
||||
DESKTOP_SETTINGS_MAGIC, \
|
||||
DESKTOP_SETTINGS_VER)
|
||||
|
||||
#define LOAD_DESKTOP_SETTINGS(x) \
|
||||
#define DESKTOP_SETTINGS_LOAD(x) \
|
||||
saved_struct_load( \
|
||||
DESKTOP_SETTINGS_PATH, \
|
||||
(x), \
|
||||
@ -46,4 +46,5 @@ typedef struct {
|
||||
PinCode pin_code;
|
||||
uint8_t is_locked;
|
||||
uint32_t auto_lock_delay_ms;
|
||||
uint8_t dummy_mode;
|
||||
} DesktopSettings;
|
||||
|
@ -72,7 +72,7 @@ void desktop_pin_lock(DesktopSettings* settings) {
|
||||
cli_session_close(cli);
|
||||
furi_record_close(RECORD_CLI);
|
||||
settings->is_locked = 1;
|
||||
SAVE_DESKTOP_SETTINGS(settings);
|
||||
DESKTOP_SETTINGS_SAVE(settings);
|
||||
}
|
||||
|
||||
void desktop_pin_unlock(DesktopSettings* settings) {
|
||||
@ -83,7 +83,7 @@ void desktop_pin_unlock(DesktopSettings* settings) {
|
||||
cli_session_open(cli, &cli_vcp);
|
||||
furi_record_close(RECORD_CLI);
|
||||
settings->is_locked = 0;
|
||||
SAVE_DESKTOP_SETTINGS(settings);
|
||||
DESKTOP_SETTINGS_SAVE(settings);
|
||||
}
|
||||
|
||||
void desktop_pin_lock_init(DesktopSettings* settings) {
|
||||
@ -95,7 +95,7 @@ void desktop_pin_lock_init(DesktopSettings* settings) {
|
||||
} else {
|
||||
if(desktop_pin_lock_is_locked()) {
|
||||
settings->is_locked = 1;
|
||||
SAVE_DESKTOP_SETTINGS(settings);
|
||||
DESKTOP_SETTINGS_SAVE(settings);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -22,10 +22,11 @@ void desktop_scene_lock_menu_callback(DesktopEvent event, void* context) {
|
||||
void desktop_scene_lock_menu_on_enter(void* context) {
|
||||
Desktop* desktop = (Desktop*)context;
|
||||
|
||||
LOAD_DESKTOP_SETTINGS(&desktop->settings);
|
||||
DESKTOP_SETTINGS_LOAD(&desktop->settings);
|
||||
scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 0);
|
||||
desktop_lock_menu_set_callback(desktop->lock_menu, desktop_scene_lock_menu_callback, desktop);
|
||||
desktop_lock_menu_pin_set(desktop->lock_menu, desktop->settings.pin_code.length > 0);
|
||||
desktop_lock_menu_set_pin_state(desktop->lock_menu, desktop->settings.pin_code.length > 0);
|
||||
desktop_lock_menu_set_dummy_mode_state(desktop->lock_menu, desktop->settings.dummy_mode);
|
||||
desktop_lock_menu_set_idx(desktop->lock_menu, 0);
|
||||
|
||||
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewIdLockMenu);
|
||||
@ -39,9 +40,9 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) {
|
||||
bool check_pin_changed =
|
||||
scene_manager_get_scene_state(desktop->scene_manager, DesktopSceneLockMenu);
|
||||
if(check_pin_changed) {
|
||||
LOAD_DESKTOP_SETTINGS(&desktop->settings);
|
||||
DESKTOP_SETTINGS_LOAD(&desktop->settings);
|
||||
if(desktop->settings.pin_code.length > 0) {
|
||||
desktop_lock_menu_pin_set(desktop->lock_menu, 1);
|
||||
desktop_lock_menu_set_pin_state(desktop->lock_menu, true);
|
||||
scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 0);
|
||||
}
|
||||
}
|
||||
@ -67,15 +68,21 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
consumed = true;
|
||||
break;
|
||||
case DesktopLockMenuEventExit:
|
||||
scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 0);
|
||||
case DesktopLockMenuEventDummyModeOn:
|
||||
desktop_set_dummy_mode_state(desktop, true);
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
desktop->scene_manager, DesktopSceneMain);
|
||||
break;
|
||||
case DesktopLockMenuEventDummyModeOff:
|
||||
desktop_set_dummy_mode_state(desktop, false);
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
desktop->scene_manager, DesktopSceneMain);
|
||||
consumed = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 0);
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
@ -46,13 +46,13 @@ void desktop_scene_locked_on_enter(void* context) {
|
||||
uint32_t state = scene_manager_get_scene_state(desktop->scene_manager, DesktopSceneLocked);
|
||||
if(state == SCENE_LOCKED_FIRST_ENTER) {
|
||||
bool pin_locked = desktop_pin_lock_is_locked();
|
||||
view_port_enabled_set(desktop->lock_viewport, true);
|
||||
view_port_enabled_set(desktop->lock_icon_viewport, true);
|
||||
Gui* gui = furi_record_open(RECORD_GUI);
|
||||
gui_set_lockdown(gui, true);
|
||||
furi_record_close(RECORD_GUI);
|
||||
|
||||
if(pin_locked) {
|
||||
LOAD_DESKTOP_SETTINGS(&desktop->settings);
|
||||
DESKTOP_SETTINGS_LOAD(&desktop->settings);
|
||||
desktop_view_locked_lock(desktop->locked_view, true);
|
||||
uint32_t pin_timeout = desktop_pin_lock_get_fail_timeout();
|
||||
if(pin_timeout > 0) {
|
||||
|
@ -113,7 +113,7 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
|
||||
case DesktopMainEventOpenFavoritePrimary:
|
||||
LOAD_DESKTOP_SETTINGS(&desktop->settings);
|
||||
DESKTOP_SETTINGS_LOAD(&desktop->settings);
|
||||
if(desktop->settings.favorite_primary < FLIPPER_APPS_COUNT) {
|
||||
LoaderStatus status = loader_start(
|
||||
desktop->loader, FLIPPER_APPS[desktop->settings.favorite_primary].name, NULL);
|
||||
@ -126,7 +126,7 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
|
||||
consumed = true;
|
||||
break;
|
||||
case DesktopMainEventOpenFavoriteSecondary:
|
||||
LOAD_DESKTOP_SETTINGS(&desktop->settings);
|
||||
DESKTOP_SETTINGS_LOAD(&desktop->settings);
|
||||
if(desktop->settings.favorite_secondary < FLIPPER_APPS_COUNT) {
|
||||
LoaderStatus status = loader_start(
|
||||
desktop->loader,
|
||||
@ -157,6 +157,21 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
consumed = true;
|
||||
break;
|
||||
case DesktopMainEventOpenPassport: {
|
||||
LoaderStatus status = loader_start(desktop->loader, "Passport", NULL);
|
||||
if(status != LoaderStatusOk) {
|
||||
FURI_LOG_E(TAG, "loader_start failed: %d", status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DesktopMainEventOpenGameMenu: {
|
||||
LoaderStatus status = loader_start(
|
||||
desktop->loader, "Applications", EXT_PATH("/apps/Games/snake_game.fap"));
|
||||
if(status != LoaderStatusOk) {
|
||||
FURI_LOG_E(TAG, "loader_start failed: %d", status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DesktopLockedEventUpdate:
|
||||
desktop_view_locked_update(desktop->locked_view);
|
||||
consumed = true;
|
||||
|
@ -7,9 +7,11 @@ typedef enum {
|
||||
DesktopMainEventOpenFavoriteSecondary,
|
||||
DesktopMainEventOpenMenu,
|
||||
DesktopMainEventOpenDebug,
|
||||
DesktopMainEventOpenPassport, /**< Broken, don't use it */
|
||||
DesktopMainEventOpenPassport,
|
||||
DesktopMainEventOpenPowerOff,
|
||||
|
||||
DesktopMainEventOpenGameMenu,
|
||||
|
||||
DesktopLockedEventUnlocked,
|
||||
DesktopLockedEventUpdate,
|
||||
DesktopLockedEventShowPinInput,
|
||||
@ -28,7 +30,8 @@ typedef enum {
|
||||
|
||||
DesktopLockMenuEventLock,
|
||||
DesktopLockMenuEventPinLock,
|
||||
DesktopLockMenuEventExit,
|
||||
DesktopLockMenuEventDummyModeOn,
|
||||
DesktopLockMenuEventDummyModeOff,
|
||||
|
||||
DesktopAnimationEventCheckAnimation,
|
||||
DesktopAnimationEventNewIdleAnimation,
|
||||
|
@ -4,7 +4,13 @@
|
||||
#include "../desktop_i.h"
|
||||
#include "desktop_view_lock_menu.h"
|
||||
|
||||
#define LOCK_MENU_ITEMS_NB 3
|
||||
typedef enum {
|
||||
DesktopLockMenuIndexLock,
|
||||
DesktopLockMenuIndexPinLock,
|
||||
DesktopLockMenuIndexDummy,
|
||||
|
||||
DesktopLockMenuIndexTotalCount
|
||||
} DesktopLockMenuIndex;
|
||||
|
||||
void desktop_lock_menu_set_callback(
|
||||
DesktopLockMenuView* lock_menu,
|
||||
@ -16,16 +22,24 @@ void desktop_lock_menu_set_callback(
|
||||
lock_menu->context = context;
|
||||
}
|
||||
|
||||
void desktop_lock_menu_pin_set(DesktopLockMenuView* lock_menu, bool pin_is_set) {
|
||||
void desktop_lock_menu_set_pin_state(DesktopLockMenuView* lock_menu, bool pin_is_set) {
|
||||
with_view_model(
|
||||
lock_menu->view, (DesktopLockMenuViewModel * model) {
|
||||
model->pin_set = pin_is_set;
|
||||
model->pin_is_set = pin_is_set;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
void desktop_lock_menu_set_dummy_mode_state(DesktopLockMenuView* lock_menu, bool dummy_mode) {
|
||||
with_view_model(
|
||||
lock_menu->view, (DesktopLockMenuViewModel * model) {
|
||||
model->dummy_mode = dummy_mode;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
void desktop_lock_menu_set_idx(DesktopLockMenuView* lock_menu, uint8_t idx) {
|
||||
furi_assert(idx < LOCK_MENU_ITEMS_NB);
|
||||
furi_assert(idx < DesktopLockMenuIndexTotalCount);
|
||||
with_view_model(
|
||||
lock_menu->view, (DesktopLockMenuViewModel * model) {
|
||||
model->idx = idx;
|
||||
@ -33,43 +47,34 @@ void desktop_lock_menu_set_idx(DesktopLockMenuView* lock_menu, uint8_t idx) {
|
||||
});
|
||||
}
|
||||
|
||||
static void lock_menu_callback(void* context, uint8_t index) {
|
||||
furi_assert(context);
|
||||
DesktopLockMenuView* lock_menu = context;
|
||||
switch(index) {
|
||||
case 0: // lock
|
||||
lock_menu->callback(DesktopLockMenuEventLock, lock_menu->context);
|
||||
break;
|
||||
case 1: // lock
|
||||
lock_menu->callback(DesktopLockMenuEventPinLock, lock_menu->context);
|
||||
break;
|
||||
default: // wip message
|
||||
with_view_model(
|
||||
lock_menu->view, (DesktopLockMenuViewModel * model) {
|
||||
model->hint_timeout = HINT_TIMEOUT;
|
||||
return true;
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void desktop_lock_menu_render(Canvas* canvas, void* model) {
|
||||
const char* Lockmenu_Items[LOCK_MENU_ITEMS_NB] = {"Lock", "Lock with PIN", "DUMB mode"};
|
||||
|
||||
void desktop_lock_menu_draw_callback(Canvas* canvas, void* model) {
|
||||
DesktopLockMenuViewModel* m = model;
|
||||
canvas_clear(canvas);
|
||||
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_icon(canvas, -57, 0 + STATUS_BAR_Y_SHIFT, &I_DoorLeft_70x55);
|
||||
canvas_draw_icon(canvas, 116, 0 + STATUS_BAR_Y_SHIFT, &I_DoorRight_70x55);
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
|
||||
for(uint8_t i = 0; i < LOCK_MENU_ITEMS_NB; ++i) {
|
||||
const char* str = Lockmenu_Items[i];
|
||||
for(uint8_t i = 0; i < DesktopLockMenuIndexTotalCount; ++i) {
|
||||
const char* str = NULL;
|
||||
|
||||
if(i == 1 && !m->pin_set) str = "Set PIN";
|
||||
if(m->hint_timeout && m->idx == 2 && m->idx == i) str = "Not Implemented";
|
||||
if(i == DesktopLockMenuIndexLock) {
|
||||
str = "Lock";
|
||||
} else if(i == DesktopLockMenuIndexPinLock) {
|
||||
if(m->pin_is_set) {
|
||||
str = "Lock with PIN";
|
||||
} else {
|
||||
str = "Set PIN";
|
||||
}
|
||||
} else if(i == DesktopLockMenuIndexDummy) {
|
||||
if(m->dummy_mode) {
|
||||
str = "Brainiac Mode";
|
||||
} else {
|
||||
str = "Dummy Mode";
|
||||
}
|
||||
}
|
||||
|
||||
if(str != NULL)
|
||||
if(str)
|
||||
canvas_draw_str_aligned(
|
||||
canvas, 64, 9 + (i * 17) + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter, str);
|
||||
|
||||
@ -82,33 +87,58 @@ View* desktop_lock_menu_get_view(DesktopLockMenuView* lock_menu) {
|
||||
return lock_menu->view;
|
||||
}
|
||||
|
||||
bool desktop_lock_menu_input(InputEvent* event, void* context) {
|
||||
bool desktop_lock_menu_input_callback(InputEvent* event, void* context) {
|
||||
furi_assert(event);
|
||||
furi_assert(context);
|
||||
|
||||
DesktopLockMenuView* lock_menu = context;
|
||||
uint8_t idx;
|
||||
uint8_t idx = 0;
|
||||
bool consumed = false;
|
||||
bool dummy_mode = false;
|
||||
|
||||
if(event->type != InputTypeShort) return false;
|
||||
with_view_model(
|
||||
lock_menu->view, (DesktopLockMenuViewModel * model) {
|
||||
model->hint_timeout = 0; // clear hint timeout
|
||||
bool ret = false;
|
||||
if((event->type == InputTypeShort) || (event->type == InputTypeRepeat)) {
|
||||
if(event->key == InputKeyUp) {
|
||||
model->idx = CLAMP(model->idx - 1, LOCK_MENU_ITEMS_NB - 1, 0);
|
||||
if(model->idx == 0) {
|
||||
model->idx = DesktopLockMenuIndexTotalCount - 1;
|
||||
} else {
|
||||
model->idx = CLAMP(model->idx - 1, DesktopLockMenuIndexTotalCount - 1, 0);
|
||||
}
|
||||
ret = true;
|
||||
consumed = true;
|
||||
} else if(event->key == InputKeyDown) {
|
||||
model->idx = CLAMP(model->idx + 1, LOCK_MENU_ITEMS_NB - 1, 0);
|
||||
if(model->idx == DesktopLockMenuIndexTotalCount - 1) {
|
||||
model->idx = 0;
|
||||
} else {
|
||||
model->idx = CLAMP(model->idx + 1, DesktopLockMenuIndexTotalCount - 1, 0);
|
||||
}
|
||||
ret = true;
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
idx = model->idx;
|
||||
return true;
|
||||
dummy_mode = model->dummy_mode;
|
||||
return ret;
|
||||
});
|
||||
|
||||
if(event->key == InputKeyBack) {
|
||||
lock_menu->callback(DesktopLockMenuEventExit, lock_menu->context);
|
||||
} else if(event->key == InputKeyOk) {
|
||||
lock_menu_callback(lock_menu, idx);
|
||||
if(event->key == InputKeyOk) {
|
||||
if((idx == DesktopLockMenuIndexLock) && (event->type == InputTypeShort)) {
|
||||
lock_menu->callback(DesktopLockMenuEventLock, lock_menu->context);
|
||||
} else if((idx == DesktopLockMenuIndexPinLock) && (event->type == InputTypeShort)) {
|
||||
lock_menu->callback(DesktopLockMenuEventPinLock, lock_menu->context);
|
||||
} else if(idx == DesktopLockMenuIndexDummy) {
|
||||
if((dummy_mode == false) && (event->type == InputTypeShort)) {
|
||||
lock_menu->callback(DesktopLockMenuEventDummyModeOn, lock_menu->context);
|
||||
} else if((dummy_mode == true) && (event->type == InputTypeShort)) {
|
||||
lock_menu->callback(DesktopLockMenuEventDummyModeOff, lock_menu->context);
|
||||
}
|
||||
}
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return consumed;
|
||||
}
|
||||
|
||||
DesktopLockMenuView* desktop_lock_menu_alloc() {
|
||||
@ -116,8 +146,8 @@ DesktopLockMenuView* desktop_lock_menu_alloc() {
|
||||
lock_menu->view = view_alloc();
|
||||
view_allocate_model(lock_menu->view, ViewModelTypeLocking, sizeof(DesktopLockMenuViewModel));
|
||||
view_set_context(lock_menu->view, lock_menu);
|
||||
view_set_draw_callback(lock_menu->view, (ViewDrawCallback)desktop_lock_menu_render);
|
||||
view_set_input_callback(lock_menu->view, desktop_lock_menu_input);
|
||||
view_set_draw_callback(lock_menu->view, (ViewDrawCallback)desktop_lock_menu_draw_callback);
|
||||
view_set_input_callback(lock_menu->view, desktop_lock_menu_input_callback);
|
||||
|
||||
return lock_menu;
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ struct DesktopLockMenuView {
|
||||
|
||||
typedef struct {
|
||||
uint8_t idx;
|
||||
uint8_t hint_timeout;
|
||||
bool pin_set;
|
||||
bool pin_is_set;
|
||||
bool dummy_mode;
|
||||
} DesktopLockMenuViewModel;
|
||||
|
||||
void desktop_lock_menu_set_callback(
|
||||
@ -27,7 +27,8 @@ void desktop_lock_menu_set_callback(
|
||||
void* context);
|
||||
|
||||
View* desktop_lock_menu_get_view(DesktopLockMenuView* lock_menu);
|
||||
void desktop_lock_menu_pin_set(DesktopLockMenuView* lock_menu, bool pin_is_set);
|
||||
void desktop_lock_menu_set_pin_state(DesktopLockMenuView* lock_menu, bool pin_is_set);
|
||||
void desktop_lock_menu_set_dummy_mode_state(DesktopLockMenuView* lock_menu, bool dummy_mode);
|
||||
void desktop_lock_menu_set_idx(DesktopLockMenuView* lock_menu, uint8_t idx);
|
||||
DesktopLockMenuView* desktop_lock_menu_alloc();
|
||||
void desktop_lock_menu_free(DesktopLockMenuView* lock_menu);
|
||||
|
@ -14,6 +14,7 @@ struct DesktopMainView {
|
||||
DesktopMainViewCallback callback;
|
||||
void* context;
|
||||
TimerHandle_t poweroff_timer;
|
||||
bool dummy_mode;
|
||||
};
|
||||
|
||||
#define DESKTOP_MAIN_VIEW_POWEROFF_TIMEOUT 5000
|
||||
@ -38,12 +39,18 @@ View* desktop_main_get_view(DesktopMainView* main_view) {
|
||||
return main_view->view;
|
||||
}
|
||||
|
||||
bool desktop_main_input(InputEvent* event, void* context) {
|
||||
void desktop_main_set_dummy_mode_state(DesktopMainView* main_view, bool dummy_mode) {
|
||||
furi_assert(main_view);
|
||||
main_view->dummy_mode = dummy_mode;
|
||||
}
|
||||
|
||||
bool desktop_main_input_callback(InputEvent* event, void* context) {
|
||||
furi_assert(event);
|
||||
furi_assert(context);
|
||||
|
||||
DesktopMainView* main_view = context;
|
||||
|
||||
if(main_view->dummy_mode == false) {
|
||||
if(event->type == InputTypeShort) {
|
||||
if(event->key == InputKeyOk) {
|
||||
main_view->callback(DesktopMainEventOpenMenu, main_view->context);
|
||||
@ -53,9 +60,8 @@ bool desktop_main_input(InputEvent* event, void* context) {
|
||||
main_view->callback(DesktopMainEventOpenArchive, main_view->context);
|
||||
} else if(event->key == InputKeyLeft) {
|
||||
main_view->callback(DesktopMainEventOpenFavoritePrimary, main_view->context);
|
||||
} else if(event->key == InputKeyRight) {
|
||||
main_view->callback(DesktopMainEventOpenPassport, main_view->context);
|
||||
}
|
||||
// Right key is handled by animation manager
|
||||
} else if(event->type == InputTypeLong) {
|
||||
if(event->key == InputKeyDown) {
|
||||
main_view->callback(DesktopMainEventOpenDebug, main_view->context);
|
||||
@ -63,6 +69,20 @@ bool desktop_main_input(InputEvent* event, void* context) {
|
||||
main_view->callback(DesktopMainEventOpenFavoriteSecondary, main_view->context);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(event->type == InputTypeShort) {
|
||||
if(event->key == InputKeyOk) {
|
||||
main_view->callback(DesktopMainEventOpenGameMenu, main_view->context);
|
||||
} else if(event->key == InputKeyUp) {
|
||||
main_view->callback(DesktopMainEventOpenLockMenu, main_view->context);
|
||||
} else if(event->key == InputKeyDown) {
|
||||
main_view->callback(DesktopMainEventOpenPassport, main_view->context);
|
||||
} else if(event->key == InputKeyLeft) {
|
||||
main_view->callback(DesktopMainEventOpenPassport, main_view->context);
|
||||
}
|
||||
// Right key is handled by animation manager
|
||||
}
|
||||
}
|
||||
|
||||
if(event->key == InputKeyBack) {
|
||||
if(event->type == InputTypePress) {
|
||||
@ -84,7 +104,7 @@ DesktopMainView* desktop_main_alloc() {
|
||||
main_view->view = view_alloc();
|
||||
view_allocate_model(main_view->view, ViewModelTypeLockFree, 1);
|
||||
view_set_context(main_view->view, main_view);
|
||||
view_set_input_callback(main_view->view, desktop_main_input);
|
||||
view_set_input_callback(main_view->view, desktop_main_input_callback);
|
||||
|
||||
main_view->poweroff_timer = xTimerCreate(
|
||||
NULL,
|
||||
|
@ -13,5 +13,6 @@ void desktop_main_set_callback(
|
||||
void* context);
|
||||
|
||||
View* desktop_main_get_view(DesktopMainView* main_view);
|
||||
void desktop_main_set_dummy_mode_state(DesktopMainView* main_view, bool dummy_mode);
|
||||
DesktopMainView* desktop_main_alloc();
|
||||
void desktop_main_free(DesktopMainView* main_view);
|
||||
|
@ -89,7 +89,7 @@ void desktop_settings_app_free(DesktopSettingsApp* app) {
|
||||
|
||||
extern int32_t desktop_settings_app(void* p) {
|
||||
DesktopSettingsApp* app = desktop_settings_app_alloc();
|
||||
LOAD_DESKTOP_SETTINGS(&app->settings);
|
||||
DESKTOP_SETTINGS_LOAD(&app->settings);
|
||||
if(p && (strcmp(p, DESKTOP_SETTINGS_RUN_PIN_SETUP_ARG) == 0)) {
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppScenePinSetupHowto);
|
||||
} else {
|
||||
|
@ -56,6 +56,6 @@ bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent e
|
||||
|
||||
void desktop_settings_scene_favorite_on_exit(void* context) {
|
||||
DesktopSettingsApp* app = context;
|
||||
SAVE_DESKTOP_SETTINGS(&app->settings);
|
||||
DESKTOP_SETTINGS_SAVE(&app->settings);
|
||||
submenu_reset(app->submenu);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ static void pin_auth_back_callback(void* context) {
|
||||
void desktop_settings_scene_pin_auth_on_enter(void* context) {
|
||||
DesktopSettingsApp* app = context;
|
||||
|
||||
LOAD_DESKTOP_SETTINGS(&app->settings);
|
||||
DESKTOP_SETTINGS_LOAD(&app->settings);
|
||||
furi_assert(app->settings.pin_code.length > 0);
|
||||
|
||||
desktop_view_pin_input_set_context(app->pin_input_view, app);
|
||||
|
@ -20,7 +20,7 @@ void desktop_settings_scene_pin_disable_on_enter(void* context) {
|
||||
DesktopSettingsApp* app = context;
|
||||
app->settings.pin_code.length = 0;
|
||||
memset(app->settings.pin_code.data, '0', sizeof(app->settings.pin_code.data));
|
||||
SAVE_DESKTOP_SETTINGS(&app->settings);
|
||||
DESKTOP_SETTINGS_SAVE(&app->settings);
|
||||
|
||||
popup_set_context(app->popup, app);
|
||||
popup_set_callback(app->popup, pin_disable_back_callback);
|
||||
|
@ -24,7 +24,7 @@ void desktop_settings_scene_pin_setup_done_on_enter(void* context) {
|
||||
DesktopSettingsApp* app = context;
|
||||
|
||||
app->settings.pin_code = app->pincode_buffer;
|
||||
SAVE_DESKTOP_SETTINGS(&app->settings);
|
||||
DESKTOP_SETTINGS_SAVE(&app->settings);
|
||||
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
|
||||
notification_message(notification, &sequence_single_vibro);
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
|
@ -96,5 +96,5 @@ bool desktop_settings_scene_start_on_event(void* context, SceneManagerEvent even
|
||||
void desktop_settings_scene_start_on_exit(void* context) {
|
||||
DesktopSettingsApp* app = context;
|
||||
variable_item_list_reset(app->variable_item_list);
|
||||
SAVE_DESKTOP_SETTINGS(&app->settings);
|
||||
DESKTOP_SETTINGS_SAVE(&app->settings);
|
||||
}
|
||||
|
BIN
assets/icons/StatusBar/GameMode_11x8.png
Normal file
BIN
assets/icons/StatusBar/GameMode_11x8.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,1.4,,
|
||||
Version,+,1.5,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
Header,+,applications/services/cli/cli_vcp.h,,
|
||||
@ -2603,6 +2603,7 @@ Variable,+,I_FaceCharging_29x14,const Icon,
|
||||
Variable,+,I_FaceConfused_29x14,const Icon,
|
||||
Variable,+,I_FaceNopower_29x14,const Icon,
|
||||
Variable,+,I_FaceNormal_29x14,const Icon,
|
||||
Variable,+,I_GameMode_11x8,const Icon,
|
||||
Variable,+,I_Health_16x16,const Icon,
|
||||
Variable,+,I_InfraredArrowDown_4x8,const Icon,
|
||||
Variable,+,I_InfraredArrowUp_4x8,const Icon,
|
||||
|
|
Loading…
Reference in New Issue
Block a user