|
12 | 12 | #include "../../../services/convert/convert.h" |
13 | 13 | #include <roll_value.h> |
14 | 14 | #include "../../../features_config.h" |
15 | | -#ifdef TOTP_BADBT_TYPE_ENABLED |
| 15 | +#ifdef TOTP_BADBT_AUTOMATION_ENABLED |
16 | 16 | #include "../../../workers/bt_type_code/bt_type_code.h" |
17 | 17 | #endif |
18 | 18 |
|
| 19 | +#ifdef TOTP_BADBT_AUTOMATION_ENABLED |
| 20 | +#define AUTOMATION_LIST_MAX_INDEX (3) |
| 21 | +#else |
| 22 | +#define AUTOMATION_LIST_MAX_INDEX (1) |
| 23 | +#endif |
| 24 | +#define BAD_KB_LAYOUT_LIST_MAX_INDEX (1) |
| 25 | +#define FONT_TEST_STR_LENGTH (7) |
| 26 | + |
19 | 27 | static const char* YES_NO_LIST[] = {"NO", "YES"}; |
20 | 28 | static const char* AUTOMATION_LIST[] = { |
21 | 29 | "None", |
22 | 30 | "USB" |
23 | | -#ifdef TOTP_BADBT_TYPE_ENABLED |
| 31 | +#ifdef TOTP_BADBT_AUTOMATION_ENABLED |
24 | 32 | , |
25 | 33 | "Bluetooth", |
26 | 34 | "BT and USB" |
27 | 35 | #endif |
28 | 36 | }; |
29 | | - |
30 | | -#ifdef TOTP_BADBT_TYPE_ENABLED |
31 | | -#define AUTOMATION_LIST_MAX_INDEX (3) |
32 | | -#else |
33 | | -#define AUTOMATION_LIST_MAX_INDEX (1) |
34 | | -#endif |
35 | | - |
36 | 37 | static const char* BAD_KB_LAYOUT_LIST[] = {"QWERTY", "AZERTY"}; |
37 | 38 | static const char* FONT_TEST_STR = "0123BCD"; |
38 | | -static const uint8_t FONT_TEST_STR_LENGTH = 7; |
39 | 39 |
|
40 | 40 | typedef enum { |
41 | 41 | HoursInput, |
@@ -71,8 +71,10 @@ void totp_scene_app_settings_activate(PluginState* plugin_state) { |
71 | 71 | scene_state->tz_offset_minutes = 60.0f * off_dec; |
72 | 72 | scene_state->notification_sound = plugin_state->notification_method & NotificationMethodSound; |
73 | 73 | scene_state->notification_vibro = plugin_state->notification_method & NotificationMethodVibro; |
74 | | - scene_state->automation_method = plugin_state->automation_method; |
75 | | - scene_state->automation_kb_layout = plugin_state->automation_kb_layout; |
| 74 | + scene_state->automation_method = |
| 75 | + MIN(plugin_state->automation_method, AUTOMATION_LIST_MAX_INDEX); |
| 76 | + scene_state->automation_kb_layout = |
| 77 | + MIN(plugin_state->automation_kb_layout, BAD_KB_LAYOUT_LIST_MAX_INDEX); |
76 | 78 |
|
77 | 79 | scene_state->active_font = plugin_state->active_font_index; |
78 | 80 | } |
@@ -281,7 +283,11 @@ bool totp_scene_app_settings_handle_event( |
281 | 283 | RollOverflowBehaviorRoll); |
282 | 284 | } else if(scene_state->selected_control == BadKeyboardLayoutSelect) { |
283 | 285 | totp_roll_value_uint8_t( |
284 | | - &scene_state->automation_kb_layout, 1, 0, 1, RollOverflowBehaviorRoll); |
| 286 | + &scene_state->automation_kb_layout, |
| 287 | + 1, |
| 288 | + 0, |
| 289 | + BAD_KB_LAYOUT_LIST_MAX_INDEX, |
| 290 | + RollOverflowBehaviorRoll); |
285 | 291 | } |
286 | 292 | break; |
287 | 293 | case InputKeyLeft: |
@@ -311,7 +317,11 @@ bool totp_scene_app_settings_handle_event( |
311 | 317 | RollOverflowBehaviorRoll); |
312 | 318 | } else if(scene_state->selected_control == BadKeyboardLayoutSelect) { |
313 | 319 | totp_roll_value_uint8_t( |
314 | | - &scene_state->automation_kb_layout, -1, 0, 1, RollOverflowBehaviorRoll); |
| 320 | + &scene_state->automation_kb_layout, |
| 321 | + -1, |
| 322 | + 0, |
| 323 | + BAD_KB_LAYOUT_LIST_MAX_INDEX, |
| 324 | + RollOverflowBehaviorRoll); |
315 | 325 | } |
316 | 326 | break; |
317 | 327 | case InputKeyOk: |
@@ -342,7 +352,7 @@ bool totp_scene_app_settings_handle_event( |
342 | 352 | return false; |
343 | 353 | } |
344 | 354 |
|
345 | | -#ifdef TOTP_BADBT_TYPE_ENABLED |
| 355 | +#ifdef TOTP_BADBT_AUTOMATION_ENABLED |
346 | 356 | if((scene_state->automation_method & AutomationMethodBadBt) == 0 && |
347 | 357 | plugin_state->bt_type_code_worker_context != NULL) { |
348 | 358 | totp_bt_type_code_worker_free(plugin_state->bt_type_code_worker_context); |
|
0 commit comments