Просмотр исходного кода

Merge magspoof from https://github.com/zacharyweiss/magspoof_flipper

Willy-JL 1 год назад
Родитель
Сommit
6cf07387b2

+ 1 - 1
magspoof/application.fam

@@ -17,7 +17,7 @@ App(
     fap_category="GPIO",
     fap_icon_assets="icons",
     fap_icon_assets_symbol="mag",
-    fap_version=(0, 9),  # major, minor
+    fap_version=(0, 10),  # major, minor
     fap_description="Enables wireless transmission of magstripe data",
     fap_author="Zachary Weiss",
     fap_weburl="https://github.com/zacharyweiss/magspoof_flipper",

+ 0 - 6
magspoof/scenes/mag_scene_emulate_config.c

@@ -199,7 +199,6 @@ void mag_scene_emulate_config_on_enter(void* context) {
     item = variable_item_list_add(
         mag->variable_item_list, "Clock:", CLOCK_COUNT, mag_scene_emulate_config_set_clock, mag);
     value_index = value_index_uint32(mag->state.us_clock, clock_value, CLOCK_COUNT);
-    // scene_manager_set_scene_state(mag->scene_manager, MagSceneEmulateConfig, (uint32_t)item);
     variable_item_set_current_value_index(item, value_index);
     variable_item_set_current_value_text(item, clock_text[value_index]);
 
@@ -207,7 +206,6 @@ void mag_scene_emulate_config_on_enter(void* context) {
     item = variable_item_list_add(
         mag->variable_item_list, "Track:", TRACK_COUNT, mag_scene_emulate_config_set_track, mag);
     value_index = value_index_uint32(mag->state.track, track_value, TRACK_COUNT);
-    //scene_manager_set_scene_state(mag->scene_manager, MagSceneEmulateConfig, (uint32_t)item);
     variable_item_set_current_value_index(item, value_index);
     variable_item_set_current_value_text(item, track_text[value_index]);
 
@@ -220,7 +218,6 @@ void mag_scene_emulate_config_on_enter(void* context) {
         mag_scene_emulate_config_set_reverse,
         mag);
     value_index = value_index_uint32(mag->state.reverse, reverse_value, REVERSE_COUNT);
-    //scene_manager_set_scene_state(mag->scene_manager, MagSceneEmulateConfig, (uint32_t)item);
     variable_item_set_current_value_index(item, value_index);
     variable_item_set_current_value_text(item, reverse_text[value_index]);
 
@@ -232,7 +229,6 @@ void mag_scene_emulate_config_on_enter(void* context) {
         mag_scene_emulate_config_set_repeat_mode,
         mag);
     value_index = (uint32_t)mag->state.repeat_mode;
-    //scene_manager_set_scene_state(mag->scene_manager, MagSceneEmulateConfig, (uint32_t)item);
     variable_item_set_current_value_index(item, value_index);
     variable_item_set_current_value_text(item, reverse_text[value_index]);
 
@@ -243,7 +239,6 @@ void mag_scene_emulate_config_on_enter(void* context) {
         item = variable_item_list_add(
             mag->variable_item_list, "TX via:", TX_COUNT, mag_scene_emulate_config_set_tx, mag);
         value_index = value_index_uint32(mag->state.tx, tx_value, TX_COUNT);
-        //scene_manager_set_scene_state(mag->scene_manager, MagSceneEmulateConfig, (uint32_t)item);
         variable_item_set_current_value_index(item, value_index);
         variable_item_set_current_value_text(item, tx_text[value_index]);
 #ifdef FW_ORIGIN_Official
@@ -261,7 +256,6 @@ void mag_scene_emulate_config_on_enter(void* context) {
         mag);
     value_index =
         value_index_uint32(mag->setting->us_interpacket, interpacket_value, INTERPACKET_COUNT);
-    scene_manager_set_scene_state(mag->scene_manager, MagSceneEmulateConfig, (uint32_t)item);
     variable_item_set_current_value_index(item, value_index);
     variable_item_set_current_value_text(item, interpacket_text[value_index]);*/
     UNUSED(mag_scene_emulate_config_set_interpacket);

+ 8 - 9
magspoof/scenes/mag_scene_settings.c

@@ -10,9 +10,7 @@ enum VarItemListIndex {
     VarItemListIndexPinEnable,
     VarItemListIndexNRepeats,
     VarItemListIndexRepeatModeOn,
-#ifndef FW_ORIGIN_Official
     VarItemListIndexAllowUART,
-#endif
 };
 
 static const char* gpio[] = {
@@ -61,8 +59,6 @@ const char* const off_on_text[OFF_ON_COUNT] = {
     "ON",
 };
 
-VariableItem* item_dialog_cb;
-
 void mag_scene_settings_var_item_list_callback(void* context, uint32_t index) {
     Mag* mag = context;
     view_dispatcher_send_custom_event(mag->view_dispatcher, index);
@@ -114,7 +110,7 @@ static void mag_scene_settings_set_allow_uart(VariableItem* item) {
     bool rising = !mag->state.allow_uart && !!variable_item_get_current_value_index(item);
     // trigger dialog only on rising change
     if(rising) {
-        item_dialog_cb = item;
+        scene_manager_set_scene_state(mag->scene_manager, MagSceneSettings, (uint32_t)item);
         view_dispatcher_send_custom_event(mag->view_dispatcher, MagEventConfirmDialog);
     }
 
@@ -228,7 +224,7 @@ bool mag_scene_settings_on_event(void* context, SceneManagerEvent event) {
 
         break;
     case SceneManagerEventTypeCustom:
-        scene_manager_set_scene_state(mag->scene_manager, MagSceneSettings, event.event);
+        // scene_manager_set_scene_state(mag->scene_manager, MagSceneSettings, event.event);
         consumed = true;
         if(event.event == MagEventConfirmDialog) {
             DialogMessage* msg = dialog_message_alloc();
@@ -244,12 +240,15 @@ bool mag_scene_settings_on_event(void* context, SceneManagerEvent event) {
             DialogMessageButton res = dialog_message_show(furi_record_open(RECORD_DIALOGS), msg);
             if(res != DialogMessageButtonRight) {
                 // if not "Yes", reset to "OFF" (0 / false-y)
-                variable_item_set_current_value_index(item_dialog_cb, 0);
-                mag_scene_settings_set_bool(item_dialog_cb, &mag->state.allow_uart);
+                VariableItem* item =
+                    (VariableItem*)scene_manager_get_scene_state(scene_manager, MagSceneSettings);
+                variable_item_set_current_value_index(item, 0);
+                mag_scene_settings_set_bool(item, &mag->state.allow_uart);
             }
             dialog_message_free(msg);
             furi_record_close(RECORD_DIALOGS);
-            item_dialog_cb = NULL;
+            // clear item from scene state
+            scene_manager_set_scene_state(scene_manager, MagSceneSettings, 0);
         }
         break;
     default: