From 73e8c632d7facb7ac79ef53410c627bfec399a7e Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 7 Apr 2024 20:43:12 +0100 Subject: [PATCH] MNTM: Add flipper Shell Color spoofing support --- .../scenes/momentum_app_scene_misc_spoof.c | 25 +++++++++++++++++++ lib/momentum/momentum.h | 2 ++ lib/momentum/settings.c | 2 ++ targets/f7/furi_hal/furi_hal_version.c | 7 +++++- targets/furi_hal_include/furi_hal_version.h | 1 + 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/applications/main/momentum_app/scenes/momentum_app_scene_misc_spoof.c b/applications/main/momentum_app/scenes/momentum_app_scene_misc_spoof.c index 7f7823376c..a9aea7efb7 100644 --- a/applications/main/momentum_app/scenes/momentum_app_scene_misc_spoof.c +++ b/applications/main/momentum_app/scenes/momentum_app_scene_misc_spoof.c @@ -2,8 +2,24 @@ enum VarItemListIndex { VarItemListIndexFlipperName, // TODO: Split into name, mac, serial + VarItemListIndexShellColor, }; +const char* const shell_color_names[FuriHalVersionColorCount] = { + "Real", + "Black", + "White", + "Transparent", +}; +static void momentum_app_scene_misc_spoof_shell_color_changed(VariableItem* item) { + MomentumApp* app = variable_item_get_context(item); + uint8_t index = variable_item_get_current_value_index(item); + variable_item_set_current_value_text(item, shell_color_names[index]); + momentum_settings.spoof_color = index; + app->save_settings = true; + app->require_reboot = true; +} + void momentum_app_scene_misc_spoof_var_item_list_callback(void* context, uint32_t index) { MomentumApp* app = context; view_dispatcher_send_custom_event(app->view_dispatcher, index); @@ -17,6 +33,15 @@ void momentum_app_scene_misc_spoof_on_enter(void* context) { item = variable_item_list_add(var_item_list, "Flipper Name", 0, NULL, app); variable_item_set_current_value_text(item, app->device_name); + item = variable_item_list_add( + var_item_list, + "Shell Color", + FuriHalVersionColorCount, + momentum_app_scene_misc_spoof_shell_color_changed, + app); + variable_item_set_current_value_index(item, momentum_settings.spoof_color); + variable_item_set_current_value_text(item, shell_color_names[momentum_settings.spoof_color]); + variable_item_list_set_enter_callback( var_item_list, momentum_app_scene_misc_spoof_var_item_list_callback, app); diff --git a/lib/momentum/momentum.h b/lib/momentum/momentum.h index b5eeec02f2..ea2c86cc46 100644 --- a/lib/momentum/momentum.h +++ b/lib/momentum/momentum.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -89,6 +90,7 @@ typedef struct { VgmColorMode vgm_color_mode; Rgb565Color vgm_color_fg; Rgb565Color vgm_color_bg; + FuriHalVersionColor spoof_color; } MomentumSettings; typedef struct { diff --git a/lib/momentum/settings.c b/lib/momentum/settings.c index 367fd51c90..0294a796f2 100644 --- a/lib/momentum/settings.c +++ b/lib/momentum/settings.c @@ -42,6 +42,7 @@ MomentumSettings momentum_settings = { .vgm_color_mode = VgmColorModeDefault, // Default .vgm_color_fg.value = 0x0000, // Default Black .vgm_color_bg.value = 0xFC00, // Default Orange + .spoof_color = FuriHalVersionColorUnknown, // Real }; typedef enum { @@ -112,6 +113,7 @@ static const struct { {setting_enum(vgm_color_mode, VgmColorModeCount)}, {setting_uint(vgm_color_fg, 0x0000, 0xFFFF)}, {setting_uint(vgm_color_bg, 0x0000, 0xFFFF)}, + {setting_enum(spoof_color, FuriHalVersionColorCount)}, }; void momentum_settings_load(void) { diff --git a/targets/f7/furi_hal/furi_hal_version.c b/targets/f7/furi_hal/furi_hal_version.c index 8c650bf0cf..04479a7b85 100644 --- a/targets/f7/furi_hal/furi_hal_version.c +++ b/targets/f7/furi_hal/furi_hal_version.c @@ -8,6 +8,8 @@ #include #include +#include + #define TAG "FuriHalVersion" #define FURI_HAL_VERSION_OTP_HEADER_MAGIC 0xBABE @@ -241,7 +243,10 @@ uint8_t furi_hal_version_get_hw_body(void) { } FuriHalVersionColor furi_hal_version_get_hw_color(void) { - return furi_hal_version.board_color; + if(momentum_settings.spoof_color == FuriHalVersionColorUnknown) { + return furi_hal_version.board_color; + } + return momentum_settings.spoof_color; } uint8_t furi_hal_version_get_hw_connect(void) { diff --git a/targets/furi_hal_include/furi_hal_version.h b/targets/furi_hal_include/furi_hal_version.h index 0cdea50733..bbcb77c0d5 100644 --- a/targets/furi_hal_include/furi_hal_version.h +++ b/targets/furi_hal_include/furi_hal_version.h @@ -35,6 +35,7 @@ typedef enum { FuriHalVersionColorBlack = 0x01, FuriHalVersionColorWhite = 0x02, FuriHalVersionColorTransparent = 0x03, + FuriHalVersionColorCount, } FuriHalVersionColor; /** Device Regions */