mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-23 13:03:13 +00:00
fix badusb from archive app execution
thats very dirty fix, needs to be re-done in a proper way
This commit is contained in:
parent
9bb1e2d11a
commit
663ad953cb
7 changed files with 71 additions and 3 deletions
|
@ -102,7 +102,7 @@ BadUsbApp* bad_usb_app_alloc(char* arg) {
|
|||
scene_manager_next_scene(app->scene_manager, BadUsbSceneError);
|
||||
} else {
|
||||
if(!string_empty_p(app->file_path)) {
|
||||
scene_manager_next_scene(app->scene_manager, BadUsbSceneWork);
|
||||
scene_manager_next_scene(app->scene_manager, BadUsbScenePWork);
|
||||
} else {
|
||||
string_set_str(app->file_path, BAD_USB_APP_BASE_FOLDER);
|
||||
scene_manager_next_scene(app->scene_manager, BadUsbSceneFileSelect);
|
||||
|
|
|
@ -661,4 +661,8 @@ void bad_usb_script_toggle(BadUsbScript* bad_usb) {
|
|||
BadUsbState* bad_usb_script_get_state(BadUsbScript* bad_usb) {
|
||||
furi_assert(bad_usb);
|
||||
return &(bad_usb->st);
|
||||
}
|
||||
|
||||
void bad_usb_script_set_run_state(BadUsbState* st, bool run) {
|
||||
st->run_from_p = run;
|
||||
}
|
|
@ -22,6 +22,7 @@ typedef enum {
|
|||
|
||||
typedef struct {
|
||||
BadUsbWorkerState state;
|
||||
bool run_from_p;
|
||||
uint16_t line_cur;
|
||||
uint16_t line_nb;
|
||||
uint32_t delay_remain;
|
||||
|
@ -42,6 +43,8 @@ void bad_usb_script_toggle(BadUsbScript* bad_usb);
|
|||
|
||||
BadUsbState* bad_usb_script_get_state(BadUsbScript* bad_usb);
|
||||
|
||||
void bad_usb_script_set_run_state(BadUsbState* st, bool run);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -1,5 +1,6 @@
|
|||
ADD_SCENE(bad_usb, file_select, FileSelect)
|
||||
ADD_SCENE(bad_usb, work, Work)
|
||||
ADD_SCENE(bad_usb, pwork, PWork)
|
||||
ADD_SCENE(bad_usb, error, Error)
|
||||
ADD_SCENE(bad_usb, config, Config)
|
||||
ADD_SCENE(bad_usb, config_layout, ConfigLayout)
|
||||
|
|
56
applications/bad_usb/scenes/bad_usb_scene_pwork.c
Normal file
56
applications/bad_usb/scenes/bad_usb_scene_pwork.c
Normal file
|
@ -0,0 +1,56 @@
|
|||
#include "../bad_usb_script.h"
|
||||
#include "../bad_usb_app_i.h"
|
||||
#include "../views/bad_usb_view.h"
|
||||
#include "furi_hal.h"
|
||||
#include "m-string.h"
|
||||
#include "toolbox/path.h"
|
||||
|
||||
void bad_usb_scene_pwork_button_callback(InputKey key, void* context) {
|
||||
furi_assert(context);
|
||||
BadUsbApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, key);
|
||||
}
|
||||
|
||||
bool bad_usb_scene_pwork_on_event(void* context, SceneManagerEvent event) {
|
||||
BadUsbApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == InputKeyOk) {
|
||||
bad_usb_script_toggle(app->bad_usb_script);
|
||||
consumed = true;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeTick) {
|
||||
bad_usb_set_state(app->bad_usb_view, bad_usb_script_get_state(app->bad_usb_script));
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void bad_usb_scene_pwork_on_enter(void* context) {
|
||||
BadUsbApp* app = context;
|
||||
|
||||
string_t file_name;
|
||||
string_init(file_name);
|
||||
|
||||
path_extract_filename(app->file_path, file_name, true);
|
||||
bad_usb_set_file_name(app->bad_usb_view, string_get_cstr(file_name));
|
||||
app->bad_usb_script = bad_usb_script_open(app->file_path);
|
||||
|
||||
bad_usb_script_set_keyboard_layout(app->bad_usb_script, app->keyboard_layout);
|
||||
|
||||
string_clear(file_name);
|
||||
|
||||
bad_usb_set_state(app->bad_usb_view, bad_usb_script_get_state(app->bad_usb_script));
|
||||
|
||||
// set app state - is executed from archive app
|
||||
bad_usb_script_set_run_state(bad_usb_script_get_state(app->bad_usb_script), true);
|
||||
|
||||
bad_usb_set_button_callback(app->bad_usb_view, bad_usb_scene_pwork_button_callback, app);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, BadUsbAppViewWork);
|
||||
}
|
||||
|
||||
void bad_usb_scene_pwork_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
//BadUsbApp* app = context;
|
||||
//bad_usb_script_close(app->bad_usb_script);
|
||||
}
|
|
@ -40,6 +40,9 @@ void bad_usb_scene_work_on_enter(void* context) {
|
|||
|
||||
bad_usb_set_state(app->bad_usb_view, bad_usb_script_get_state(app->bad_usb_script));
|
||||
|
||||
// set app state - is executed from archive app
|
||||
bad_usb_script_set_run_state(bad_usb_script_get_state(app->bad_usb_script), false);
|
||||
|
||||
bad_usb_set_button_callback(app->bad_usb_view, bad_usb_scene_work_button_callback, app);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, BadUsbAppViewWork);
|
||||
}
|
||||
|
|
|
@ -34,8 +34,9 @@ static void bad_usb_draw_callback(Canvas* canvas, void* _model) {
|
|||
elements_button_center(canvas, "Stop");
|
||||
}
|
||||
|
||||
if((model->state.state == BadUsbStateNotConnected) ||
|
||||
(model->state.state == BadUsbStateIdle) || (model->state.state == BadUsbStateDone)) {
|
||||
if(((model->state.state == BadUsbStateNotConnected) ||
|
||||
(model->state.state == BadUsbStateIdle) || (model->state.state == BadUsbStateDone)) &&
|
||||
!model->state.run_from_p) {
|
||||
elements_button_left(canvas, "Config");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue