|
@@ -10,16 +10,35 @@
|
|
|
#include "../../../services/convert/convert.h"
|
|
#include "../../../services/convert/convert.h"
|
|
|
#include "../../../lib/roll_value/roll_value.h"
|
|
#include "../../../lib/roll_value/roll_value.h"
|
|
|
#include "../../../types/nullable.h"
|
|
#include "../../../types/nullable.h"
|
|
|
|
|
+#include "../../../features_config.h"
|
|
|
|
|
+#ifdef TOTP_BADBT_TYPE_ENABLED
|
|
|
|
|
+#include "../../../workers/bt_type_code/bt_type_code.h"
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
char* YES_NO_LIST[] = {"NO", "YES"};
|
|
char* YES_NO_LIST[] = {"NO", "YES"};
|
|
|
|
|
+char* ON_OFF_LIST[] = {"OFF", "ON"};
|
|
|
|
|
|
|
|
-typedef enum { HoursInput, MinutesInput, Sound, Vibro, ConfirmButton } Control;
|
|
|
|
|
|
|
+typedef enum {
|
|
|
|
|
+ HoursInput,
|
|
|
|
|
+ MinutesInput,
|
|
|
|
|
+ Sound,
|
|
|
|
|
+ Vibro,
|
|
|
|
|
+ BadUsb,
|
|
|
|
|
+#ifdef TOTP_BADBT_TYPE_ENABLED
|
|
|
|
|
+ BadBt,
|
|
|
|
|
+#endif
|
|
|
|
|
+ ConfirmButton
|
|
|
|
|
+} Control;
|
|
|
|
|
|
|
|
typedef struct {
|
|
typedef struct {
|
|
|
int8_t tz_offset_hours;
|
|
int8_t tz_offset_hours;
|
|
|
uint8_t tz_offset_minutes;
|
|
uint8_t tz_offset_minutes;
|
|
|
bool notification_sound;
|
|
bool notification_sound;
|
|
|
bool notification_vibro;
|
|
bool notification_vibro;
|
|
|
|
|
+ bool badusb_enabled;
|
|
|
|
|
+#ifdef TOTP_BADBT_TYPE_ENABLED
|
|
|
|
|
+ bool badbt_enabled;
|
|
|
|
|
+#endif
|
|
|
uint8_t y_offset;
|
|
uint8_t y_offset;
|
|
|
TotpNullable_uint16_t current_token_index;
|
|
TotpNullable_uint16_t current_token_index;
|
|
|
Control selected_control;
|
|
Control selected_control;
|
|
@@ -47,6 +66,10 @@ void totp_scene_app_settings_activate(
|
|
|
scene_state->tz_offset_minutes = 60.0f * off_dec;
|
|
scene_state->tz_offset_minutes = 60.0f * off_dec;
|
|
|
scene_state->notification_sound = plugin_state->notification_method & NotificationMethodSound;
|
|
scene_state->notification_sound = plugin_state->notification_method & NotificationMethodSound;
|
|
|
scene_state->notification_vibro = plugin_state->notification_method & NotificationMethodVibro;
|
|
scene_state->notification_vibro = plugin_state->notification_method & NotificationMethodVibro;
|
|
|
|
|
+ scene_state->badusb_enabled = plugin_state->automation_method & AutomationMethodBadUsb;
|
|
|
|
|
+#ifdef TOTP_BADBT_TYPE_ENABLED
|
|
|
|
|
+ scene_state->badbt_enabled = plugin_state->automation_method & AutomationMethodBadBt;
|
|
|
|
|
+#endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void two_digit_to_str(int8_t num, char* str) {
|
|
static void two_digit_to_str(int8_t num, char* str) {
|
|
@@ -73,7 +96,7 @@ void totp_scene_app_settings_render(Canvas* const canvas, const PluginState* plu
|
|
|
|
|
|
|
|
char tmp_str[4];
|
|
char tmp_str[4];
|
|
|
two_digit_to_str(scene_state->tz_offset_hours, &tmp_str[0]);
|
|
two_digit_to_str(scene_state->tz_offset_hours, &tmp_str[0]);
|
|
|
- canvas_draw_str_aligned(canvas, 0, 16 - scene_state->y_offset, AlignLeft, AlignTop, "Hours:");
|
|
|
|
|
|
|
+ canvas_draw_str_aligned(canvas, 0, 17 - scene_state->y_offset, AlignLeft, AlignTop, "Hours:");
|
|
|
ui_control_select_render(
|
|
ui_control_select_render(
|
|
|
canvas,
|
|
canvas,
|
|
|
36,
|
|
36,
|
|
@@ -84,7 +107,7 @@ void totp_scene_app_settings_render(Canvas* const canvas, const PluginState* plu
|
|
|
|
|
|
|
|
two_digit_to_str(scene_state->tz_offset_minutes, &tmp_str[0]);
|
|
two_digit_to_str(scene_state->tz_offset_minutes, &tmp_str[0]);
|
|
|
canvas_draw_str_aligned(
|
|
canvas_draw_str_aligned(
|
|
|
- canvas, 0, 34 - scene_state->y_offset, AlignLeft, AlignTop, "Minutes:");
|
|
|
|
|
|
|
+ canvas, 0, 35 - scene_state->y_offset, AlignLeft, AlignTop, "Minutes:");
|
|
|
ui_control_select_render(
|
|
ui_control_select_render(
|
|
|
canvas,
|
|
canvas,
|
|
|
36,
|
|
36,
|
|
@@ -104,7 +127,7 @@ void totp_scene_app_settings_render(Canvas* const canvas, const PluginState* plu
|
|
|
canvas, 0, 64 - scene_state->y_offset, AlignLeft, AlignTop, "Notifications");
|
|
canvas, 0, 64 - scene_state->y_offset, AlignLeft, AlignTop, "Notifications");
|
|
|
canvas_set_font(canvas, FontSecondary);
|
|
canvas_set_font(canvas, FontSecondary);
|
|
|
|
|
|
|
|
- canvas_draw_str_aligned(canvas, 0, 80 - scene_state->y_offset, AlignLeft, AlignTop, "Sound:");
|
|
|
|
|
|
|
+ canvas_draw_str_aligned(canvas, 0, 81 - scene_state->y_offset, AlignLeft, AlignTop, "Sound:");
|
|
|
ui_control_select_render(
|
|
ui_control_select_render(
|
|
|
canvas,
|
|
canvas,
|
|
|
36,
|
|
36,
|
|
@@ -113,7 +136,7 @@ void totp_scene_app_settings_render(Canvas* const canvas, const PluginState* plu
|
|
|
YES_NO_LIST[scene_state->notification_sound],
|
|
YES_NO_LIST[scene_state->notification_sound],
|
|
|
scene_state->selected_control == Sound);
|
|
scene_state->selected_control == Sound);
|
|
|
|
|
|
|
|
- canvas_draw_str_aligned(canvas, 0, 98 - scene_state->y_offset, AlignLeft, AlignTop, "Vibro:");
|
|
|
|
|
|
|
+ canvas_draw_str_aligned(canvas, 0, 99 - scene_state->y_offset, AlignLeft, AlignTop, "Vibro:");
|
|
|
ui_control_select_render(
|
|
ui_control_select_render(
|
|
|
canvas,
|
|
canvas,
|
|
|
36,
|
|
36,
|
|
@@ -122,10 +145,43 @@ void totp_scene_app_settings_render(Canvas* const canvas, const PluginState* plu
|
|
|
YES_NO_LIST[scene_state->notification_vibro],
|
|
YES_NO_LIST[scene_state->notification_vibro],
|
|
|
scene_state->selected_control == Vibro);
|
|
scene_state->selected_control == Vibro);
|
|
|
|
|
|
|
|
|
|
+ canvas_draw_icon(
|
|
|
|
|
+ canvas, SCREEN_WIDTH_CENTER - 5, 123 - scene_state->y_offset, &I_totp_arrow_bottom_10x5);
|
|
|
|
|
+
|
|
|
|
|
+ canvas_set_font(canvas, FontPrimary);
|
|
|
|
|
+ canvas_draw_str_aligned(
|
|
|
|
|
+ canvas, 0, 128 - scene_state->y_offset, AlignLeft, AlignTop, "Automation");
|
|
|
|
|
+ canvas_set_font(canvas, FontSecondary);
|
|
|
|
|
+
|
|
|
|
|
+ canvas_draw_str_aligned(
|
|
|
|
|
+ canvas, 0, 145 - scene_state->y_offset, AlignLeft, AlignTop, "BadUSB:");
|
|
|
|
|
+ ui_control_select_render(
|
|
|
|
|
+ canvas,
|
|
|
|
|
+ 36,
|
|
|
|
|
+ 138 - scene_state->y_offset,
|
|
|
|
|
+ SCREEN_WIDTH - 36,
|
|
|
|
|
+ ON_OFF_LIST[scene_state->badusb_enabled],
|
|
|
|
|
+ scene_state->selected_control == BadUsb);
|
|
|
|
|
+
|
|
|
|
|
+#ifdef TOTP_BADBT_TYPE_ENABLED
|
|
|
|
|
+ canvas_draw_str_aligned(canvas, 0, 163 - scene_state->y_offset, AlignLeft, AlignTop, "BadBT:");
|
|
|
|
|
+ ui_control_select_render(
|
|
|
|
|
+ canvas,
|
|
|
|
|
+ 36,
|
|
|
|
|
+ 156 - scene_state->y_offset,
|
|
|
|
|
+ SCREEN_WIDTH - 36,
|
|
|
|
|
+ ON_OFF_LIST[scene_state->badbt_enabled],
|
|
|
|
|
+ scene_state->selected_control == BadBt);
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
ui_control_button_render(
|
|
ui_control_button_render(
|
|
|
canvas,
|
|
canvas,
|
|
|
SCREEN_WIDTH_CENTER - 24,
|
|
SCREEN_WIDTH_CENTER - 24,
|
|
|
- 115 - scene_state->y_offset,
|
|
|
|
|
|
|
+#ifdef TOTP_BADBT_TYPE_ENABLED
|
|
|
|
|
+ 178 - scene_state->y_offset,
|
|
|
|
|
+#else
|
|
|
|
|
+ 165 - scene_state->y_offset,
|
|
|
|
|
+#endif
|
|
|
48,
|
|
48,
|
|
|
13,
|
|
13,
|
|
|
"Confirm",
|
|
"Confirm",
|
|
@@ -152,7 +208,9 @@ bool totp_scene_app_settings_handle_event(
|
|
|
HoursInput,
|
|
HoursInput,
|
|
|
ConfirmButton,
|
|
ConfirmButton,
|
|
|
RollOverflowBehaviorStop);
|
|
RollOverflowBehaviorStop);
|
|
|
- if(scene_state->selected_control > MinutesInput) {
|
|
|
|
|
|
|
+ if(scene_state->selected_control > Vibro) {
|
|
|
|
|
+ scene_state->y_offset = 128;
|
|
|
|
|
+ } else if(scene_state->selected_control > MinutesInput) {
|
|
|
scene_state->y_offset = 64;
|
|
scene_state->y_offset = 64;
|
|
|
} else {
|
|
} else {
|
|
|
scene_state->y_offset = 0;
|
|
scene_state->y_offset = 0;
|
|
@@ -161,7 +219,9 @@ bool totp_scene_app_settings_handle_event(
|
|
|
case InputKeyDown:
|
|
case InputKeyDown:
|
|
|
totp_roll_value_uint8_t(
|
|
totp_roll_value_uint8_t(
|
|
|
&scene_state->selected_control, 1, HoursInput, ConfirmButton, RollOverflowBehaviorStop);
|
|
&scene_state->selected_control, 1, HoursInput, ConfirmButton, RollOverflowBehaviorStop);
|
|
|
- if(scene_state->selected_control > MinutesInput) {
|
|
|
|
|
|
|
+ if(scene_state->selected_control > Vibro) {
|
|
|
|
|
+ scene_state->y_offset = 128;
|
|
|
|
|
+ } else if(scene_state->selected_control > MinutesInput) {
|
|
|
scene_state->y_offset = 64;
|
|
scene_state->y_offset = 64;
|
|
|
} else {
|
|
} else {
|
|
|
scene_state->y_offset = 0;
|
|
scene_state->y_offset = 0;
|
|
@@ -178,7 +238,14 @@ bool totp_scene_app_settings_handle_event(
|
|
|
scene_state->notification_sound = !scene_state->notification_sound;
|
|
scene_state->notification_sound = !scene_state->notification_sound;
|
|
|
} else if(scene_state->selected_control == Vibro) {
|
|
} else if(scene_state->selected_control == Vibro) {
|
|
|
scene_state->notification_vibro = !scene_state->notification_vibro;
|
|
scene_state->notification_vibro = !scene_state->notification_vibro;
|
|
|
|
|
+ } else if(scene_state->selected_control == BadUsb) {
|
|
|
|
|
+ scene_state->badusb_enabled = !scene_state->badusb_enabled;
|
|
|
}
|
|
}
|
|
|
|
|
+#ifdef TOTP_BADBT_TYPE_ENABLED
|
|
|
|
|
+ else if(scene_state->selected_control == BadBt) {
|
|
|
|
|
+ scene_state->badbt_enabled = !scene_state->badbt_enabled;
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
break;
|
|
break;
|
|
|
case InputKeyLeft:
|
|
case InputKeyLeft:
|
|
|
if(scene_state->selected_control == HoursInput) {
|
|
if(scene_state->selected_control == HoursInput) {
|
|
@@ -191,7 +258,14 @@ bool totp_scene_app_settings_handle_event(
|
|
|
scene_state->notification_sound = !scene_state->notification_sound;
|
|
scene_state->notification_sound = !scene_state->notification_sound;
|
|
|
} else if(scene_state->selected_control == Vibro) {
|
|
} else if(scene_state->selected_control == Vibro) {
|
|
|
scene_state->notification_vibro = !scene_state->notification_vibro;
|
|
scene_state->notification_vibro = !scene_state->notification_vibro;
|
|
|
|
|
+ } else if(scene_state->selected_control == BadUsb) {
|
|
|
|
|
+ scene_state->badusb_enabled = !scene_state->badusb_enabled;
|
|
|
|
|
+ }
|
|
|
|
|
+#ifdef TOTP_BADBT_TYPE_ENABLED
|
|
|
|
|
+ else if(scene_state->selected_control == BadBt) {
|
|
|
|
|
+ scene_state->badbt_enabled = !scene_state->badbt_enabled;
|
|
|
}
|
|
}
|
|
|
|
|
+#endif
|
|
|
break;
|
|
break;
|
|
|
case InputKeyOk:
|
|
case InputKeyOk:
|
|
|
if(scene_state->selected_control == ConfirmButton) {
|
|
if(scene_state->selected_control == ConfirmButton) {
|
|
@@ -204,12 +278,26 @@ bool totp_scene_app_settings_handle_event(
|
|
|
(scene_state->notification_vibro ? NotificationMethodVibro :
|
|
(scene_state->notification_vibro ? NotificationMethodVibro :
|
|
|
NotificationMethodNone);
|
|
NotificationMethodNone);
|
|
|
|
|
|
|
|
|
|
+ plugin_state->automation_method =
|
|
|
|
|
+ scene_state->badusb_enabled ? AutomationMethodBadUsb : AutomationMethodNone;
|
|
|
|
|
+#ifdef TOTP_BADBT_TYPE_ENABLED
|
|
|
|
|
+ plugin_state->automation_method |= scene_state->badbt_enabled ? AutomationMethodBadBt :
|
|
|
|
|
+ AutomationMethodNone;
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
if(totp_config_file_update_user_settings(plugin_state) !=
|
|
if(totp_config_file_update_user_settings(plugin_state) !=
|
|
|
TotpConfigFileUpdateSuccess) {
|
|
TotpConfigFileUpdateSuccess) {
|
|
|
totp_dialogs_config_updating_error(plugin_state);
|
|
totp_dialogs_config_updating_error(plugin_state);
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+#ifdef TOTP_BADBT_TYPE_ENABLED
|
|
|
|
|
+ if(!scene_state->badbt_enabled && plugin_state->bt_type_code_worker_context != NULL) {
|
|
|
|
|
+ totp_bt_type_code_worker_free(plugin_state->bt_type_code_worker_context);
|
|
|
|
|
+ plugin_state->bt_type_code_worker_context = NULL;
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
if(!scene_state->current_token_index.is_null) {
|
|
if(!scene_state->current_token_index.is_null) {
|
|
|
TokenMenuSceneContext generate_scene_context = {
|
|
TokenMenuSceneContext generate_scene_context = {
|
|
|
.current_token_index = scene_state->current_token_index.value};
|
|
.current_token_index = scene_state->current_token_index.value};
|