diff --git a/applications/bad_usb/bad_usb_app.c b/applications/bad_usb/bad_usb_app.c index 107371e4e..bf3f7741f 100644 --- a/applications/bad_usb/bad_usb_app.c +++ b/applications/bad_usb/bad_usb_app.c @@ -102,7 +102,9 @@ 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, BadUsbScenePWork); + app->bad_usb_script = bad_usb_script_open(app->file_path); + bad_usb_script_set_keyboard_layout(app->bad_usb_script, app->keyboard_layout); + scene_manager_next_scene(app->scene_manager, BadUsbSceneWork); } else { string_set_str(app->file_path, BAD_USB_APP_BASE_FOLDER); scene_manager_next_scene(app->scene_manager, BadUsbSceneFileSelect); @@ -122,7 +124,6 @@ void bad_usb_app_free(BadUsbApp* app) { // Views view_dispatcher_remove_view(app->view_dispatcher, BadUsbAppViewWork); - bad_usb_free(app->bad_usb_view); // Custom Widget @@ -157,4 +158,4 @@ int32_t bad_usb_app(void* p) { bad_usb_app_free(bad_usb_app); return 0; -} \ No newline at end of file +} diff --git a/applications/bad_usb/bad_usb_script.c b/applications/bad_usb/bad_usb_script.c index f50c86284..140ffffea 100644 --- a/applications/bad_usb/bad_usb_script.c +++ b/applications/bad_usb/bad_usb_script.c @@ -662,7 +662,3 @@ 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; -} \ No newline at end of file diff --git a/applications/bad_usb/bad_usb_script.h b/applications/bad_usb/bad_usb_script.h index 4cf661ddd..119beb4aa 100644 --- a/applications/bad_usb/bad_usb_script.h +++ b/applications/bad_usb/bad_usb_script.h @@ -22,7 +22,6 @@ typedef enum { typedef struct { BadUsbWorkerState state; - bool run_from_p; uint16_t line_cur; uint16_t line_nb; uint32_t delay_remain; @@ -43,8 +42,6 @@ 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 \ No newline at end of file +#endif diff --git a/applications/bad_usb/scenes/bad_usb_scene_config.h b/applications/bad_usb/scenes/bad_usb_scene_config.h index e19b185ee..423aedc51 100644 --- a/applications/bad_usb/scenes/bad_usb_scene_config.h +++ b/applications/bad_usb/scenes/bad_usb_scene_config.h @@ -1,6 +1,5 @@ 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) diff --git a/applications/bad_usb/scenes/bad_usb_scene_pwork.c b/applications/bad_usb/scenes/bad_usb_scene_pwork.c deleted file mode 100644 index b82b9de60..000000000 --- a/applications/bad_usb/scenes/bad_usb_scene_pwork.c +++ /dev/null @@ -1,62 +0,0 @@ -#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_t layout; - string_init(layout); - path_extract_filename(app->keyboard_layout, layout, true); - bad_usb_set_layout(app->bad_usb_view, string_get_cstr(layout)); - string_clear(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); -} \ No newline at end of file diff --git a/applications/bad_usb/scenes/bad_usb_scene_work.c b/applications/bad_usb/scenes/bad_usb_scene_work.c index c966947ad..1fdcfa999 100644 --- a/applications/bad_usb/scenes/bad_usb_scene_work.c +++ b/applications/bad_usb/scenes/bad_usb_scene_work.c @@ -46,9 +46,6 @@ 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); } diff --git a/applications/bad_usb/views/bad_usb_view.c b/applications/bad_usb/views/bad_usb_view.c index f8b4b932c..87c5fae49 100644 --- a/applications/bad_usb/views/bad_usb_view.c +++ b/applications/bad_usb/views/bad_usb_view.c @@ -49,9 +49,8 @@ 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)) && - !model->state.run_from_p) { + if((model->state.state == BadUsbStateNotConnected) || + (model->state.state == BadUsbStateIdle) || (model->state.state == BadUsbStateDone)) { elements_button_left(canvas, "Config"); } @@ -189,7 +188,6 @@ void bad_usb_set_layout(BadUsb* bad_usb, const char* layout) { return true; }); } - void bad_usb_set_state(BadUsb* bad_usb, BadUsbState* st) { furi_assert(st); with_view_model( @@ -198,4 +196,4 @@ void bad_usb_set_state(BadUsb* bad_usb, BadUsbState* st) { model->anim_frame ^= 1; return true; }); -} \ No newline at end of file +}