LTVA1 3 лет назад
Родитель
Сommit
890f2abf9e
3 измененных файлов с 74 добавлено и 72 удалено
  1. 0 72
      input/songinfo.c
  2. 72 0
      input_event.c
  3. 2 0
      input_event.h

+ 0 - 72
input/songinfo.c

@@ -2,78 +2,6 @@
 
 #include "../diskop.h"
 
-void return_from_keyboard_callback(void *ctx)
-{
-    FlizzerTrackerApp *tracker = (FlizzerTrackerApp *)ctx;
-
-    if(!tracker->is_loading && !tracker->is_saving)
-    {
-        uint8_t string_length = 0;
-        char *string = NULL;
-
-        if (tracker->focus == EDIT_SONGINFO && tracker->mode == PATTERN_VIEW)
-        {
-            switch (tracker->selected_param)
-            {
-                case SI_SONGNAME:
-                {
-                    string_length = MUS_SONG_NAME_LEN;
-                    string = (char *)&tracker->song.song_name;
-                    break;
-                }
-
-                case SI_INSTRUMENTNAME:
-                {
-                    string_length = MUS_INST_NAME_LEN;
-                    string = (char *)&tracker->song.instrument[tracker->current_instrument]->name;
-                    break;
-                }
-            }
-        }
-
-        if (tracker->focus == EDIT_INSTRUMENT && tracker->mode == INST_EDITOR_VIEW)
-        {
-            switch (tracker->selected_param)
-            {
-                case INST_INSTRUMENTNAME:
-                {
-                    string_length = MUS_INST_NAME_LEN;
-                    string = (char *)&tracker->song.instrument[tracker->current_instrument]->name;
-                    break;
-                }
-            }
-        }
-
-        if (string == NULL || string_length == 0)
-            return;
-
-        for (uint8_t i = 0; i < string_length; i++) // I tinyfied the font by deleting lowercase chars, and I don't like the lowercase chars of any 3x5 pixels font
-        {
-            string[i] = toupper(string[i]);
-        }
-    }
-
-    view_dispatcher_switch_to_view(tracker->view_dispatcher, VIEW_TRACKER);
-
-    if(tracker->is_saving)
-    {
-        tracker->filepath = furi_string_alloc();
-        furi_string_cat_printf(tracker->filepath, "%s/%s%s", FLIZZER_TRACKER_FOLDER, tracker->filename, SONG_FILE_EXT);
-
-        if(storage_file_exists(tracker->storage, furi_string_get_cstr(tracker->filepath)))
-        {
-            view_dispatcher_switch_to_view(tracker->view_dispatcher, VIEW_FILE_OVERWRITE);
-            return;
-        }
-
-        else
-        {
-            FlizzerTrackerEvent event = {.type = EventTypeSaveSong, .input = {0}, .period = 0};
-            furi_message_queue_put(tracker->event_queue, &event, FuriWaitForever);
-        }
-    }
-}
-
 void edit_songinfo_param(FlizzerTrackerApp *tracker, uint8_t selected_param, int8_t delta)
 {
     if (!(tracker->current_digit))

+ 72 - 0
input_event.c

@@ -2,6 +2,78 @@
 
 #include "diskop.h"
 
+void return_from_keyboard_callback(void *ctx)
+{
+    FlizzerTrackerApp *tracker = (FlizzerTrackerApp *)ctx;
+
+    if(!tracker->is_loading && !tracker->is_saving)
+    {
+        uint8_t string_length = 0;
+        char *string = NULL;
+
+        if (tracker->focus == EDIT_SONGINFO && tracker->mode == PATTERN_VIEW)
+        {
+            switch (tracker->selected_param)
+            {
+                case SI_SONGNAME:
+                {
+                    string_length = MUS_SONG_NAME_LEN;
+                    string = (char *)&tracker->song.song_name;
+                    break;
+                }
+
+                case SI_INSTRUMENTNAME:
+                {
+                    string_length = MUS_INST_NAME_LEN;
+                    string = (char *)&tracker->song.instrument[tracker->current_instrument]->name;
+                    break;
+                }
+            }
+        }
+
+        if (tracker->focus == EDIT_INSTRUMENT && tracker->mode == INST_EDITOR_VIEW)
+        {
+            switch (tracker->selected_param)
+            {
+                case INST_INSTRUMENTNAME:
+                {
+                    string_length = MUS_INST_NAME_LEN;
+                    string = (char *)&tracker->song.instrument[tracker->current_instrument]->name;
+                    break;
+                }
+            }
+        }
+
+        if (string == NULL || string_length == 0)
+            return;
+
+        for (uint8_t i = 0; i < string_length; i++) // I tinyfied the font by deleting lowercase chars, and I don't like the lowercase chars of any 3x5 pixels font
+        {
+            string[i] = toupper(string[i]);
+        }
+    }
+
+    view_dispatcher_switch_to_view(tracker->view_dispatcher, VIEW_TRACKER);
+
+    if(tracker->is_saving)
+    {
+        tracker->filepath = furi_string_alloc();
+        furi_string_cat_printf(tracker->filepath, "%s/%s%s", FLIZZER_TRACKER_FOLDER, tracker->filename, SONG_FILE_EXT);
+
+        if(storage_file_exists(tracker->storage, furi_string_get_cstr(tracker->filepath)))
+        {
+            view_dispatcher_switch_to_view(tracker->view_dispatcher, VIEW_FILE_OVERWRITE);
+            return;
+        }
+
+        else
+        {
+            FlizzerTrackerEvent event = {.type = EventTypeSaveSong, .input = {0}, .period = 0};
+            furi_message_queue_put(tracker->event_queue, &event, FuriWaitForever);
+        }
+    }
+}
+
 void overwrite_file_widget_yes_input_callback(GuiButtonType result, InputType type, void* ctx)
 {
     UNUSED(result);

+ 2 - 0
input_event.h

@@ -15,6 +15,8 @@
 #include "input/sequence.h"
 #include "input/songinfo.h"
 
+void return_from_keyboard_callback(void *ctx);
+
 void overwrite_file_widget_yes_input_callback(GuiButtonType result, InputType type, void* ctx);
 void overwrite_file_widget_no_input_callback(GuiButtonType result, InputType type, void* ctx);