Willy-JL 2 лет назад
Родитель
Сommit
56b91c7da0

+ 2 - 3
minesweeper/helpers/mine_sweeper_haptic.c

@@ -1,7 +1,6 @@
 #include "mine_sweeper_haptic.h"
 #include "mine_sweeper_haptic.h"
 #include "../minesweeper.h"
 #include "../minesweeper.h"
 
 
-
 void mine_sweeper_play_happy_bump(void* context) {
 void mine_sweeper_play_happy_bump(void* context) {
     MineSweeperApp* app = context;
     MineSweeperApp* app = context;
 
 
@@ -13,7 +12,7 @@ void mine_sweeper_play_happy_bump(void* context) {
 void mine_sweeper_play_long_ok_bump(void* context) {
 void mine_sweeper_play_long_ok_bump(void* context) {
     MineSweeperApp* app = context;
     MineSweeperApp* app = context;
 
 
-    for (int i = 0; i < 2; i++) {
+    for(int i = 0; i < 2; i++) {
         notification_message(app->notification, &sequence_set_vibro_on);
         notification_message(app->notification, &sequence_set_vibro_on);
         furi_thread_flags_wait(0, FuriFlagWaitAny, 20);
         furi_thread_flags_wait(0, FuriFlagWaitAny, 20);
         notification_message(app->notification, &sequence_reset_vibro);
         notification_message(app->notification, &sequence_reset_vibro);
@@ -41,7 +40,7 @@ void mine_sweeper_play_lose_bump(void* context) {
 void mine_sweeper_play_win_bump(void* context) {
 void mine_sweeper_play_win_bump(void* context) {
     MineSweeperApp* app = context;
     MineSweeperApp* app = context;
 
 
-    for (int i = 0; i < 4; i++) {
+    for(int i = 0; i < 4; i++) {
         notification_message(app->notification, &sequence_set_vibro_on);
         notification_message(app->notification, &sequence_set_vibro_on);
         furi_thread_flags_wait(0, FuriFlagWaitAny, 50);
         furi_thread_flags_wait(0, FuriFlagWaitAny, 50);
         notification_message(app->notification, &sequence_reset_vibro);
         notification_message(app->notification, &sequence_reset_vibro);

+ 0 - 1
minesweeper/helpers/mine_sweeper_haptic.h

@@ -13,5 +13,4 @@ void mine_sweeper_play_lose_bump(void* context);
 
 
 void mine_sweeper_play_win_bump(void* context);
 void mine_sweeper_play_win_bump(void* context);
 
 
-
 #endif
 #endif

+ 11 - 8
minesweeper/helpers/mine_sweeper_led.c

@@ -1,8 +1,6 @@
 #include "mine_sweeper_led.h"
 #include "mine_sweeper_led.h"
 #include "../minesweeper.h"
 #include "../minesweeper.h"
 
 
-
-
 void mine_sweeper_led_set_rgb(void* context, int red, int green, int blue) {
 void mine_sweeper_led_set_rgb(void* context, int red, int green, int blue) {
     MineSweeperApp* app = context;
     MineSweeperApp* app = context;
 
 
@@ -24,7 +22,8 @@ void mine_sweeper_led_set_rgb(void* context, int red, int green, int blue) {
         NULL,
         NULL,
     };
     };
     notification_message(app->notification, &notification_sequence);
     notification_message(app->notification, &notification_sequence);
-    furi_thread_flags_wait(0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set    
+    furi_thread_flags_wait(
+        0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set
 }
 }
 
 
 void mine_sweeper_led_blink_red(void* context) {
 void mine_sweeper_led_blink_red(void* context) {
@@ -32,7 +31,8 @@ void mine_sweeper_led_blink_red(void* context) {
     MineSweeperApp* app = context;
     MineSweeperApp* app = context;
 
 
     notification_message(app->notification, &sequence_blink_red_100);
     notification_message(app->notification, &sequence_blink_red_100);
-    furi_thread_flags_wait(0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set    
+    furi_thread_flags_wait(
+        0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set
 }
 }
 
 
 void mine_sweeper_led_blink_magenta(void* context) {
 void mine_sweeper_led_blink_magenta(void* context) {
@@ -40,7 +40,8 @@ void mine_sweeper_led_blink_magenta(void* context) {
     MineSweeperApp* app = context;
     MineSweeperApp* app = context;
 
 
     notification_message(app->notification, &sequence_blink_magenta_100);
     notification_message(app->notification, &sequence_blink_magenta_100);
-    furi_thread_flags_wait(0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set    
+    furi_thread_flags_wait(
+        0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set
 }
 }
 
 
 void mine_sweeper_led_blink_cyan(void* context) {
 void mine_sweeper_led_blink_cyan(void* context) {
@@ -48,7 +49,8 @@ void mine_sweeper_led_blink_cyan(void* context) {
     MineSweeperApp* app = context;
     MineSweeperApp* app = context;
 
 
     notification_message(app->notification, &sequence_blink_cyan_100);
     notification_message(app->notification, &sequence_blink_cyan_100);
-    furi_thread_flags_wait(0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set    
+    furi_thread_flags_wait(
+        0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set
 }
 }
 
 
 void mine_sweeper_led_reset(void* context) {
 void mine_sweeper_led_reset(void* context) {
@@ -56,6 +58,7 @@ void mine_sweeper_led_reset(void* context) {
     notification_message(app->notification, &sequence_reset_red);
     notification_message(app->notification, &sequence_reset_red);
     notification_message(app->notification, &sequence_reset_green);
     notification_message(app->notification, &sequence_reset_green);
     notification_message(app->notification, &sequence_reset_blue);
     notification_message(app->notification, &sequence_reset_blue);
-    
-    furi_thread_flags_wait(0, FuriFlagWaitAny, 300); //Delay, prevent removal from RAM before LED value set    
+
+    furi_thread_flags_wait(
+        0, FuriFlagWaitAny, 300); //Delay, prevent removal from RAM before LED value set
 }
 }

+ 0 - 1
minesweeper/helpers/mine_sweeper_led.h

@@ -11,5 +11,4 @@ void mine_sweeper_led_blink_cyan(void* context);
 
 
 void mine_sweeper_led_reset(void* context);
 void mine_sweeper_led_reset(void* context);
 
 
-
 #endif
 #endif

+ 0 - 5
minesweeper/helpers/mine_sweeper_speaker.c

@@ -10,7 +10,6 @@ void mine_sweeper_play_ok_sound(void* context) {
     if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
     if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
         furi_hal_speaker_start(NOTE_LOSE, volume);
         furi_hal_speaker_start(NOTE_LOSE, volume);
     }
     }
-
 }
 }
 
 
 void mine_sweeper_play_flag_sound(void* context) {
 void mine_sweeper_play_flag_sound(void* context) {
@@ -20,7 +19,6 @@ void mine_sweeper_play_flag_sound(void* context) {
     if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
     if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
         furi_hal_speaker_start(NOTE_FLAG, volume);
         furi_hal_speaker_start(NOTE_FLAG, volume);
     }
     }
-
 }
 }
 
 
 void mine_sweeper_play_oob_sound(void* context) {
 void mine_sweeper_play_oob_sound(void* context) {
@@ -30,7 +28,6 @@ void mine_sweeper_play_oob_sound(void* context) {
     if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
     if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
         furi_hal_speaker_start(NOTE_OOB, volume);
         furi_hal_speaker_start(NOTE_OOB, volume);
     }
     }
-
 }
 }
 
 
 void mine_sweeper_play_win_sound(void* context) {
 void mine_sweeper_play_win_sound(void* context) {
@@ -40,7 +37,6 @@ void mine_sweeper_play_win_sound(void* context) {
     if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
     if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
         furi_hal_speaker_start(NOTE_WIN, volume);
         furi_hal_speaker_start(NOTE_WIN, volume);
     }
     }
-
 }
 }
 
 
 void mine_sweeper_play_lose_sound(void* context) {
 void mine_sweeper_play_lose_sound(void* context) {
@@ -50,7 +46,6 @@ void mine_sweeper_play_lose_sound(void* context) {
     if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
     if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
         furi_hal_speaker_start(NOTE_LOSE, volume);
         furi_hal_speaker_start(NOTE_LOSE, volume);
     }
     }
-
 }
 }
 
 
 void mine_sweeper_stop_all_sound(void* context) {
 void mine_sweeper_stop_all_sound(void* context) {

+ 2 - 3
minesweeper/helpers/mine_sweeper_speaker.h

@@ -3,8 +3,8 @@
 
 
 #define NOTE_OK 3078.95f //G_4
 #define NOTE_OK 3078.95f //G_4
 #define NOTE_FLAG 384.87f //G_4
 #define NOTE_FLAG 384.87f //G_4
-#define NOTE_OOB 342.88f  //F_4
-#define NOTE_WIN 432.00f  //Divine
+#define NOTE_OOB 342.88f //F_4
+#define NOTE_WIN 432.00f //Divine
 #define NOTE_LOSE 4170.00f //Cursed
 #define NOTE_LOSE 4170.00f //Cursed
 
 
 void mine_sweeper_play_ok_sound(void* context);
 void mine_sweeper_play_ok_sound(void* context);
@@ -14,5 +14,4 @@ void mine_sweeper_play_win_sound(void* context);
 void mine_sweeper_play_lose_sound(void* context);
 void mine_sweeper_play_lose_sound(void* context);
 void mine_sweeper_stop_all_sound(void* context);
 void mine_sweeper_stop_all_sound(void* context);
 
 
-
 #endif
 #endif

+ 36 - 33
minesweeper/helpers/mine_sweeper_storage.c

@@ -1,6 +1,5 @@
 #include "mine_sweeper_storage.h"
 #include "mine_sweeper_storage.h"
 
 
-
 static Storage* mine_sweeper_open_storage() {
 static Storage* mine_sweeper_open_storage() {
     return furi_record_open(RECORD_STORAGE);
     return furi_record_open(RECORD_STORAGE);
 }
 }
@@ -10,7 +9,7 @@ static void mine_sweeper_close_storage() {
 }
 }
 
 
 static void mine_sweeper_close_config_file(FlipperFormat* file) {
 static void mine_sweeper_close_config_file(FlipperFormat* file) {
-    if (file == NULL) return;
+    if(file == NULL) return;
     flipper_format_file_close(file);
     flipper_format_file_close(file);
     flipper_format_free(file);
     flipper_format_free(file);
 }
 }
@@ -20,7 +19,7 @@ void mine_sweeper_save_settings(void* context) {
 
 
     Storage* storage = mine_sweeper_open_storage();
     Storage* storage = mine_sweeper_open_storage();
     FlipperFormat* fff_file = flipper_format_file_alloc(storage);
     FlipperFormat* fff_file = flipper_format_file_alloc(storage);
-    
+
     // Overwrite wont work, so delete first
     // Overwrite wont work, so delete first
     if(storage_file_exists(storage, MINESWEEPER_SETTINGS_SAVE_PATH)) {
     if(storage_file_exists(storage, MINESWEEPER_SETTINGS_SAVE_PATH)) {
         storage_simply_remove(storage, MINESWEEPER_SETTINGS_SAVE_PATH);
         storage_simply_remove(storage, MINESWEEPER_SETTINGS_SAVE_PATH);
@@ -28,12 +27,11 @@ void mine_sweeper_save_settings(void* context) {
 
 
     // Open File, create if not exists
     // Open File, create if not exists
     if(!storage_common_stat(storage, MINESWEEPER_SETTINGS_SAVE_PATH, NULL) == FSE_OK) {
     if(!storage_common_stat(storage, MINESWEEPER_SETTINGS_SAVE_PATH, NULL) == FSE_OK) {
-        FURI_LOG_I(TAG, "Config file %s is not found. Will create new.", MINESWEEPER_SETTINGS_SAVE_PATH);
+        FURI_LOG_I(
+            TAG, "Config file %s is not found. Will create new.", MINESWEEPER_SETTINGS_SAVE_PATH);
         if(storage_common_stat(storage, CONFIG_FILE_DIRECTORY_PATH, NULL) == FSE_NOT_EXIST) {
         if(storage_common_stat(storage, CONFIG_FILE_DIRECTORY_PATH, NULL) == FSE_NOT_EXIST) {
             FURI_LOG_I(
             FURI_LOG_I(
-                TAG,
-                "Directory %s doesn't exist. Will create new.",
-                CONFIG_FILE_DIRECTORY_PATH);
+                TAG, "Directory %s doesn't exist. Will create new.", CONFIG_FILE_DIRECTORY_PATH);
             if(!storage_simply_mkdir(storage, CONFIG_FILE_DIRECTORY_PATH)) {
             if(!storage_simply_mkdir(storage, CONFIG_FILE_DIRECTORY_PATH)) {
                 FURI_LOG_E(TAG, "Error creating directory %s", CONFIG_FILE_DIRECTORY_PATH);
                 FURI_LOG_E(TAG, "Error creating directory %s", CONFIG_FILE_DIRECTORY_PATH);
             }
             }
@@ -45,26 +43,21 @@ void mine_sweeper_save_settings(void* context) {
         mine_sweeper_close_storage();
         mine_sweeper_close_storage();
         return;
         return;
     }
     }
-    
+
     // Store Settings
     // Store Settings
     flipper_format_write_header_cstr(
     flipper_format_write_header_cstr(
         fff_file, MINESWEEPER_SETTINGS_HEADER, MINESWEEPER_SETTINGS_FILE_VERSION);
         fff_file, MINESWEEPER_SETTINGS_HEADER, MINESWEEPER_SETTINGS_FILE_VERSION);
-    flipper_format_write_uint32(
-        fff_file, MINESWEEPER_SETTINGS_KEY_HAPTIC, &app->haptic, 1);
-    flipper_format_write_uint32(
-        fff_file, MINESWEEPER_SETTINGS_KEY_SPEAKER, &app->speaker, 1);
-    flipper_format_write_uint32(
-        fff_file, MINESWEEPER_SETTINGS_KEY_LED, &app->led, 1);
-
-    uint32_t w = app->settings_info.board_width, h = app->settings_info.board_height, d = app->settings_info.difficulty;
-
-    flipper_format_write_uint32(
-        fff_file, MINESWEEPER_SETTINGS_KEY_WIDTH, &w, 1);
-    flipper_format_write_uint32(
-        fff_file, MINESWEEPER_SETTINGS_KEY_HEIGHT, &h, 1);
-    flipper_format_write_uint32(
-        fff_file, MINESWEEPER_SETTINGS_KEY_DIFFICULTY, &d, 1);
-    
+    flipper_format_write_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_HAPTIC, &app->haptic, 1);
+    flipper_format_write_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_SPEAKER, &app->speaker, 1);
+    flipper_format_write_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_LED, &app->led, 1);
+
+    uint32_t w = app->settings_info.board_width, h = app->settings_info.board_height,
+             d = app->settings_info.difficulty;
+
+    flipper_format_write_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_WIDTH, &w, 1);
+    flipper_format_write_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_HEIGHT, &h, 1);
+    flipper_format_write_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_DIFFICULTY, &d, 1);
+
     if(!flipper_format_rewind(fff_file)) {
     if(!flipper_format_rewind(fff_file)) {
         FURI_LOG_E(TAG, "Rewind error");
         FURI_LOG_E(TAG, "Rewind error");
         mine_sweeper_close_config_file(fff_file);
         mine_sweeper_close_config_file(fff_file);
@@ -92,7 +85,7 @@ bool mine_sweeper_read_settings(void* context) {
     uint32_t file_version;
     uint32_t file_version;
     FuriString* temp_str = furi_string_alloc();
     FuriString* temp_str = furi_string_alloc();
 
 
-    if (!flipper_format_file_open_existing(fff_file, MINESWEEPER_SETTINGS_SAVE_PATH)) {
+    if(!flipper_format_file_open_existing(fff_file, MINESWEEPER_SETTINGS_SAVE_PATH)) {
         FURI_LOG_E(TAG, "Cannot open file %s", MINESWEEPER_SETTINGS_SAVE_PATH);
         FURI_LOG_E(TAG, "Cannot open file %s", MINESWEEPER_SETTINGS_SAVE_PATH);
         mine_sweeper_close_config_file(fff_file);
         mine_sweeper_close_config_file(fff_file);
         mine_sweeper_close_storage();
         mine_sweeper_close_storage();
@@ -120,15 +113,25 @@ bool mine_sweeper_read_settings(void* context) {
     flipper_format_read_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_HEIGHT, &h, 1);
     flipper_format_read_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_HEIGHT, &h, 1);
     flipper_format_read_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_DIFFICULTY, &d, 1);
     flipper_format_read_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_DIFFICULTY, &d, 1);
 
 
-    if (w > 146) {w = 146;}
-    if (w < 16 ) {w = 16;}
-    if (h > 64 ) {h = 64;}
-    if (h < 7  ) {h = 7;}
-    if (d > 2 ) {d = 2;}
+    if(w > 146) {
+        w = 146;
+    }
+    if(w < 16) {
+        w = 16;
+    }
+    if(h > 64) {
+        h = 64;
+    }
+    if(h < 7) {
+        h = 7;
+    }
+    if(d > 2) {
+        d = 2;
+    }
 
 
-    app->settings_info.board_width = (uint8_t) w;
-    app->settings_info.board_height = (uint8_t) h;
-    app->settings_info.difficulty = (uint8_t) d;
+    app->settings_info.board_width = (uint8_t)w;
+    app->settings_info.board_height = (uint8_t)h;
+    app->settings_info.difficulty = (uint8_t)d;
 
 
     flipper_format_read_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_HAPTIC, &app->haptic, 1);
     flipper_format_read_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_HAPTIC, &app->haptic, 1);
     flipper_format_read_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_SPEAKER, &app->speaker, 1);
     flipper_format_read_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_SPEAKER, &app->speaker, 1);

+ 38 - 28
minesweeper/minesweeper.c

@@ -19,27 +19,29 @@ static void minesweeper_tick_event_callback(void* context) {
     return scene_manager_handle_tick_event(app->scene_manager);
     return scene_manager_handle_tick_event(app->scene_manager);
 }
 }
 
 
-static MineSweeperApp* app_alloc() { 
+static MineSweeperApp* app_alloc() {
     MineSweeperApp* app = (MineSweeperApp*)malloc(sizeof(MineSweeperApp));
     MineSweeperApp* app = (MineSweeperApp*)malloc(sizeof(MineSweeperApp));
-    
+
     // NotificationApp Service
     // NotificationApp Service
     app->notification = furi_record_open(RECORD_NOTIFICATION);
     app->notification = furi_record_open(RECORD_NOTIFICATION);
 
 
     // Turn backlight on when app starts
     // Turn backlight on when app starts
     notification_message(app->notification, &sequence_display_backlight_on);
     notification_message(app->notification, &sequence_display_backlight_on);
 
 
-
-    // Alloc Scene Manager and set handlers for on_enter, on_event, on_exit 
+    // Alloc Scene Manager and set handlers for on_enter, on_event, on_exit
     app->scene_manager = scene_manager_alloc(&minesweeper_scene_handlers, app);
     app->scene_manager = scene_manager_alloc(&minesweeper_scene_handlers, app);
-    
+
     // Alloc View Dispatcher and enable queue
     // Alloc View Dispatcher and enable queue
     app->view_dispatcher = view_dispatcher_alloc();
     app->view_dispatcher = view_dispatcher_alloc();
     view_dispatcher_enable_queue(app->view_dispatcher);
     view_dispatcher_enable_queue(app->view_dispatcher);
     // Set View Dispatcher event callback context and callbacks
     // Set View Dispatcher event callback context and callbacks
     view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
     view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
-    view_dispatcher_set_custom_event_callback(app->view_dispatcher, minesweeper_custom_event_callback);
-    view_dispatcher_set_navigation_event_callback(app->view_dispatcher, minesweeper_navigation_event_callback);
-    view_dispatcher_set_tick_event_callback(app->view_dispatcher, minesweeper_tick_event_callback, 500);
+    view_dispatcher_set_custom_event_callback(
+        app->view_dispatcher, minesweeper_custom_event_callback);
+    view_dispatcher_set_navigation_event_callback(
+        app->view_dispatcher, minesweeper_navigation_event_callback);
+    view_dispatcher_set_tick_event_callback(
+        app->view_dispatcher, minesweeper_tick_event_callback, 500);
 
 
     // Set setting info to default
     // Set setting info to default
     app->settings_info.width_str = furi_string_alloc();
     app->settings_info.width_str = furi_string_alloc();
@@ -48,7 +50,7 @@ static MineSweeperApp* app_alloc() {
     app->is_settings_changed = false;
     app->is_settings_changed = false;
 
 
     // If we cannot read the save file set to default values
     // If we cannot read the save file set to default values
-    if (!(mine_sweeper_read_settings(app))) {
+    if(!(mine_sweeper_read_settings(app))) {
         FURI_LOG_I(TAG, "Cannot read save file, loading defaults");
         FURI_LOG_I(TAG, "Cannot read save file, loading defaults");
         app->settings_info.board_width = 16;
         app->settings_info.board_width = 16;
         app->settings_info.board_height = 7;
         app->settings_info.board_height = 7;
@@ -65,18 +67,19 @@ static MineSweeperApp* app_alloc() {
     // Alloc views and add to view dispatcher
     // Alloc views and add to view dispatcher
     app->start_screen = start_screen_alloc();
     app->start_screen = start_screen_alloc();
     view_dispatcher_add_view(
     view_dispatcher_add_view(
-            app->view_dispatcher,
-            MineSweeperStartScreenView,
-            start_screen_get_view(app->start_screen));
+        app->view_dispatcher,
+        MineSweeperStartScreenView,
+        start_screen_get_view(app->start_screen));
 
 
     app->loading = loading_alloc();
     app->loading = loading_alloc();
-    view_dispatcher_add_view(app->view_dispatcher, MineSweeperLoadingView, loading_get_view(app->loading));
+    view_dispatcher_add_view(
+        app->view_dispatcher, MineSweeperLoadingView, loading_get_view(app->loading));
 
 
     app->game_screen = mine_sweeper_game_screen_alloc(
     app->game_screen = mine_sweeper_game_screen_alloc(
-            app->settings_info.board_width,
-            app->settings_info.board_height,
-            app->settings_info.difficulty,
-            false);
+        app->settings_info.board_width,
+        app->settings_info.board_height,
+        app->settings_info.difficulty,
+        false);
 
 
     view_dispatcher_add_view(
     view_dispatcher_add_view(
         app->view_dispatcher,
         app->view_dispatcher,
@@ -84,21 +87,29 @@ static MineSweeperApp* app_alloc() {
         mine_sweeper_game_screen_get_view(app->game_screen));
         mine_sweeper_game_screen_get_view(app->game_screen));
 
 
     app->menu_screen = dialog_ex_alloc();
     app->menu_screen = dialog_ex_alloc();
-    view_dispatcher_add_view(app->view_dispatcher, MineSweeperMenuView, dialog_ex_get_view(app->menu_screen));
+    view_dispatcher_add_view(
+        app->view_dispatcher, MineSweeperMenuView, dialog_ex_get_view(app->menu_screen));
 
 
     app->settings_screen = variable_item_list_alloc();
     app->settings_screen = variable_item_list_alloc();
-    view_dispatcher_add_view(app->view_dispatcher, MineSweeperSettingsView, variable_item_list_get_view(app->settings_screen));
+    view_dispatcher_add_view(
+        app->view_dispatcher,
+        MineSweeperSettingsView,
+        variable_item_list_get_view(app->settings_screen));
 
 
     app->confirmation_screen = dialog_ex_alloc();
     app->confirmation_screen = dialog_ex_alloc();
-    view_dispatcher_add_view(app->view_dispatcher, MineSweeperConfirmationView, dialog_ex_get_view(app->confirmation_screen));
+    view_dispatcher_add_view(
+        app->view_dispatcher,
+        MineSweeperConfirmationView,
+        dialog_ex_get_view(app->confirmation_screen));
 
 
     app->info_screen = text_box_alloc();
     app->info_screen = text_box_alloc();
-    view_dispatcher_add_view(app->view_dispatcher, MineSweeperInfoView, text_box_get_view(app->info_screen));
+    view_dispatcher_add_view(
+        app->view_dispatcher, MineSweeperInfoView, text_box_get_view(app->info_screen));
 
 
     Gui* gui = furi_record_open(RECORD_GUI);
     Gui* gui = furi_record_open(RECORD_GUI);
 
 
     view_dispatcher_attach_to_gui(app->view_dispatcher, gui, ViewDispatcherTypeFullscreen);
     view_dispatcher_attach_to_gui(app->view_dispatcher, gui, ViewDispatcherTypeFullscreen);
-    
+
     furi_record_close(RECORD_GUI);
     furi_record_close(RECORD_GUI);
 
 
     return app;
     return app;
@@ -106,10 +117,11 @@ static MineSweeperApp* app_alloc() {
 
 
 static void app_free(MineSweeperApp* app) {
 static void app_free(MineSweeperApp* app) {
     furi_assert(app);
     furi_assert(app);
-    
-    // Remove each view from View Dispatcher
-    for (MineSweeperView minesweeper_view = (MineSweeperView)0; minesweeper_view < MineSweeperViewCount; minesweeper_view++) {
 
 
+    // Remove each view from View Dispatcher
+    for(MineSweeperView minesweeper_view = (MineSweeperView)0;
+        minesweeper_view < MineSweeperViewCount;
+        minesweeper_view++) {
         view_dispatcher_remove_view(app->view_dispatcher, minesweeper_view);
         view_dispatcher_remove_view(app->view_dispatcher, minesweeper_view);
     }
     }
 
 
@@ -120,13 +132,12 @@ static void app_free(MineSweeperApp* app) {
     // Free views
     // Free views
     loading_free(app->loading);
     loading_free(app->loading);
     start_screen_free(app->start_screen);
     start_screen_free(app->start_screen);
-    mine_sweeper_game_screen_free(app->game_screen);  
+    mine_sweeper_game_screen_free(app->game_screen);
     dialog_ex_free(app->menu_screen);
     dialog_ex_free(app->menu_screen);
     variable_item_list_free(app->settings_screen);
     variable_item_list_free(app->settings_screen);
     dialog_ex_free(app->confirmation_screen);
     dialog_ex_free(app->confirmation_screen);
     text_box_free(app->info_screen);
     text_box_free(app->info_screen);
 
 
-
     furi_string_free(app->settings_info.width_str);
     furi_string_free(app->settings_info.width_str);
     furi_string_free(app->settings_info.height_str);
     furi_string_free(app->settings_info.height_str);
 
 
@@ -134,7 +145,6 @@ static void app_free(MineSweeperApp* app) {
 
 
     // Free app structure
     // Free app structure
     free(app);
     free(app);
-
 }
 }
 
 
 int32_t minesweeper_app(void* p) {
 int32_t minesweeper_app(void* p) {

+ 1 - 1
minesweeper/minesweeper.h

@@ -44,7 +44,7 @@ typedef struct {
 typedef struct MineSweeperApp {
 typedef struct MineSweeperApp {
     SceneManager* scene_manager;
     SceneManager* scene_manager;
     ViewDispatcher* view_dispatcher;
     ViewDispatcher* view_dispatcher;
-    
+
     NotificationApp* notification;
     NotificationApp* notification;
 
 
     StartScreen* start_screen;
     StartScreen* start_screen;

+ 51 - 44
minesweeper/scenes/confirmation_scene.c

@@ -12,12 +12,19 @@ void minesweeper_scene_confirmation_screen_on_enter(void* context) {
     MineSweeperApp* app = (MineSweeperApp*)context;
     MineSweeperApp* app = (MineSweeperApp*)context;
 
 
     view_dispatcher_switch_to_view(app->view_dispatcher, MineSweeperLoadingView);
     view_dispatcher_switch_to_view(app->view_dispatcher, MineSweeperLoadingView);
-    
+
     dialog_ex_set_context(app->confirmation_screen, app);
     dialog_ex_set_context(app->confirmation_screen, app);
 
 
-    dialog_ex_set_header(app->confirmation_screen, "Save Settings?", 128/2, 4, AlignCenter, AlignTop);
+    dialog_ex_set_header(
+        app->confirmation_screen, "Save Settings?", 128 / 2, 4, AlignCenter, AlignTop);
 
 
-    dialog_ex_set_text(app->confirmation_screen, "Warning: Saving will reset\nthe game with the\nselected settings.", 128/2, 64/2, AlignCenter, AlignCenter);
+    dialog_ex_set_text(
+        app->confirmation_screen,
+        "Warning: Saving will reset\nthe game with the\nselected settings.",
+        128 / 2,
+        64 / 2,
+        AlignCenter,
+        AlignCenter);
 
 
     dialog_ex_set_left_button_text(app->confirmation_screen, "Back");
     dialog_ex_set_left_button_text(app->confirmation_screen, "Back");
 
 
@@ -33,61 +40,61 @@ void minesweeper_scene_confirmation_screen_on_enter(void* context) {
 bool minesweeper_scene_confirmation_screen_on_event(void* context, SceneManagerEvent event) {
 bool minesweeper_scene_confirmation_screen_on_event(void* context, SceneManagerEvent event) {
     furi_assert(context);
     furi_assert(context);
 
 
-    MineSweeperApp* app = context; 
+    MineSweeperApp* app = context;
     bool consumed = false;
     bool consumed = false;
-    
-    if (event.type == SceneManagerEventTypeCustom) {
-        switch (event.event) {
-
-            case DialogExResultLeft :
-                if (!scene_manager_search_and_switch_to_previous_scene(
-                        app->scene_manager, MineSweeperSceneSettingsScreen)) {
 
 
-                    scene_manager_stop(app->scene_manager);
-                    view_dispatcher_stop(app->view_dispatcher);
-                }
-                break;
+    if(event.type == SceneManagerEventTypeCustom) {
+        switch(event.event) {
+        case DialogExResultLeft:
+            if(!scene_manager_search_and_switch_to_previous_scene(
+                   app->scene_manager, MineSweeperSceneSettingsScreen)) {
+                scene_manager_stop(app->scene_manager);
+                view_dispatcher_stop(app->view_dispatcher);
+            }
+            break;
 
 
-            case DialogExResultRight : 
+        case DialogExResultRight:
 
 
-                view_dispatcher_switch_to_view(app->view_dispatcher, MineSweeperLoadingView);
+            view_dispatcher_switch_to_view(app->view_dispatcher, MineSweeperLoadingView);
 
 
-                // Commit changes to actual buffer for settings data
-                app->settings_info.board_width  = app->t_settings_info.board_width;
-                app->settings_info.board_height = app->t_settings_info.board_height;
-                app->settings_info.difficulty   = app->t_settings_info.difficulty;
-                app->settings_info.ensure_solvable_board = app->t_settings_info.ensure_solvable_board;
+            // Commit changes to actual buffer for settings data
+            app->settings_info.board_width = app->t_settings_info.board_width;
+            app->settings_info.board_height = app->t_settings_info.board_height;
+            app->settings_info.difficulty = app->t_settings_info.difficulty;
+            app->settings_info.ensure_solvable_board = app->t_settings_info.ensure_solvable_board;
 
 
-                mine_sweeper_save_settings(app);
+            mine_sweeper_save_settings(app);
 
 
-                // This is used to let the settings view know it can save the main settings_info
-                // to the temp one on the next on enter
-                app->is_settings_changed = false;
+            // This is used to let the settings view know it can save the main settings_info
+            // to the temp one on the next on enter
+            app->is_settings_changed = false;
 
 
-                // Reset the game board
-                mine_sweeper_game_screen_reset(
-                        app->game_screen,
-                        app->settings_info.board_width,
-                        app->settings_info.board_height,
-                        app->settings_info.difficulty,
-                        app->settings_info.ensure_solvable_board);
+            // Reset the game board
+            mine_sweeper_game_screen_reset(
+                app->game_screen,
+                app->settings_info.board_width,
+                app->settings_info.board_height,
+                app->settings_info.difficulty,
+                app->settings_info.ensure_solvable_board);
 
 
-                // Go to reset game view
-                scene_manager_search_and_switch_to_another_scene(app->scene_manager, MineSweeperSceneGameScreen); 
-                break;
+            // Go to reset game view
+            scene_manager_search_and_switch_to_another_scene(
+                app->scene_manager, MineSweeperSceneGameScreen);
+            break;
 
 
-            case DialogExResultCenter :
-                // Do not commit changes to actual buffer on cancel
+        case DialogExResultCenter:
+            // Do not commit changes to actual buffer on cancel
 
 
-                app->is_settings_changed = false;
+            app->is_settings_changed = false;
 
 
-                // we want to just switch back to the game screen without resetting 
-                scene_manager_search_and_switch_to_another_scene(app->scene_manager, MineSweeperSceneGameScreen); 
+            // we want to just switch back to the game screen without resetting
+            scene_manager_search_and_switch_to_another_scene(
+                app->scene_manager, MineSweeperSceneGameScreen);
 
 
-                break;
+            break;
 
 
-            default :
-                break;
+        default:
+            break;
         }
         }
         consumed = true;
         consumed = true;
     }
     }

+ 3 - 3
minesweeper/scenes/game_screen_scene.c

@@ -6,7 +6,7 @@
 void minesweeper_scene_game_screen_on_enter(void* context) {
 void minesweeper_scene_game_screen_on_enter(void* context) {
     furi_assert(context);
     furi_assert(context);
     MineSweeperApp* app = context;
     MineSweeperApp* app = context;
-    
+
     furi_assert(app->game_screen);
     furi_assert(app->game_screen);
 
 
     mine_sweeper_game_screen_set_context(app->game_screen, app);
     mine_sweeper_game_screen_set_context(app->game_screen, app);
@@ -22,7 +22,7 @@ bool minesweeper_scene_game_screen_on_event(void* context, SceneManagerEvent eve
 
 
     // No custom scene events from mine sweeper view
     // No custom scene events from mine sweeper view
     // Just check for back button to route to next screen
     // Just check for back button to route to next screen
-    if (event.type == SceneManagerEventTypeBack) {
+    if(event.type == SceneManagerEventTypeBack) {
         scene_manager_next_scene(app->scene_manager, MineSweeperSceneMenuScreen);
         scene_manager_next_scene(app->scene_manager, MineSweeperSceneMenuScreen);
         consumed = true;
         consumed = true;
     }
     }
@@ -33,7 +33,7 @@ bool minesweeper_scene_game_screen_on_event(void* context, SceneManagerEvent eve
 void minesweeper_scene_game_screen_on_exit(void* context) {
 void minesweeper_scene_game_screen_on_exit(void* context) {
     furi_assert(context);
     furi_assert(context);
     MineSweeperApp* app = context;
     MineSweeperApp* app = context;
-    
+
     // Do not call reset function for mine sweeper module
     // Do not call reset function for mine sweeper module
     //unless you want to reset the state of the board
     //unless you want to reset the state of the board
     UNUSED(app);
     UNUSED(app);

+ 40 - 41
minesweeper/scenes/info_scene.c

@@ -1,44 +1,43 @@
 #include "../minesweeper.h"
 #include "../minesweeper.h"
-static const char* info_string= "GAME INFO BELOW\n\n"
-                                "1. Press OK to clear a tile.\n\n"
-                                "2. Hold OK on a numbered tile\n"
-                                "to clear all surrounding\n"
-                                "tiles if the correct amount\n"
-                                "of flags are set.\n\n"
-                                "3. Hold Back on a tile to\n"
-                                "mark it with a flag.\n\n"
-                                "4. Hold back on a cleared\n"
-                                "tile to jump to the\n"
-                                "closest tile.\n\n"
-                                "SETTINGS INFO\n\n"
-                                "Difficulty and map\n"
-                                "dimensions can be changed\n"
-                                "in the settings with a\n"
-                                "max map size of 1024\n"
-                                "tiles (32x32).\n\n"
-                                "ENSURE SOLVABLE\n"
-                                "This is a setting that\n"
-                                "enables a board verifier\n"
-                                "when generating a new\n"
-                                "board.\n\n"
-                                "-- WARNING --\n"
-                                "This setting will introduce\n"
-                                "a variable amount of\n"
-                                "overhead when generating\n"
-                                "a new map. It can take\n"
-                                "several seconds for a\n"
-                                "valid map to generate. The\n"
-                                "UI may hang and stop for a\n"
-                                "while but it should resolve\n"
-                                "in a few seconds.\n\n"
-                                "Enjoy the game and if you\n"
-                                "want to reach out about an\n"
-                                "issue go to the git hub repo\n"
-                                "for this app:\n\n"
-                                "'github.com/squee72564/\n"
-                                "F0_Minesweeper_Fap'\n\n"
-                                "Thanks and enjoy!";
-
+static const char* info_string = "GAME INFO BELOW\n\n"
+                                 "1. Press OK to clear a tile.\n\n"
+                                 "2. Hold OK on a numbered tile\n"
+                                 "to clear all surrounding\n"
+                                 "tiles if the correct amount\n"
+                                 "of flags are set.\n\n"
+                                 "3. Hold Back on a tile to\n"
+                                 "mark it with a flag.\n\n"
+                                 "4. Hold back on a cleared\n"
+                                 "tile to jump to the\n"
+                                 "closest tile.\n\n"
+                                 "SETTINGS INFO\n\n"
+                                 "Difficulty and map\n"
+                                 "dimensions can be changed\n"
+                                 "in the settings with a\n"
+                                 "max map size of 1024\n"
+                                 "tiles (32x32).\n\n"
+                                 "ENSURE SOLVABLE\n"
+                                 "This is a setting that\n"
+                                 "enables a board verifier\n"
+                                 "when generating a new\n"
+                                 "board.\n\n"
+                                 "-- WARNING --\n"
+                                 "This setting will introduce\n"
+                                 "a variable amount of\n"
+                                 "overhead when generating\n"
+                                 "a new map. It can take\n"
+                                 "several seconds for a\n"
+                                 "valid map to generate. The\n"
+                                 "UI may hang and stop for a\n"
+                                 "while but it should resolve\n"
+                                 "in a few seconds.\n\n"
+                                 "Enjoy the game and if you\n"
+                                 "want to reach out about an\n"
+                                 "issue go to the git hub repo\n"
+                                 "for this app:\n\n"
+                                 "'github.com/squee72564/\n"
+                                 "F0_Minesweeper_Fap'\n\n"
+                                 "Thanks and enjoy!";
 
 
 void minesweeper_scene_info_screen_on_enter(void* context) {
 void minesweeper_scene_info_screen_on_enter(void* context) {
     furi_assert(context);
     furi_assert(context);
@@ -60,7 +59,7 @@ bool minesweeper_scene_info_screen_on_event(void* context, SceneManagerEvent eve
     UNUSED(app);
     UNUSED(app);
 
 
     bool consumed = false;
     bool consumed = false;
-    
+
     return consumed;
     return consumed;
 }
 }
 
 

+ 32 - 47
minesweeper/scenes/menu_scene.c

@@ -1,27 +1,13 @@
 #include "../minesweeper.h"
 #include "../minesweeper.h"
 
 
 static const char* farewellPrompts[] = {
 static const char* farewellPrompts[] = {
-    "Leaving so\n   soon?",
-    "Will you\n   stay?",
-    "Don't swim\n   away.",
-    "Feeling\n   farewell?",
-    "Sad to part\n   ways.",
-    "Ocean of\n   goodbyes.",
-    "Dolphin tears,\n   why?",
-    "Lonely without\n   you.",
-    "End of our\n   wave?",
-    "Will you\n   return?",
-    "Drowning in\n   goodbye.",
-    "Farewell\n   ripples.",
-    "Flipper's\n   frown.",
-    "Sea of\n   solitude.",
-    "Parting\n   currents.",
-    "Goodbye, old\n   friend.",
-    "Will tide\n  bring back?",
-    "Echoes of\n  departure.",
-    "Dolphin's last\n   dance.",
-    "Ocean misses\n   you."
-};
+    "Leaving so\n   soon?",      "Will you\n   stay?",       "Don't swim\n   away.",
+    "Feeling\n   farewell?",     "Sad to part\n   ways.",    "Ocean of\n   goodbyes.",
+    "Dolphin tears,\n   why?",   "Lonely without\n   you.",  "End of our\n   wave?",
+    "Will you\n   return?",      "Drowning in\n   goodbye.", "Farewell\n   ripples.",
+    "Flipper's\n   frown.",      "Sea of\n   solitude.",     "Parting\n   currents.",
+    "Goodbye, old\n   friend.",  "Will tide\n  bring back?", "Echoes of\n  departure.",
+    "Dolphin's last\n   dance.", "Ocean misses\n   you."};
 
 
 static void minesweeper_menu_scene_dialog_callback(DialogExResult result, void* context) {
 static void minesweeper_menu_scene_dialog_callback(DialogExResult result, void* context) {
     furi_assert(context);
     furi_assert(context);
@@ -35,14 +21,15 @@ void minesweeper_scene_menu_screen_on_enter(void* context) {
     MineSweeperApp* app = (MineSweeperApp*)context;
     MineSweeperApp* app = (MineSweeperApp*)context;
 
 
     view_dispatcher_switch_to_view(app->view_dispatcher, MineSweeperLoadingView);
     view_dispatcher_switch_to_view(app->view_dispatcher, MineSweeperLoadingView);
-    
+
     dialog_ex_set_context(app->menu_screen, app);
     dialog_ex_set_context(app->menu_screen, app);
 
 
-    dialog_ex_set_header(app->menu_screen, "Exit Game?", (128*3)/4, 4, AlignCenter, AlignTop);
+    dialog_ex_set_header(app->menu_screen, "Exit Game?", (128 * 3) / 4, 4, AlignCenter, AlignTop);
 
 
     uint32_t prompt_index = furi_hal_random_get() % sizeof(farewellPrompts) / sizeof(char*);
     uint32_t prompt_index = furi_hal_random_get() % sizeof(farewellPrompts) / sizeof(char*);
 
 
-    dialog_ex_set_text(app->menu_screen, farewellPrompts[prompt_index], 65, 20, AlignLeft, AlignTop);
+    dialog_ex_set_text(
+        app->menu_screen, farewellPrompts[prompt_index], 65, 20, AlignLeft, AlignTop);
 
 
     dialog_ex_set_icon(app->menu_screen, 11, 0, &I_Cry_dolph_55x52);
     dialog_ex_set_icon(app->menu_screen, 11, 0, &I_Cry_dolph_55x52);
 
 
@@ -60,35 +47,33 @@ void minesweeper_scene_menu_screen_on_enter(void* context) {
 bool minesweeper_scene_menu_screen_on_event(void* context, SceneManagerEvent event) {
 bool minesweeper_scene_menu_screen_on_event(void* context, SceneManagerEvent event) {
     furi_assert(context);
     furi_assert(context);
 
 
-    MineSweeperApp* app = context; 
+    MineSweeperApp* app = context;
     bool consumed = false;
     bool consumed = false;
-    
-    if (event.type == SceneManagerEventTypeCustom) {
-        switch (event.event) {
-
-            case DialogExResultLeft :
-                if (!scene_manager_search_and_switch_to_previous_scene(
-                        app->scene_manager, MineSweeperSceneGameScreen)) {
-
-                    scene_manager_stop(app->scene_manager);
-                    view_dispatcher_stop(app->view_dispatcher);
-                }
 
 
-                consumed = true;
-                break;
-
-            case DialogExResultRight : 
+    if(event.type == SceneManagerEventTypeCustom) {
+        switch(event.event) {
+        case DialogExResultLeft:
+            if(!scene_manager_search_and_switch_to_previous_scene(
+                   app->scene_manager, MineSweeperSceneGameScreen)) {
                 scene_manager_stop(app->scene_manager);
                 scene_manager_stop(app->scene_manager);
                 view_dispatcher_stop(app->view_dispatcher);
                 view_dispatcher_stop(app->view_dispatcher);
-                consumed = true;
-                break;
+            }
+
+            consumed = true;
+            break;
+
+        case DialogExResultRight:
+            scene_manager_stop(app->scene_manager);
+            view_dispatcher_stop(app->view_dispatcher);
+            consumed = true;
+            break;
 
 
-            case DialogExResultCenter :
-                scene_manager_next_scene(app->scene_manager, MineSweeperSceneSettingsScreen);
-                break;
+        case DialogExResultCenter:
+            scene_manager_next_scene(app->scene_manager, MineSweeperSceneSettingsScreen);
+            break;
 
 
-            default :
-                break;
+        default:
+            break;
         }
         }
     }
     }
 
 

+ 1 - 1
minesweeper/scenes/minesweeper_scene.h

@@ -7,7 +7,7 @@
 #define ADD_SCENE(prefix, name, id) MineSweeperScene##id,
 #define ADD_SCENE(prefix, name, id) MineSweeperScene##id,
 typedef enum {
 typedef enum {
 #include "minesweeper_scene_config.h"
 #include "minesweeper_scene_config.h"
-        MineSweeperSceneNum
+    MineSweeperSceneNum
 } MineSweeperScene;
 } MineSweeperScene;
 #undef ADD_SCENE
 #undef ADD_SCENE
 
 

+ 84 - 119
minesweeper/scenes/settings_scene.c

@@ -41,18 +41,17 @@ static void minesweeper_scene_settings_screen_set_difficulty(VariableItem* item)
     app->t_settings_info.difficulty_item = item;
     app->t_settings_info.difficulty_item = item;
 
 
     uint8_t index = variable_item_get_current_value_index(app->t_settings_info.difficulty_item);
     uint8_t index = variable_item_get_current_value_index(app->t_settings_info.difficulty_item);
-    
+
     app->t_settings_info.difficulty = index;
     app->t_settings_info.difficulty = index;
 
 
     variable_item_set_current_value_text(
     variable_item_set_current_value_text(
-            app->t_settings_info.difficulty_item,
-            settings_screen_difficulty_text[index]);
+        app->t_settings_info.difficulty_item, settings_screen_difficulty_text[index]);
 
 
-    view_dispatcher_send_custom_event(app->view_dispatcher, MineSweeperSettingsScreenEventDifficultyChange);
+    view_dispatcher_send_custom_event(
+        app->view_dispatcher, MineSweeperSettingsScreenEventDifficultyChange);
 }
 }
 
 
 static void minesweeper_scene_settings_screen_set_width(VariableItem* item) {
 static void minesweeper_scene_settings_screen_set_width(VariableItem* item) {
-
     char source[5];
     char source[5];
     uint8_t index = 0;
     uint8_t index = 0;
     uint8_t curr_board_height = 7;
     uint8_t curr_board_height = 7;
@@ -64,16 +63,17 @@ static void minesweeper_scene_settings_screen_set_width(VariableItem* item) {
     app->t_settings_info.width_item = item;
     app->t_settings_info.width_item = item;
 
 
     index = variable_item_get_current_value_index(app->t_settings_info.width_item);
     index = variable_item_get_current_value_index(app->t_settings_info.width_item);
-    app->t_settings_info.board_width = index+16;
+    app->t_settings_info.board_width = index + 16;
 
 
     curr_board_height = app->t_settings_info.board_height;
     curr_board_height = app->t_settings_info.board_height;
 
 
-    is_over_max_tiles = (app->t_settings_info.board_width * curr_board_height) > MINESWEEPER_BOARD_MAX_TILES;
-    if (is_over_max_tiles) {
-
+    is_over_max_tiles = (app->t_settings_info.board_width * curr_board_height) >
+                        MINESWEEPER_BOARD_MAX_TILES;
+    if(is_over_max_tiles) {
         do {
         do {
-            is_over_max_tiles = (app->t_settings_info.board_width * --curr_board_height) > MINESWEEPER_BOARD_MAX_TILES;
-        } while (is_over_max_tiles);
+            is_over_max_tiles = (app->t_settings_info.board_width * --curr_board_height) >
+                                MINESWEEPER_BOARD_MAX_TILES;
+        } while(is_over_max_tiles);
 
 
         app->t_settings_info.board_height = curr_board_height;
         app->t_settings_info.board_height = curr_board_height;
 
 
@@ -83,24 +83,26 @@ static void minesweeper_scene_settings_screen_set_width(VariableItem* item) {
         furi_string_set_strn(app->t_settings_info.height_str, source, 5);
         furi_string_set_strn(app->t_settings_info.height_str, source, 5);
 
 
         variable_item_set_current_value_index(
         variable_item_set_current_value_index(
-                app->t_settings_info.height_item,
-                app->t_settings_info.board_height-7);
+            app->t_settings_info.height_item, app->t_settings_info.board_height - 7);
 
 
-        variable_item_set_current_value_text(app->t_settings_info.height_item, furi_string_get_cstr(app->t_settings_info.height_str));
+        variable_item_set_current_value_text(
+            app->t_settings_info.height_item,
+            furi_string_get_cstr(app->t_settings_info.height_str));
     }
     }
 
 
-    snprintf(source, 5, "%" PRIu8, index+16);
+    snprintf(source, 5, "%" PRIu8, index + 16);
     source[4] = '\0';
     source[4] = '\0';
-    
+
     furi_string_set_strn(app->t_settings_info.width_str, source, 5);
     furi_string_set_strn(app->t_settings_info.width_str, source, 5);
 
 
-    variable_item_set_current_value_text(app->t_settings_info.width_item, furi_string_get_cstr(app->t_settings_info.width_str));
+    variable_item_set_current_value_text(
+        app->t_settings_info.width_item, furi_string_get_cstr(app->t_settings_info.width_str));
 
 
-    view_dispatcher_send_custom_event(app->view_dispatcher, MineSweeperSettingsScreenEventHeightChange);
+    view_dispatcher_send_custom_event(
+        app->view_dispatcher, MineSweeperSettingsScreenEventHeightChange);
 }
 }
 
 
 static void minesweeper_scene_settings_screen_set_height(VariableItem* item) {
 static void minesweeper_scene_settings_screen_set_height(VariableItem* item) {
-
     char source[5];
     char source[5];
     uint8_t index = 0;
     uint8_t index = 0;
     uint8_t curr_board_width = 16;
     uint8_t curr_board_width = 16;
@@ -112,16 +114,17 @@ static void minesweeper_scene_settings_screen_set_height(VariableItem* item) {
     app->t_settings_info.height_item = item;
     app->t_settings_info.height_item = item;
 
 
     index = variable_item_get_current_value_index(app->t_settings_info.height_item);
     index = variable_item_get_current_value_index(app->t_settings_info.height_item);
-    app->t_settings_info.board_height = index+7;
+    app->t_settings_info.board_height = index + 7;
 
 
     curr_board_width = app->t_settings_info.board_width;
     curr_board_width = app->t_settings_info.board_width;
 
 
-    is_over_max_tiles = (app->t_settings_info.board_height * curr_board_width) > MINESWEEPER_BOARD_MAX_TILES;
-    if (is_over_max_tiles) {
-
+    is_over_max_tiles = (app->t_settings_info.board_height * curr_board_width) >
+                        MINESWEEPER_BOARD_MAX_TILES;
+    if(is_over_max_tiles) {
         do {
         do {
-            is_over_max_tiles = (app->t_settings_info.board_height * --curr_board_width) > MINESWEEPER_BOARD_MAX_TILES;
-        } while (is_over_max_tiles);
+            is_over_max_tiles = (app->t_settings_info.board_height * --curr_board_width) >
+                                MINESWEEPER_BOARD_MAX_TILES;
+        } while(is_over_max_tiles);
 
 
         app->t_settings_info.board_width = curr_board_width;
         app->t_settings_info.board_width = curr_board_width;
 
 
@@ -131,21 +134,22 @@ static void minesweeper_scene_settings_screen_set_height(VariableItem* item) {
         furi_string_set_strn(app->t_settings_info.width_str, source, 5);
         furi_string_set_strn(app->t_settings_info.width_str, source, 5);
 
 
         variable_item_set_current_value_index(
         variable_item_set_current_value_index(
-                app->t_settings_info.width_item,
-                app->t_settings_info.board_width-16);
+            app->t_settings_info.width_item, app->t_settings_info.board_width - 16);
 
 
-        variable_item_set_current_value_text(app->t_settings_info.width_item, furi_string_get_cstr(app->t_settings_info.width_str));
+        variable_item_set_current_value_text(
+            app->t_settings_info.width_item, furi_string_get_cstr(app->t_settings_info.width_str));
     }
     }
 
 
-    snprintf(source, 5, "%" PRIu8, index+7);
+    snprintf(source, 5, "%" PRIu8, index + 7);
     source[4] = '\0';
     source[4] = '\0';
 
 
     furi_string_set_strn(app->t_settings_info.height_str, source, 5);
     furi_string_set_strn(app->t_settings_info.height_str, source, 5);
 
 
-    variable_item_set_current_value_text(app->t_settings_info.height_item, furi_string_get_cstr(app->t_settings_info.height_str));
-
+    variable_item_set_current_value_text(
+        app->t_settings_info.height_item, furi_string_get_cstr(app->t_settings_info.height_str));
 
 
-    view_dispatcher_send_custom_event(app->view_dispatcher, MineSweeperSettingsScreenEventWidthChange);
+    view_dispatcher_send_custom_event(
+        app->view_dispatcher, MineSweeperSettingsScreenEventWidthChange);
 }
 }
 
 
 static void minesweeper_scene_settings_screen_set_solvable(VariableItem* item) {
 static void minesweeper_scene_settings_screen_set_solvable(VariableItem* item) {
@@ -159,8 +163,8 @@ static void minesweeper_scene_settings_screen_set_solvable(VariableItem* item) {
 
 
     variable_item_set_current_value_text(item, settings_screen_verifier_text[index]);
     variable_item_set_current_value_text(item, settings_screen_verifier_text[index]);
 
 
-    view_dispatcher_send_custom_event(app->view_dispatcher, MineSweeperSettingsScreenEventSolvableChange);
-    
+    view_dispatcher_send_custom_event(
+        app->view_dispatcher, MineSweeperSettingsScreenEventSolvableChange);
 }
 }
 
 
 static void minesweeper_scene_settings_screen_set_info(VariableItem* item) {
 static void minesweeper_scene_settings_screen_set_info(VariableItem* item) {
@@ -168,19 +172,19 @@ static void minesweeper_scene_settings_screen_set_info(VariableItem* item) {
 
 
     MineSweeperApp* app = variable_item_get_context(item);
     MineSweeperApp* app = variable_item_get_context(item);
 
 
-    view_dispatcher_send_custom_event(app->view_dispatcher, MineSweeperSettingsScreenEventInfoChange);
+    view_dispatcher_send_custom_event(
+        app->view_dispatcher, MineSweeperSettingsScreenEventInfoChange);
 }
 }
 
 
 void minesweeper_scene_settings_screen_on_enter(void* context) {
 void minesweeper_scene_settings_screen_on_enter(void* context) {
     furi_assert(context);
     furi_assert(context);
 
 
-
     MineSweeperApp* app = (MineSweeperApp*)context;
     MineSweeperApp* app = (MineSweeperApp*)context;
     VariableItemList* va = app->settings_screen;
     VariableItemList* va = app->settings_screen;
     VariableItem* item;
     VariableItem* item;
 
 
     // If we are accessing the scene and have not changed the settings
     // If we are accessing the scene and have not changed the settings
-    if (!app->is_settings_changed) {
+    if(!app->is_settings_changed) {
         // Set temp setting buffer to current state
         // Set temp setting buffer to current state
         app->t_settings_info = app->settings_info;
         app->t_settings_info = app->settings_info;
     }
     }
@@ -195,94 +199,61 @@ void minesweeper_scene_settings_screen_on_enter(void* context) {
 
 
     app->t_settings_info.difficulty_item = item;
     app->t_settings_info.difficulty_item = item;
 
 
-    variable_item_set_current_value_index(
-            item,
-            app->t_settings_info.difficulty);
+    variable_item_set_current_value_index(item, app->t_settings_info.difficulty);
 
 
     variable_item_set_current_value_text(
     variable_item_set_current_value_text(
-            item,
-            settings_screen_difficulty_text[app->t_settings_info.difficulty]);
+        item, settings_screen_difficulty_text[app->t_settings_info.difficulty]);
 
 
     // Set Width Item
     // Set Width Item
     item = variable_item_list_add(
     item = variable_item_list_add(
-           va,
-           "Board Width",
-           33-16,
-           minesweeper_scene_settings_screen_set_width,
-           app);
+        va, "Board Width", 33 - 16, minesweeper_scene_settings_screen_set_width, app);
 
 
     app->t_settings_info.width_item = item;
     app->t_settings_info.width_item = item;
 
 
-    variable_item_set_current_value_index(
-            item,
-            app->t_settings_info.board_width-16);
+    variable_item_set_current_value_index(item, app->t_settings_info.board_width - 16);
 
 
     char source[5];
     char source[5];
     snprintf(source, 5, "%" PRIu8, app->t_settings_info.board_width);
     snprintf(source, 5, "%" PRIu8, app->t_settings_info.board_width);
     source[4] = '\0';
     source[4] = '\0';
     furi_string_set_strn(app->t_settings_info.width_str, source, 5);
     furi_string_set_strn(app->t_settings_info.width_str, source, 5);
-    
+
     variable_item_set_current_value_text(
     variable_item_set_current_value_text(
-            item,
-            furi_string_get_cstr(app->t_settings_info.width_str));
+        item, furi_string_get_cstr(app->t_settings_info.width_str));
 
 
     // Set Height Item
     // Set Height Item
     item = variable_item_list_add(
     item = variable_item_list_add(
-           va,
-           "Board Height",
-           33-7,
-           minesweeper_scene_settings_screen_set_height,
-           app);
+        va, "Board Height", 33 - 7, minesweeper_scene_settings_screen_set_height, app);
 
 
     app->t_settings_info.height_item = item;
     app->t_settings_info.height_item = item;
 
 
-    variable_item_set_current_value_index(
-            item,
-            app->t_settings_info.board_height-7);
+    variable_item_set_current_value_index(item, app->t_settings_info.board_height - 7);
 
 
     snprintf(source, 5, "%" PRIu8, app->t_settings_info.board_height);
     snprintf(source, 5, "%" PRIu8, app->t_settings_info.board_height);
     source[4] = '\0';
     source[4] = '\0';
     furi_string_set_strn(app->t_settings_info.height_str, source, 5);
     furi_string_set_strn(app->t_settings_info.height_str, source, 5);
 
 
     variable_item_set_current_value_text(
     variable_item_set_current_value_text(
-            item,
-            furi_string_get_cstr(app->t_settings_info.height_str));
+        item, furi_string_get_cstr(app->t_settings_info.height_str));
 
 
     // Set solvable item
     // Set solvable item
     item = variable_item_list_add(
     item = variable_item_list_add(
-            va,
-            "Ensure Solvable",
-            2,
-            minesweeper_scene_settings_screen_set_solvable,
-            app);
+        va, "Ensure Solvable", 2, minesweeper_scene_settings_screen_set_solvable, app);
 
 
     app->t_settings_info.solvable_item = item;
     app->t_settings_info.solvable_item = item;
 
 
     uint8_t idx = (app->t_settings_info.ensure_solvable_board) ? 1 : 0;
     uint8_t idx = (app->t_settings_info.ensure_solvable_board) ? 1 : 0;
 
 
-    variable_item_set_current_value_index(
-            item,
-            idx);
+    variable_item_set_current_value_index(item, idx);
+
+    variable_item_set_current_value_text(item, settings_screen_verifier_text[idx]);
 
 
-    variable_item_set_current_value_text(
-            item,
-            settings_screen_verifier_text[idx]);
-    
     // Set info item
     // Set info item
     item = variable_item_list_add(
     item = variable_item_list_add(
-            va,
-            "Right For Info",
-            2,
-            minesweeper_scene_settings_screen_set_info,
-            app);
+        va, "Right For Info", 2, minesweeper_scene_settings_screen_set_info, app);
 
 
-    variable_item_set_current_value_index(
-            item,
-            0);
+    variable_item_set_current_value_index(item, 0);
 
 
-    variable_item_set_current_value_text(
-            item,
-            "-------");
+    variable_item_set_current_value_text(item, "-------");
 
 
     view_dispatcher_switch_to_view(app->view_dispatcher, MineSweeperSettingsView);
     view_dispatcher_switch_to_view(app->view_dispatcher, MineSweeperSettingsView);
 }
 }
@@ -290,62 +261,56 @@ void minesweeper_scene_settings_screen_on_enter(void* context) {
 bool minesweeper_scene_settings_screen_on_event(void* context, SceneManagerEvent event) {
 bool minesweeper_scene_settings_screen_on_event(void* context, SceneManagerEvent event) {
     furi_assert(context);
     furi_assert(context);
 
 
-    MineSweeperApp* app = context; 
+    MineSweeperApp* app = context;
     bool consumed = false;
     bool consumed = false;
-    
-    if (event.type == SceneManagerEventTypeCustom) {
 
 
-        app->is_settings_changed = (app->settings_info.board_width != app->t_settings_info.board_width  ||
-                                   app->settings_info.board_height != app->t_settings_info.board_height ||
-                                   app->settings_info.difficulty != app->t_settings_info.difficulty     ||
-                                   app->settings_info.ensure_solvable_board != app->t_settings_info.ensure_solvable_board);
+    if(event.type == SceneManagerEventTypeCustom) {
+        app->is_settings_changed =
+            (app->settings_info.board_width != app->t_settings_info.board_width ||
+             app->settings_info.board_height != app->t_settings_info.board_height ||
+             app->settings_info.difficulty != app->t_settings_info.difficulty ||
+             app->settings_info.ensure_solvable_board !=
+                 app->t_settings_info.ensure_solvable_board);
+
+        switch(event.event) {
+        case MineSweeperSettingsScreenEventDifficultyChange:
 
 
-        switch (event.event) {
+            break;
 
 
-            case MineSweeperSettingsScreenEventDifficultyChange :
+        case MineSweeperSettingsScreenEventWidthChange:
 
 
-                break;
-            
-            case MineSweeperSettingsScreenEventWidthChange : 
+            break;
 
 
-                break;
-            
-            case MineSweeperSettingsScreenEventHeightChange :
+        case MineSweeperSettingsScreenEventHeightChange:
 
 
-                break;
+            break;
 
 
-            case MineSweeperSettingsScreenEventSolvableChange :
+        case MineSweeperSettingsScreenEventSolvableChange:
 
 
-                break;
+            break;
 
 
-            case MineSweeperSettingsScreenEventInfoChange :
+        case MineSweeperSettingsScreenEventInfoChange:
 
 
-                scene_manager_next_scene(app->scene_manager, MineSweeperSceneInfoScreen);
-                break;
+            scene_manager_next_scene(app->scene_manager, MineSweeperSceneInfoScreen);
+            break;
 
 
-            default :
-                break;
+        default:
+            break;
         };
         };
         consumed = true;
         consumed = true;
 
 
-    } else if (event.type == SceneManagerEventTypeBack) {
-
+    } else if(event.type == SceneManagerEventTypeBack) {
         // If there are changes in the width, height, or difficulty go to confirmation scren
         // If there are changes in the width, height, or difficulty go to confirmation scren
-        if (app->is_settings_changed) { 
-
+        if(app->is_settings_changed) {
             scene_manager_next_scene(app->scene_manager, MineSweeperSceneConfirmationScreen);
             scene_manager_next_scene(app->scene_manager, MineSweeperSceneConfirmationScreen);
         } else {
         } else {
-
             memset(&app->t_settings_info, 0, sizeof(app->t_settings_info));
             memset(&app->t_settings_info, 0, sizeof(app->t_settings_info));
 
 
-            if (!scene_manager_search_and_switch_to_previous_scene(
-                        app->scene_manager, MineSweeperSceneMenuScreen)) {
-
+            if(!scene_manager_search_and_switch_to_previous_scene(
+                   app->scene_manager, MineSweeperSceneMenuScreen)) {
                 scene_manager_stop(app->scene_manager);
                 scene_manager_stop(app->scene_manager);
                 view_dispatcher_stop(app->view_dispatcher);
                 view_dispatcher_stop(app->view_dispatcher);
-
             }
             }
-
         }
         }
 
 
         consumed = true;
         consumed = true;

+ 11 - 15
minesweeper/scenes/start_screen_scene.c

@@ -13,14 +13,12 @@ bool minesweeper_scene_start_screen_input_callback(InputEvent* event, void* cont
     bool consumed = false;
     bool consumed = false;
 
 
     // Right now we continue if back is not pressed
     // Right now we continue if back is not pressed
-    if (event->key == InputKeyBack) {
+    if(event->key == InputKeyBack) {
         consumed = scene_manager_handle_custom_event(
         consumed = scene_manager_handle_custom_event(
-                        app->scene_manager,
-                        MineSweeperSceneStartScreenExitEvent); 
+            app->scene_manager, MineSweeperSceneStartScreenExitEvent);
     } else {
     } else {
         consumed = scene_manager_handle_custom_event(
         consumed = scene_manager_handle_custom_event(
-                        app->scene_manager,
-                        MineSweeperSceneStartScreenContinueEvent); 
+            app->scene_manager, MineSweeperSceneStartScreenContinueEvent);
     }
     }
 
 
     return consumed;
     return consumed;
@@ -36,19 +34,17 @@ void minesweeper_scene_start_screen_secondary_draw_callback(Canvas* canvas, void
 void minesweeper_scene_start_screen_on_enter(void* context) {
 void minesweeper_scene_start_screen_on_enter(void* context) {
     furi_assert(context);
     furi_assert(context);
     MineSweeperApp* app = context;
     MineSweeperApp* app = context;
-    
+
     furi_assert(app->start_screen);
     furi_assert(app->start_screen);
 
 
     start_screen_set_context(app->start_screen, app);
     start_screen_set_context(app->start_screen, app);
 
 
     start_screen_set_input_callback(
     start_screen_set_input_callback(
-            app->start_screen,
-            minesweeper_scene_start_screen_input_callback);
+        app->start_screen, minesweeper_scene_start_screen_input_callback);
 
 
     start_screen_set_secondary_draw_callback(
     start_screen_set_secondary_draw_callback(
-            app->start_screen,
-            minesweeper_scene_start_screen_secondary_draw_callback);
-    
+        app->start_screen, minesweeper_scene_start_screen_secondary_draw_callback);
+
     start_screen_set_icon_animation(app->start_screen, 0, 0, &A_StartScreen_128x64);
     start_screen_set_icon_animation(app->start_screen, 0, 0, &A_StartScreen_128x64);
 
 
     view_dispatcher_switch_to_view(app->view_dispatcher, MineSweeperStartScreenView);
     view_dispatcher_switch_to_view(app->view_dispatcher, MineSweeperStartScreenView);
@@ -60,12 +56,12 @@ bool minesweeper_scene_start_screen_on_event(void* context, SceneManagerEvent ev
     MineSweeperApp* app = context;
     MineSweeperApp* app = context;
     bool consumed = false;
     bool consumed = false;
 
 
-    if (event.type == SceneManagerEventTypeCustom) {
-        if (event.event == MineSweeperSceneStartScreenContinueEvent) {
+    if(event.type == SceneManagerEventTypeCustom) {
+        if(event.event == MineSweeperSceneStartScreenContinueEvent) {
             mine_sweeper_game_screen_reset_clock(app->game_screen);
             mine_sweeper_game_screen_reset_clock(app->game_screen);
-            scene_manager_next_scene(app->scene_manager, MineSweeperSceneGameScreen); 
+            scene_manager_next_scene(app->scene_manager, MineSweeperSceneGameScreen);
             consumed = true;
             consumed = true;
-        } else if (event.event == MineSweeperSceneStartScreenExitEvent) {
+        } else if(event.event == MineSweeperSceneStartScreenExitEvent) {
             // Exit app
             // Exit app
             scene_manager_stop(app->scene_manager);
             scene_manager_stop(app->scene_manager);
             view_dispatcher_stop(app->view_dispatcher);
             view_dispatcher_stop(app->view_dispatcher);

Разница между файлами не показана из-за своего большого размера
+ 278 - 350
minesweeper/views/minesweeper_game_screen.c


+ 19 - 15
minesweeper/views/minesweeper_game_screen.h

@@ -14,15 +14,15 @@
 #include "../helpers/mine_sweeper_speaker.h"
 #include "../helpers/mine_sweeper_speaker.h"
 
 
 // MAX TILES ALLOWED
 // MAX TILES ALLOWED
-#define MINESWEEPER_BOARD_MAX_TILES  (1<<10)
+#define MINESWEEPER_BOARD_MAX_TILES (1 << 10)
 
 
 // These defines represent how many tiles
 // These defines represent how many tiles
-// can be visually representen on the screen 
+// can be visually representen on the screen
 // due to icon sizes
 // due to icon sizes
 #define MINESWEEPER_SCREEN_TILE_HEIGHT 7
 #define MINESWEEPER_SCREEN_TILE_HEIGHT 7
 #define MINESWEEPER_SCREEN_TILE_WIDTH 16
 #define MINESWEEPER_SCREEN_TILE_WIDTH 16
 
 
-#define MS_DEBUG_TAG  "Mine Sweeper Module/View"
+#define MS_DEBUG_TAG "Mine Sweeper Module/View"
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
 extern "C" {
 extern "C" {
@@ -46,7 +46,11 @@ typedef bool (*GameScreenInputCallback)(InputEvent* event, void* context);
  *
  *
  * @return      MineSweeperGameScreen* instance 
  * @return      MineSweeperGameScreen* instance 
  */
  */
-MineSweeperGameScreen* mine_sweeper_game_screen_alloc(uint8_t width, uint8_t height, uint8_t difficulty, bool ensure_solvable);
+MineSweeperGameScreen* mine_sweeper_game_screen_alloc(
+    uint8_t width,
+    uint8_t height,
+    uint8_t difficulty,
+    bool ensure_solvable);
 
 
 /** Deinitialize and free Start Screen view
 /** Deinitialize and free Start Screen view
  *
  *
@@ -62,11 +66,11 @@ void mine_sweeper_game_screen_free(MineSweeperGameScreen* instance);
  * @param       difficulty  uint8_t difficulty for board
  * @param       difficulty  uint8_t difficulty for board
  */
  */
 void mine_sweeper_game_screen_reset(
 void mine_sweeper_game_screen_reset(
-        MineSweeperGameScreen* instance,
-        uint8_t width,
-        uint8_t height,
-        uint8_t difficulty,
-        bool ensure_solvable);
+    MineSweeperGameScreen* instance,
+    uint8_t width,
+    uint8_t height,
+    uint8_t difficulty,
+    bool ensure_solvable);
 
 
 /** Reset MineSweeperGameScreen clock 
 /** Reset MineSweeperGameScreen clock 
  *
  *
@@ -89,12 +93,12 @@ View* mine_sweeper_game_screen_get_view(MineSweeperGameScreen* instance);
  */
  */
 void mine_sweeper_game_screen_set_context(MineSweeperGameScreen* instance, void* context);
 void mine_sweeper_game_screen_set_context(MineSweeperGameScreen* instance, void* context);
 
 
-#define inverted_canvas_white_to_black(canvas, code)      \
-    {                                           \
-        canvas_set_color(canvas, ColorWhite);   \
-        {code};                                 \
-        canvas_set_color(canvas, ColorBlack);   \
-    }                           
+#define inverted_canvas_white_to_black(canvas, code) \
+    {                                                \
+        canvas_set_color(canvas, ColorWhite);        \
+        {code};                                      \
+        canvas_set_color(canvas, ColorBlack);        \
+    }
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
 }
 }

+ 19 - 23
minesweeper/views/minesweeper_game_screen_i.h

@@ -7,7 +7,7 @@
 #ifdef __cplusplus
 #ifdef __cplusplus
 extern "C" {
 extern "C" {
 #endif
 #endif
-		
+
 /** We can use this Point struct for the 2d position for the minesweeper game.
 /** We can use this Point struct for the 2d position for the minesweeper game.
   * We define the necessary functions needed for this user defined type
   * We define the necessary functions needed for this user defined type
   * so that we can make use of M*LIB's Red Black Tree and Double Ended
   * so that we can make use of M*LIB's Red Black Tree and Double Ended
@@ -15,16 +15,16 @@ extern "C" {
   */
   */
 
 
 typedef struct {
 typedef struct {
-    uint8_t x,y;
+    uint8_t x, y;
 } Point;
 } Point;
 
 
 typedef struct {
 typedef struct {
     bool allocated;
     bool allocated;
-	Point p;
+    Point p;
 } Point_t[1];
 } Point_t[1];
 
 
 static inline void pointobj_init(Point_t dest) {
 static inline void pointobj_init(Point_t dest) {
-    dest->p = (Point) {.x = 0, .y = 0};
+    dest->p = (Point){.x = 0, .y = 0};
     dest->allocated = true;
     dest->allocated = true;
 }
 }
 
 
@@ -39,9 +39,9 @@ static inline void pointobj_init_set(Point_t dest, const Point_t source) {
 }
 }
 
 
 static inline void pointobj_set(Point_t dest, const Point_t source) {
 static inline void pointobj_set(Point_t dest, const Point_t source) {
-    if (dest != source) {
+    if(dest != source) {
         pointobj_clear(dest);
         pointobj_clear(dest);
-        pointobj_init_set(dest, source); 
+        pointobj_init_set(dest, source);
     }
     }
 }
 }
 
 
@@ -55,27 +55,25 @@ static inline void pointobj_init_set_point(Point_t dest, Point val) {
 }
 }
 
 
 static inline bool pointobj_equal_p(const Point_t a, const Point_t b) {
 static inline bool pointobj_equal_p(const Point_t a, const Point_t b) {
-
     return (a->p.x == b->p.x && a->p.y == b->p.y) ? true : false;
     return (a->p.x == b->p.x && a->p.y == b->p.y) ? true : false;
 }
 }
 
 
 static inline int pointobj_cmp(const Point_t a, const Point_t b) {
 static inline int pointobj_cmp(const Point_t a, const Point_t b) {
-    if (a->p.x != b->p.x) return (a->p.x < b->p.x) ? -1 : 1;
-    if (a->p.y != b->p.y) return (a->p.y < b->p.y) ? -1 : 1; 
+    if(a->p.x != b->p.x) return (a->p.x < b->p.x) ? -1 : 1;
+    if(a->p.y != b->p.y) return (a->p.y < b->p.y) ? -1 : 1;
     return 0;
     return 0;
 }
 }
 
 
 // This is the oplist needed to define the rb tree and dequeue and uses the/
 // This is the oplist needed to define the rb tree and dequeue and uses the/
 // above functions.
 // above functions.
-#define POINT_OPLIST (                      \
-            TYPE(Point_t),                  \
-            INIT(pointobj_init),            \
-            INIT_SET(pointobj_init_set),    \
-            SET(pointobj_set),              \
-            CLEAR(pointobj_clear),          \
-            EQUAL(pointobj_equal_p),        \
-            CMP(pointobj_cmp)               \
-        )
+#define POINT_OPLIST              \
+    (TYPE(Point_t),               \
+     INIT(pointobj_init),         \
+     INIT_SET(pointobj_init_set), \
+     SET(pointobj_set),           \
+     CLEAR(pointobj_clear),       \
+     EQUAL(pointobj_equal_p),     \
+     CMP(pointobj_cmp))
 
 
 // Use this to get rid of -Wunused-parameter errors for this macro only
 // Use this to get rid of -Wunused-parameter errors for this macro only
 #pragma GCC diagnostic push
 #pragma GCC diagnostic push
@@ -87,7 +85,7 @@ RBTREE_DEF(point_set, Point_t, POINT_OPLIST)
 #pragma GCC diagnostic pop
 #pragma GCC diagnostic pop
 
 
 // Example Macro defining the DEQ for Point that will be used as a double ended queue
 // Example Macro defining the DEQ for Point that will be used as a double ended queue
-DEQUE_DEF (point_deq, Point_t, POINT_OPLIST)
+DEQUE_DEF(point_deq, Point_t, POINT_OPLIST)
 
 
 // Helper to convert the Point_t type to Point
 // Helper to convert the Point_t type to Point
 static inline Point pointobj_get_point(const Point_t z) {
 static inline Point pointobj_get_point(const Point_t z) {
@@ -96,24 +94,22 @@ static inline Point pointobj_get_point(const Point_t z) {
 
 
 // Printing deq to debug
 // Printing deq to debug
 static inline void print_deq_to_debug(point_deq_t* deq) {
 static inline void print_deq_to_debug(point_deq_t* deq) {
-
     point_deq_it_t it;
     point_deq_it_t it;
 
 
     for(point_deq_it(it, *deq); !point_deq_end_p(it); point_deq_next(it)) {
     for(point_deq_it(it, *deq); !point_deq_end_p(it); point_deq_next(it)) {
         Point ref = pointobj_get_point(*point_deq_ref(it));
         Point ref = pointobj_get_point(*point_deq_ref(it));
-		
+
         FURI_LOG_D("DEQ DEBUG:", "(%hd,%hd), ", ref.x, ref.y);
         FURI_LOG_D("DEQ DEBUG:", "(%hd,%hd), ", ref.x, ref.y);
     }
     }
 }
 }
 
 
 // Printing ordered set to debug
 // Printing ordered set to debug
 static inline void print_ordered_set_to_debug(point_set_t* tree) {
 static inline void print_ordered_set_to_debug(point_set_t* tree) {
-
     point_set_it_t it;
     point_set_it_t it;
 
 
     for(point_set_it(it, *tree); !point_set_end_p(it); point_set_next(it)) {
     for(point_set_it(it, *tree); !point_set_end_p(it); point_set_next(it)) {
         Point ref = pointobj_get_point(*point_set_ref(it));
         Point ref = pointobj_get_point(*point_set_ref(it));
-		
+
         FURI_LOG_D("SET DEBUG:", "(%hd,%hd), ", ref.x, ref.y);
         FURI_LOG_D("SET DEBUG:", "(%hd,%hd), ", ref.x, ref.y);
     }
     }
 }
 }

+ 16 - 23
minesweeper/views/start_screen.c

@@ -39,8 +39,7 @@ void start_screen_view_enter(void* context) {
         start_screen->view,
         start_screen->view,
         StartScreenModel * model,
         StartScreenModel * model,
         {
         {
-            if (model->icon.animation != NULL)
-                icon_animation_start(model->icon.animation);
+            if(model->icon.animation != NULL) icon_animation_start(model->icon.animation);
         },
         },
         true);
         true);
 }
 }
@@ -53,8 +52,7 @@ void start_screen_view_exit(void* context) {
         start_screen->view,
         start_screen->view,
         StartScreenModel * model,
         StartScreenModel * model,
         {
         {
-            if (model->icon.animation != NULL)
-                icon_animation_stop(model->icon.animation);
+            if(model->icon.animation != NULL) icon_animation_stop(model->icon.animation);
         },
         },
         true);
         true);
 }
 }
@@ -70,11 +68,11 @@ void start_screen_view_draw_callback(Canvas* canvas, void* _model) {
     canvas_draw_box(canvas, 0, 0, canvas_width(canvas), canvas_height(canvas));
     canvas_draw_box(canvas, 0, 0, canvas_width(canvas), canvas_height(canvas));
     canvas_set_color(canvas, ColorBlack);
     canvas_set_color(canvas, ColorBlack);
 
 
-    if (model->icon.animation != NULL) {
+    if(model->icon.animation != NULL) {
         canvas_draw_icon_animation(canvas, model->icon.x, model->icon.y, model->icon.animation);
         canvas_draw_icon_animation(canvas, model->icon.x, model->icon.y, model->icon.animation);
     }
     }
 
 
-    if (model->text1.text != NULL) {
+    if(model->text1.text != NULL) {
         canvas_set_font(canvas, model->text1.font);
         canvas_set_font(canvas, model->text1.font);
         elements_multiline_text_aligned(
         elements_multiline_text_aligned(
             canvas,
             canvas,
@@ -85,7 +83,7 @@ void start_screen_view_draw_callback(Canvas* canvas, void* _model) {
             model->text1.text);
             model->text1.text);
     }
     }
 
 
-    if (model->text2.text != NULL) {
+    if(model->text2.text != NULL) {
         canvas_set_font(canvas, model->text2.font);
         canvas_set_font(canvas, model->text2.font);
         elements_multiline_text_aligned(
         elements_multiline_text_aligned(
             canvas,
             canvas,
@@ -96,7 +94,7 @@ void start_screen_view_draw_callback(Canvas* canvas, void* _model) {
             model->text2.text);
             model->text2.text);
     }
     }
 
 
-    if (model->text3.text != NULL) {
+    if(model->text3.text != NULL) {
         canvas_set_font(canvas, model->text3.font);
         canvas_set_font(canvas, model->text3.font);
         elements_multiline_text_aligned(
         elements_multiline_text_aligned(
             canvas,
             canvas,
@@ -106,16 +104,15 @@ void start_screen_view_draw_callback(Canvas* canvas, void* _model) {
             model->text3.vertical,
             model->text3.vertical,
             model->text3.text);
             model->text3.text);
     }
     }
-
 }
 }
 
 
 bool start_screen_view_input_callback(InputEvent* event, void* context) {
 bool start_screen_view_input_callback(InputEvent* event, void* context) {
     StartScreen* start_screen = context;
     StartScreen* start_screen = context;
     bool consumed = false;
     bool consumed = false;
 
 
-    // If custom input callback is defined pass event to it 
-    if (start_screen->input_callback != NULL) {
-        consumed = start_screen->input_callback(event, start_screen->context); 
+    // If custom input callback is defined pass event to it
+    if(start_screen->input_callback != NULL) {
+        consumed = start_screen->input_callback(event, start_screen->context);
     } else {
     } else {
         // You can add default functionality here
         // You can add default functionality here
     }
     }
@@ -125,7 +122,7 @@ bool start_screen_view_input_callback(InputEvent* event, void* context) {
 
 
 StartScreen* start_screen_alloc() {
 StartScreen* start_screen_alloc() {
     StartScreen* start_screen = (StartScreen*)malloc(sizeof(StartScreen));
     StartScreen* start_screen = (StartScreen*)malloc(sizeof(StartScreen));
-    
+
     start_screen->view = view_alloc();
     start_screen->view = view_alloc();
 
 
     start_screen->input_callback = NULL;
     start_screen->input_callback = NULL;
@@ -166,11 +163,11 @@ StartScreen* start_screen_alloc() {
 
 
     view_set_draw_callback(start_screen->view, start_screen_view_draw_callback);
     view_set_draw_callback(start_screen->view, start_screen_view_draw_callback);
     view_set_input_callback(start_screen->view, start_screen_view_input_callback);
     view_set_input_callback(start_screen->view, start_screen_view_input_callback);
-    
+
     // Right now these enter/exit callbacks are being used to start/stop animations
     // Right now these enter/exit callbacks are being used to start/stop animations
     view_set_enter_callback(start_screen->view, start_screen_view_enter);
     view_set_enter_callback(start_screen->view, start_screen_view_enter);
     view_set_exit_callback(start_screen->view, start_screen_view_exit);
     view_set_exit_callback(start_screen->view, start_screen_view_exit);
-    
+
     return start_screen;
     return start_screen;
 }
 }
 
 
@@ -181,8 +178,7 @@ void start_screen_free(StartScreen* instance) {
         instance->view,
         instance->view,
         StartScreenModel * model,
         StartScreenModel * model,
         {
         {
-            if (model->icon.animation != NULL)
-                icon_animation_free(model->icon.animation);
+            if(model->icon.animation != NULL) icon_animation_free(model->icon.animation);
 
 
             model->icon.animation = NULL;
             model->icon.animation = NULL;
         },
         },
@@ -218,7 +214,9 @@ void start_screen_set_input_callback(StartScreen* instance, StartScreenInputCall
     instance->input_callback = callback;
     instance->input_callback = callback;
 }
 }
 
 
-void start_screen_set_secondary_draw_callback(StartScreen* instance, StartScreenDrawCallback callback) {
+void start_screen_set_secondary_draw_callback(
+    StartScreen* instance,
+    StartScreenDrawCallback callback) {
     furi_assert(instance);
     furi_assert(instance);
     instance->secondary_draw_callback = callback;
     instance->secondary_draw_callback = callback;
 }
 }
@@ -236,7 +234,6 @@ void start_screen_set_text1(
     Align vertical,
     Align vertical,
     Font font,
     Font font,
     const char* text) {
     const char* text) {
-
     furi_assert(instance);
     furi_assert(instance);
     with_view_model(
     with_view_model(
         instance->view,
         instance->view,
@@ -260,7 +257,6 @@ void start_screen_set_text2(
     Align vertical,
     Align vertical,
     Font font,
     Font font,
     const char* text) {
     const char* text) {
-
     furi_assert(instance);
     furi_assert(instance);
     with_view_model(
     with_view_model(
         instance->view,
         instance->view,
@@ -284,7 +280,6 @@ void start_screen_set_text3(
     Align vertical,
     Align vertical,
     Font font,
     Font font,
     const char* text) {
     const char* text) {
-
     furi_assert(instance);
     furi_assert(instance);
     with_view_model(
     with_view_model(
         instance->view,
         instance->view,
@@ -305,7 +300,6 @@ void start_screen_set_icon_animation(
     uint8_t x,
     uint8_t x,
     uint8_t y,
     uint8_t y,
     const Icon* animation) {
     const Icon* animation) {
-
     furi_assert(instance);
     furi_assert(instance);
     with_view_model(
     with_view_model(
         instance->view,
         instance->view,
@@ -318,4 +312,3 @@ void start_screen_set_icon_animation(
         },
         },
         true);
         true);
 }
 }
-

+ 30 - 29
minesweeper/views/start_screen.h

@@ -8,7 +8,6 @@
 
 
 #include <gui/view.h>
 #include <gui/view.h>
 
 
-
 #ifdef __cplusplus
 #ifdef __cplusplus
 extern "C" {
 extern "C" {
 #endif
 #endif
@@ -56,9 +55,7 @@ View* start_screen_get_view(StartScreen* instance);
  * @param       instance StartScreen instance
  * @param       instance StartScreen instance
  * @param       callback StartScreenInputCallback callback
  * @param       callback StartScreenInputCallback callback
  */
  */
-void start_screen_set_input_callback(
-        StartScreen* instance,
-        StartScreenInputCallback callback);
+void start_screen_set_input_callback(StartScreen* instance, StartScreenInputCallback callback);
 
 
 /** Set Additional draw callback 
 /** Set Additional draw callback 
  * 
  * 
@@ -70,8 +67,8 @@ void start_screen_set_input_callback(
  * @param callback StartScreenDrawCallback callback
  * @param callback StartScreenDrawCallback callback
  */
  */
 void start_screen_set_secondary_draw_callback(
 void start_screen_set_secondary_draw_callback(
-        StartScreen* instance,
-        StartScreenDrawCallback callback);
+    StartScreen* instance,
+    StartScreenDrawCallback callback);
 
 
 /** Set StartScreen context 
 /** Set StartScreen context 
  *
  *
@@ -94,13 +91,13 @@ void start_screen_set_context(StartScreen* instance, void* context);
  * @param[in]  text        The text
  * @param[in]  text        The text
  */
  */
 void start_screen_set_text1(
 void start_screen_set_text1(
-        StartScreen* instance,
-        uint8_t x,
-        uint8_t y,
-        Align horizontal,
-        Align vertical,
-        Font font,
-        const char* text);
+    StartScreen* instance,
+    uint8_t x,
+    uint8_t y,
+    Align horizontal,
+    Align vertical,
+    Font font,
+    const char* text);
 
 
 /** Set Text2 Element
 /** Set Text2 Element
  *
  *
@@ -113,14 +110,14 @@ void start_screen_set_text1(
  * @param[in]  text        The text
  * @param[in]  text        The text
  */
  */
 void start_screen_set_text2(
 void start_screen_set_text2(
-        StartScreen* instance,
-        uint8_t x,
-        uint8_t y,
-        Align horizontal,
-        Align vertical,
-        Font font,
-        const char* text);
-        
+    StartScreen* instance,
+    uint8_t x,
+    uint8_t y,
+    Align horizontal,
+    Align vertical,
+    Font font,
+    const char* text);
+
 /** Set Text3 Element
 /** Set Text3 Element
  *
  *
  * @param      instance StartScreen instance
  * @param      instance StartScreen instance
@@ -132,13 +129,13 @@ void start_screen_set_text2(
  * @param[in]  text        The text
  * @param[in]  text        The text
  */
  */
 void start_screen_set_text3(
 void start_screen_set_text3(
-        StartScreen* instance,
-        uint8_t x,
-        uint8_t y,
-        Align horizontal,
-        Align vertical,
-        Font font,
-        const char* text);
+    StartScreen* instance,
+    uint8_t x,
+    uint8_t y,
+    Align horizontal,
+    Align vertical,
+    Font font,
+    const char* text);
 
 
 /** Set Icon Animation Element
 /** Set Icon Animation Element
  *
  *
@@ -147,7 +144,11 @@ void start_screen_set_text3(
  * @param      y       top left y coordinate
  * @param      y       top left y coordinate
  * @param      animation    IconAnimation instance
  * @param      animation    IconAnimation instance
  */
  */
-void start_screen_set_icon_animation(StartScreen* instance, uint8_t x, uint8_t y, const Icon* animation);
+void start_screen_set_icon_animation(
+    StartScreen* instance,
+    uint8_t x,
+    uint8_t y,
+    const Icon* animation);
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
 }
 }

+ 49 - 50
nrf24mousejacker/mousejacker_ducky.c

@@ -25,56 +25,55 @@ static bool holding_gui = false;
 #define LOGITECH_HELLO_SIZE 10
 #define LOGITECH_HELLO_SIZE 10
 #define TAG "mousejacker_ducky"
 #define TAG "mousejacker_ducky"
 
 
-MJDuckyKey mj_ducky_keys[] = {{" ", 44, 0},         {"!", 30, 2},          {"\"", 52, 2},
-                              {"#", 32, 2},         {"$", 33, 2},          {"%", 34, 2},
-                              {"&", 36, 2},         {"'", 52, 0},          {"(", 38, 2},
-                              {")", 39, 2},         {"*", 37, 2},          {"+", 46, 2},
-                              {",", 54, 0},         {"-", 45, 0},          {".", 55, 0},
-                              {"/", 56, 0},         {"0", 39, 0},          {"1", 30, 0},
-                              {"2", 31, 0},         {"3", 32, 0},          {"4", 33, 0},
-                              {"5", 34, 0},         {"6", 35, 0},          {"7", 36, 0},
-                              {"8", 37, 0},         {"9", 38, 0},          {":", 51, 2},
-                              {";", 51, 0},         {"<", 54, 2},          {"=", 46, 0},
-                              {">", 55, 2},         {"?", 56, 2},          {"@", 31, 2},
-                              {"A", 4, 2},          {"B", 5, 2},           {"C", 6, 2},
-                              {"D", 7, 2},          {"E", 8, 2},           {"F", 9, 2},
-                              {"G", 10, 2},         {"H", 11, 2},          {"I", 12, 2},
-                              {"J", 13, 2},         {"K", 14, 2},          {"L", 15, 2},
-                              {"M", 16, 2},         {"N", 17, 2},          {"O", 18, 2},
-                              {"P", 19, 2},         {"Q", 20, 2},          {"R", 21, 2},
-                              {"S", 22, 2},         {"T", 23, 2},          {"U", 24, 2},
-                              {"V", 25, 2},         {"W", 26, 2},          {"X", 27, 2},
-                              {"Y", 28, 2},         {"Z", 29, 2},          {"[", 47, 0},
-                              {"\\", 49, 0},        {"]", 48, 0},          {"^", 35, 2},
-                              {"_", 45, 2},         {"`", 53, 0},          {"a", 4, 0},
-                              {"b", 5, 0},          {"c", 6, 0},           {"d", 7, 0},
-                              {"e", 8, 0},          {"f", 9, 0},           {"g", 10, 0},
-                              {"h", 11, 0},         {"i", 12, 0},          {"j", 13, 0},
-                              {"k", 14, 0},         {"l", 15, 0},          {"m", 16, 0},
-                              {"n", 17, 0},         {"o", 18, 0},          {"p", 19, 0},
-                              {"q", 20, 0},         {"r", 21, 0},          {"s", 22, 0},
-                              {"t", 23, 0},         {"u", 24, 0},          {"v", 25, 0},
-                              {"w", 26, 0},         {"x", 27, 0},          {"y", 28, 0},
-                              {"z", 29, 0},         {"{", 47, 2},          {"|", 49, 2},
-                              {"}", 48, 2},         {"~", 53, 2},          {"BACKSPACE", 42, 0},
-                              {"", 0, 0},           {"ALT", 0, 4},         {"SHIFT", 0, 2},
-                              {"CTRL", 0, 1},       {"GUI", 0, 8},         {"SCROLLLOCK", 71, 0},
-                              {"ENTER", 40, 0},     {"F12", 69, 0},        {"HOME", 74, 0},
-                              {"F10", 67, 0},       {"F9", 66, 0},         {"ESCAPE", 41, 0},
-                              {"PAGEUP", 75, 0},    {"TAB", 43, 0},        {"PRINTSCREEN", 70, 0},
-                              {"F2", 59, 0},        {"CAPSLOCK", 57, 0},   {"F1", 58, 0},
-                              {"F4", 61, 0},        {"F6", 63, 0},         {"F8", 65, 0},
-                              {"DOWNARROW", 81, 0}, {"DELETE", 42, 0},     {"RIGHT", 79, 0},
-                              {"F3", 60, 0},        {"DOWN", 81, 0},       {"DEL", 76, 0},
-                              {"END", 77, 0},       {"INSERT", 73, 0},
-                              {"NUMLOCK", 83, 0},     {"F5", 62, 0},
-                              {"LEFTARROW", 80, 0}, {"RIGHTARROW", 79, 0}, {"PAGEDOWN", 78, 0},
-                              {"PAUSE", 72, 0},     {"SPACE", 44, 0},      {"UPARROW", 82, 0},
-                              {"F11", 68, 0},       {"F7", 64, 0},         {"UP", 82, 0},
-                              {"LEFT", 80, 0},      {"NUM 1", 89, 0},      {"NUM 2", 90, 0},
-                              {"NUM 3", 91, 0},     {"NUM 4", 92, 0},      {"NUM 5", 93, 0},
-                              {"NUM 6", 94, 0},     {"NUM 7", 95, 0},      {"NUM 8", 96, 0},
-                              {"NUM 9", 97, 0},     {"NUM 0", 98, 0}};
+MJDuckyKey mj_ducky_keys[] = {{" ", 44, 0},         {"!", 30, 2},         {"\"", 52, 2},
+                              {"#", 32, 2},         {"$", 33, 2},         {"%", 34, 2},
+                              {"&", 36, 2},         {"'", 52, 0},         {"(", 38, 2},
+                              {")", 39, 2},         {"*", 37, 2},         {"+", 46, 2},
+                              {",", 54, 0},         {"-", 45, 0},         {".", 55, 0},
+                              {"/", 56, 0},         {"0", 39, 0},         {"1", 30, 0},
+                              {"2", 31, 0},         {"3", 32, 0},         {"4", 33, 0},
+                              {"5", 34, 0},         {"6", 35, 0},         {"7", 36, 0},
+                              {"8", 37, 0},         {"9", 38, 0},         {":", 51, 2},
+                              {";", 51, 0},         {"<", 54, 2},         {"=", 46, 0},
+                              {">", 55, 2},         {"?", 56, 2},         {"@", 31, 2},
+                              {"A", 4, 2},          {"B", 5, 2},          {"C", 6, 2},
+                              {"D", 7, 2},          {"E", 8, 2},          {"F", 9, 2},
+                              {"G", 10, 2},         {"H", 11, 2},         {"I", 12, 2},
+                              {"J", 13, 2},         {"K", 14, 2},         {"L", 15, 2},
+                              {"M", 16, 2},         {"N", 17, 2},         {"O", 18, 2},
+                              {"P", 19, 2},         {"Q", 20, 2},         {"R", 21, 2},
+                              {"S", 22, 2},         {"T", 23, 2},         {"U", 24, 2},
+                              {"V", 25, 2},         {"W", 26, 2},         {"X", 27, 2},
+                              {"Y", 28, 2},         {"Z", 29, 2},         {"[", 47, 0},
+                              {"\\", 49, 0},        {"]", 48, 0},         {"^", 35, 2},
+                              {"_", 45, 2},         {"`", 53, 0},         {"a", 4, 0},
+                              {"b", 5, 0},          {"c", 6, 0},          {"d", 7, 0},
+                              {"e", 8, 0},          {"f", 9, 0},          {"g", 10, 0},
+                              {"h", 11, 0},         {"i", 12, 0},         {"j", 13, 0},
+                              {"k", 14, 0},         {"l", 15, 0},         {"m", 16, 0},
+                              {"n", 17, 0},         {"o", 18, 0},         {"p", 19, 0},
+                              {"q", 20, 0},         {"r", 21, 0},         {"s", 22, 0},
+                              {"t", 23, 0},         {"u", 24, 0},         {"v", 25, 0},
+                              {"w", 26, 0},         {"x", 27, 0},         {"y", 28, 0},
+                              {"z", 29, 0},         {"{", 47, 2},         {"|", 49, 2},
+                              {"}", 48, 2},         {"~", 53, 2},         {"BACKSPACE", 42, 0},
+                              {"", 0, 0},           {"ALT", 0, 4},        {"SHIFT", 0, 2},
+                              {"CTRL", 0, 1},       {"GUI", 0, 8},        {"SCROLLLOCK", 71, 0},
+                              {"ENTER", 40, 0},     {"F12", 69, 0},       {"HOME", 74, 0},
+                              {"F10", 67, 0},       {"F9", 66, 0},        {"ESCAPE", 41, 0},
+                              {"PAGEUP", 75, 0},    {"TAB", 43, 0},       {"PRINTSCREEN", 70, 0},
+                              {"F2", 59, 0},        {"CAPSLOCK", 57, 0},  {"F1", 58, 0},
+                              {"F4", 61, 0},        {"F6", 63, 0},        {"F8", 65, 0},
+                              {"DOWNARROW", 81, 0}, {"DELETE", 42, 0},    {"RIGHT", 79, 0},
+                              {"F3", 60, 0},        {"DOWN", 81, 0},      {"DEL", 76, 0},
+                              {"END", 77, 0},       {"INSERT", 73, 0},    {"NUMLOCK", 83, 0},
+                              {"F5", 62, 0},        {"LEFTARROW", 80, 0}, {"RIGHTARROW", 79, 0},
+                              {"PAGEDOWN", 78, 0},  {"PAUSE", 72, 0},     {"SPACE", 44, 0},
+                              {"UPARROW", 82, 0},   {"F11", 68, 0},       {"F7", 64, 0},
+                              {"UP", 82, 0},        {"LEFT", 80, 0},      {"NUM 1", 89, 0},
+                              {"NUM 2", 90, 0},     {"NUM 3", 91, 0},     {"NUM 4", 92, 0},
+                              {"NUM 5", 93, 0},     {"NUM 6", 94, 0},     {"NUM 7", 95, 0},
+                              {"NUM 8", 96, 0},     {"NUM 9", 97, 0},     {"NUM 0", 98, 0}};
 
 
 /*
 /*
 static bool mj_ducky_get_number(const char* param, uint32_t* val) {
 static bool mj_ducky_get_number(const char* param, uint32_t* val) {

Некоторые файлы не были показаны из-за большого количества измененных файлов