[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
#include <gui/gui_i.h>
|
|
|
|
#include <gui/view.h>
|
|
|
|
#include <gui/elements.h>
|
|
|
|
#include <gui/canvas.h>
|
2021-09-28 12:40:39 +03:00
|
|
|
#include <furi.h>
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
#include <input/input.h>
|
|
|
|
#include <dolphin/dolphin.h>
|
|
|
|
|
2021-09-28 12:40:39 +03:00
|
|
|
#include "../desktop_i.h"
|
2022-02-10 21:17:41 +03:00
|
|
|
#include "desktop_view_main.h"
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
|
|
|
|
struct DesktopMainView {
|
|
|
|
View* view;
|
|
|
|
DesktopMainViewCallback callback;
|
|
|
|
void* context;
|
2022-06-13 05:40:57 +03:00
|
|
|
TimerHandle_t poweroff_timer;
|
2022-09-17 00:43:21 +03:00
|
|
|
bool dummy_mode;
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
};
|
2021-09-28 12:40:39 +03:00
|
|
|
|
2023-02-24 03:04:36 +03:00
|
|
|
#define DESKTOP_MAIN_VIEW_POWEROFF_TIMEOUT 1300
|
2022-06-13 05:40:57 +03:00
|
|
|
|
|
|
|
static void desktop_main_poweroff_timer_callback(TimerHandle_t timer) {
|
|
|
|
DesktopMainView* main_view = pvTimerGetTimerID(timer);
|
|
|
|
main_view->callback(DesktopMainEventOpenPowerOff, main_view->context);
|
|
|
|
}
|
|
|
|
|
2021-09-28 12:40:39 +03:00
|
|
|
void desktop_main_set_callback(
|
|
|
|
DesktopMainView* main_view,
|
|
|
|
DesktopMainViewCallback callback,
|
|
|
|
void* context) {
|
|
|
|
furi_assert(main_view);
|
|
|
|
furi_assert(callback);
|
|
|
|
main_view->callback = callback;
|
|
|
|
main_view->context = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
View* desktop_main_get_view(DesktopMainView* main_view) {
|
|
|
|
furi_assert(main_view);
|
|
|
|
return main_view->view;
|
|
|
|
}
|
|
|
|
|
2022-09-17 00:43:21 +03:00
|
|
|
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) {
|
2021-09-28 12:40:39 +03:00
|
|
|
furi_assert(event);
|
|
|
|
furi_assert(context);
|
|
|
|
|
|
|
|
DesktopMainView* main_view = context;
|
|
|
|
|
2022-09-17 00:43:21 +03:00
|
|
|
if(main_view->dummy_mode == false) {
|
|
|
|
if(event->type == InputTypeShort) {
|
|
|
|
if(event->key == InputKeyOk) {
|
|
|
|
main_view->callback(DesktopMainEventOpenMenu, main_view->context);
|
|
|
|
} else if(event->key == InputKeyUp) {
|
|
|
|
main_view->callback(DesktopMainEventOpenLockMenu, main_view->context);
|
|
|
|
} else if(event->key == InputKeyDown) {
|
|
|
|
main_view->callback(DesktopMainEventOpenArchive, main_view->context);
|
|
|
|
} else if(event->key == InputKeyLeft) {
|
2023-08-17 13:04:40 +03:00
|
|
|
main_view->callback(DesktopMainEventOpenFavoriteLeftShort, main_view->context);
|
2022-09-17 00:43:21 +03:00
|
|
|
}
|
2023-08-17 13:04:40 +03:00
|
|
|
// Right key short is handled by animation manager
|
2022-09-17 00:43:21 +03:00
|
|
|
} else if(event->type == InputTypeLong) {
|
2023-08-17 13:04:40 +03:00
|
|
|
if(event->key == InputKeyUp) {
|
|
|
|
main_view->callback(DesktopMainEventLock, main_view->context);
|
|
|
|
} else if(event->key == InputKeyDown) {
|
2022-09-17 00:43:21 +03:00
|
|
|
main_view->callback(DesktopMainEventOpenDebug, main_view->context);
|
|
|
|
} else if(event->key == InputKeyLeft) {
|
2023-08-17 13:04:40 +03:00
|
|
|
main_view->callback(DesktopMainEventOpenFavoriteLeftLong, main_view->context);
|
2023-03-18 01:16:34 +03:00
|
|
|
} else if(event->key == InputKeyRight) {
|
2023-08-17 13:04:40 +03:00
|
|
|
main_view->callback(DesktopMainEventOpenFavoriteRightLong, main_view->context);
|
2022-10-28 17:30:53 +03:00
|
|
|
} else if(event->key == InputKeyOk) {
|
|
|
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
|
|
|
main_view->callback(DesktopAnimationEventNewIdleAnimation, main_view->context);
|
|
|
|
}
|
2022-09-17 00:43:21 +03:00
|
|
|
}
|
2022-01-30 19:45:08 +03:00
|
|
|
}
|
2022-09-17 00:43:21 +03:00
|
|
|
} else {
|
|
|
|
if(event->type == InputTypeShort) {
|
|
|
|
if(event->key == InputKeyOk) {
|
2023-08-17 13:04:40 +03:00
|
|
|
main_view->callback(DesktopDummyEventOpenOk, main_view->context);
|
2022-09-17 00:43:21 +03:00
|
|
|
} else if(event->key == InputKeyUp) {
|
|
|
|
main_view->callback(DesktopMainEventOpenLockMenu, main_view->context);
|
|
|
|
} else if(event->key == InputKeyDown) {
|
2023-08-17 13:04:40 +03:00
|
|
|
main_view->callback(DesktopDummyEventOpenDown, main_view->context);
|
2022-09-17 00:43:21 +03:00
|
|
|
} else if(event->key == InputKeyLeft) {
|
2023-08-17 13:04:40 +03:00
|
|
|
main_view->callback(DesktopDummyEventOpenLeft, main_view->context);
|
2022-09-17 00:43:21 +03:00
|
|
|
}
|
2023-08-17 13:04:40 +03:00
|
|
|
// Right key short is handled by animation manager
|
2022-10-27 02:19:14 +03:00
|
|
|
} else if(event->type == InputTypeLong) {
|
|
|
|
if(event->key == InputKeyOk) {
|
2023-08-17 13:40:55 +03:00
|
|
|
// Not working in DummyMode
|
|
|
|
// if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
|
|
|
// main_view->callback(DesktopAnimationEventNewIdleAnimation, main_view->context);
|
|
|
|
// }
|
|
|
|
main_view->callback(DesktopDummyEventOpenOkLong, main_view->context);
|
2022-10-27 02:19:14 +03:00
|
|
|
} else if(event->key == InputKeyUp) {
|
2023-08-17 13:04:40 +03:00
|
|
|
main_view->callback(DesktopDummyEventOpenUpLong, main_view->context);
|
2022-10-27 02:19:14 +03:00
|
|
|
} else if(event->key == InputKeyDown) {
|
2023-08-17 13:04:40 +03:00
|
|
|
main_view->callback(DesktopDummyEventOpenDownLong, main_view->context);
|
2022-10-27 02:19:14 +03:00
|
|
|
} else if(event->key == InputKeyLeft) {
|
2023-08-17 13:04:40 +03:00
|
|
|
main_view->callback(DesktopDummyEventOpenLeftLong, main_view->context);
|
2023-08-17 13:40:55 +03:00
|
|
|
} else if(event->key == InputKeyRight) {
|
|
|
|
main_view->callback(DesktopDummyEventOpenRightLong, main_view->context);
|
2022-10-27 02:19:14 +03:00
|
|
|
}
|
2022-06-13 05:40:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(event->key == InputKeyBack) {
|
|
|
|
if(event->type == InputTypePress) {
|
|
|
|
xTimerChangePeriod(
|
|
|
|
main_view->poweroff_timer,
|
|
|
|
pdMS_TO_TICKS(DESKTOP_MAIN_VIEW_POWEROFF_TIMEOUT),
|
|
|
|
portMAX_DELAY);
|
|
|
|
} else if(event->type == InputTypeRelease) {
|
|
|
|
xTimerStop(main_view->poweroff_timer, portMAX_DELAY);
|
2022-01-30 19:45:08 +03:00
|
|
|
}
|
2021-09-28 12:40:39 +03:00
|
|
|
}
|
2021-10-26 21:34:31 +03:00
|
|
|
|
2022-01-30 19:45:08 +03:00
|
|
|
return true;
|
2021-09-28 12:40:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
DesktopMainView* desktop_main_alloc() {
|
2022-02-18 22:53:46 +03:00
|
|
|
DesktopMainView* main_view = malloc(sizeof(DesktopMainView));
|
2022-01-03 00:39:56 +03:00
|
|
|
|
2021-09-28 12:40:39 +03:00
|
|
|
main_view->view = view_alloc();
|
|
|
|
view_set_context(main_view->view, main_view);
|
2022-09-17 00:43:21 +03:00
|
|
|
view_set_input_callback(main_view->view, desktop_main_input_callback);
|
2021-09-28 12:40:39 +03:00
|
|
|
|
2022-06-13 05:40:57 +03:00
|
|
|
main_view->poweroff_timer = xTimerCreate(
|
|
|
|
NULL,
|
|
|
|
pdMS_TO_TICKS(DESKTOP_MAIN_VIEW_POWEROFF_TIMEOUT),
|
|
|
|
pdFALSE,
|
|
|
|
main_view,
|
|
|
|
desktop_main_poweroff_timer_callback);
|
|
|
|
|
2021-09-28 12:40:39 +03:00
|
|
|
return main_view;
|
|
|
|
}
|
|
|
|
|
|
|
|
void desktop_main_free(DesktopMainView* main_view) {
|
|
|
|
furi_assert(main_view);
|
|
|
|
view_free(main_view->view);
|
2022-07-20 13:56:33 +03:00
|
|
|
furi_timer_free(main_view->poweroff_timer);
|
2021-09-28 12:40:39 +03:00
|
|
|
free(main_view);
|
|
|
|
}
|