mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-23 19:23:09 +00:00
77 lines
2.3 KiB
C
77 lines
2.3 KiB
C
#include "flipfrid_scene_load_custom_uids.h"
|
|
#include "flipfrid_scene_run_attack.h"
|
|
#include "flipfrid_scene_entrypoint.h"
|
|
|
|
#define LFRFID_UIDS_EXTENSION ".txt"
|
|
|
|
bool flipfrid_load_uids(FlipFridState* context, const char* file_path) {
|
|
bool result = false;
|
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
context->uids_stream = buffered_file_stream_alloc(storage);
|
|
result =
|
|
buffered_file_stream_open(context->uids_stream, file_path, FSAM_READ, FSOM_OPEN_EXISTING);
|
|
// Close if loading fails
|
|
if(!result) {
|
|
buffered_file_stream_close(context->uids_stream);
|
|
return false;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
bool flipfrid_load_custom_uids_from_file(FlipFridState* context) {
|
|
// Input events and views are managed by file_select
|
|
bool res = dialog_file_browser_show(
|
|
context->dialogs,
|
|
context->file_path,
|
|
context->file_path,
|
|
LFRFID_UIDS_EXTENSION,
|
|
true,
|
|
&I_sub1_10px,
|
|
true);
|
|
|
|
if(res) {
|
|
res = flipfrid_load_uids(context, string_get_cstr(context->file_path));
|
|
}
|
|
return res;
|
|
}
|
|
|
|
void flipfrid_scene_load_custom_uids_on_enter(FlipFridState* context) {
|
|
if(flipfrid_load_custom_uids_from_file(context)) {
|
|
// Force context loading
|
|
flipfrid_scene_run_attack_on_enter(context);
|
|
context->current_scene = SceneAttack;
|
|
} else {
|
|
flipfrid_scene_entrypoint_on_enter(context);
|
|
context->current_scene = SceneEntryPoint;
|
|
}
|
|
}
|
|
|
|
void flipfrid_scene_load_custom_uids_on_exit(FlipFridState* context) {
|
|
UNUSED(context);
|
|
}
|
|
|
|
void flipfrid_scene_load_custom_uids_on_tick(FlipFridState* context) {
|
|
UNUSED(context);
|
|
}
|
|
|
|
void flipfrid_scene_load_custom_uids_on_event(FlipFridEvent event, FlipFridState* context) {
|
|
if(event.evt_type == EventTypeKey) {
|
|
if(event.input_type == InputTypeShort) {
|
|
switch(event.key) {
|
|
case InputKeyDown:
|
|
case InputKeyUp:
|
|
case InputKeyLeft:
|
|
case InputKeyRight:
|
|
case InputKeyOk:
|
|
case InputKeyBack:
|
|
context->current_scene = SceneEntryPoint;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void flipfrid_scene_load_custom_uids_on_draw(Canvas* canvas, FlipFridState* context) {
|
|
UNUSED(context);
|
|
UNUSED(canvas);
|
|
}
|