|
|
@@ -60,17 +60,17 @@ void totp_scene_app_settings_activate(PluginState* plugin_state) {
|
|
|
}
|
|
|
|
|
|
static void two_digit_to_str(int8_t num, char* str) {
|
|
|
- uint8_t index = 0;
|
|
|
+ char* s = str;
|
|
|
if(num < 0) {
|
|
|
- str[index++] = '-';
|
|
|
+ *(s++) = '-';
|
|
|
num = -num;
|
|
|
}
|
|
|
|
|
|
uint8_t d1 = (num / 10) % 10;
|
|
|
uint8_t d2 = num % 10;
|
|
|
- str[index++] = CONVERT_DIGIT_TO_CHAR(d1);
|
|
|
- str[index++] = CONVERT_DIGIT_TO_CHAR(d2);
|
|
|
- str[index++] = '\0';
|
|
|
+ *(s++) = CONVERT_DIGIT_TO_CHAR(d1);
|
|
|
+ *(s++) = CONVERT_DIGIT_TO_CHAR(d2);
|
|
|
+ *(s++) = '\0';
|
|
|
}
|
|
|
|
|
|
void totp_scene_app_settings_render(Canvas* const canvas, const PluginState* plugin_state) {
|
|
|
@@ -183,116 +183,117 @@ bool totp_scene_app_settings_handle_event(
|
|
|
}
|
|
|
|
|
|
SceneState* scene_state = (SceneState*)plugin_state->current_scene_state;
|
|
|
- if(event->input.type != InputTypePress && event->input.type != InputTypeRepeat) {
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- switch(event->input.key) {
|
|
|
- case InputKeyUp:
|
|
|
- totp_roll_value_uint8_t(
|
|
|
- &scene_state->selected_control,
|
|
|
- -1,
|
|
|
- HoursInput,
|
|
|
- ConfirmButton,
|
|
|
- RollOverflowBehaviorStop);
|
|
|
- if(scene_state->selected_control > Vibro) {
|
|
|
- scene_state->y_offset = 128;
|
|
|
- } else if(scene_state->selected_control > MinutesInput) {
|
|
|
- scene_state->y_offset = 64;
|
|
|
- } else {
|
|
|
- scene_state->y_offset = 0;
|
|
|
- }
|
|
|
- break;
|
|
|
- case InputKeyDown:
|
|
|
- totp_roll_value_uint8_t(
|
|
|
- &scene_state->selected_control, 1, HoursInput, ConfirmButton, RollOverflowBehaviorStop);
|
|
|
- if(scene_state->selected_control > Vibro) {
|
|
|
- scene_state->y_offset = 128;
|
|
|
- } else if(scene_state->selected_control > MinutesInput) {
|
|
|
- scene_state->y_offset = 64;
|
|
|
- } else {
|
|
|
- scene_state->y_offset = 0;
|
|
|
- }
|
|
|
- break;
|
|
|
- case InputKeyRight:
|
|
|
- if(scene_state->selected_control == HoursInput) {
|
|
|
- totp_roll_value_int8_t(
|
|
|
- &scene_state->tz_offset_hours, 1, -12, 12, RollOverflowBehaviorStop);
|
|
|
- } else if(scene_state->selected_control == MinutesInput) {
|
|
|
+ if(event->input.type == InputTypePress || event->input.type == InputTypeRepeat) {
|
|
|
+ switch(event->input.key) {
|
|
|
+ case InputKeyUp:
|
|
|
totp_roll_value_uint8_t(
|
|
|
- &scene_state->tz_offset_minutes, 15, 0, 45, RollOverflowBehaviorRoll);
|
|
|
- } else if(scene_state->selected_control == Sound) {
|
|
|
- scene_state->notification_sound = !scene_state->notification_sound;
|
|
|
- } else if(scene_state->selected_control == Vibro) {
|
|
|
- scene_state->notification_vibro = !scene_state->notification_vibro;
|
|
|
- } else if(scene_state->selected_control == BadUsb) {
|
|
|
- scene_state->badusb_enabled = !scene_state->badusb_enabled;
|
|
|
- }
|
|
|
+ &scene_state->selected_control,
|
|
|
+ -1,
|
|
|
+ HoursInput,
|
|
|
+ ConfirmButton,
|
|
|
+ RollOverflowBehaviorStop);
|
|
|
+ if(scene_state->selected_control > Vibro) {
|
|
|
+ scene_state->y_offset = 128;
|
|
|
+ } else if(scene_state->selected_control > MinutesInput) {
|
|
|
+ scene_state->y_offset = 64;
|
|
|
+ } else {
|
|
|
+ scene_state->y_offset = 0;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case InputKeyDown:
|
|
|
+ totp_roll_value_uint8_t(
|
|
|
+ &scene_state->selected_control,
|
|
|
+ 1,
|
|
|
+ HoursInput,
|
|
|
+ ConfirmButton,
|
|
|
+ RollOverflowBehaviorStop);
|
|
|
+ if(scene_state->selected_control > Vibro) {
|
|
|
+ scene_state->y_offset = 128;
|
|
|
+ } else if(scene_state->selected_control > MinutesInput) {
|
|
|
+ scene_state->y_offset = 64;
|
|
|
+ } else {
|
|
|
+ scene_state->y_offset = 0;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case InputKeyRight:
|
|
|
+ if(scene_state->selected_control == HoursInput) {
|
|
|
+ totp_roll_value_int8_t(
|
|
|
+ &scene_state->tz_offset_hours, 1, -12, 12, RollOverflowBehaviorStop);
|
|
|
+ } else if(scene_state->selected_control == MinutesInput) {
|
|
|
+ totp_roll_value_uint8_t(
|
|
|
+ &scene_state->tz_offset_minutes, 15, 0, 45, RollOverflowBehaviorRoll);
|
|
|
+ } else if(scene_state->selected_control == Sound) {
|
|
|
+ scene_state->notification_sound = !scene_state->notification_sound;
|
|
|
+ } else if(scene_state->selected_control == 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;
|
|
|
- }
|
|
|
+ else if(scene_state->selected_control == BadBt) {
|
|
|
+ scene_state->badbt_enabled = !scene_state->badbt_enabled;
|
|
|
+ }
|
|
|
#endif
|
|
|
- break;
|
|
|
- case InputKeyLeft:
|
|
|
- if(scene_state->selected_control == HoursInput) {
|
|
|
- totp_roll_value_int8_t(
|
|
|
- &scene_state->tz_offset_hours, -1, -12, 12, RollOverflowBehaviorStop);
|
|
|
- } else if(scene_state->selected_control == MinutesInput) {
|
|
|
- totp_roll_value_uint8_t(
|
|
|
- &scene_state->tz_offset_minutes, -15, 0, 45, RollOverflowBehaviorRoll);
|
|
|
- } else if(scene_state->selected_control == Sound) {
|
|
|
- scene_state->notification_sound = !scene_state->notification_sound;
|
|
|
- } else if(scene_state->selected_control == Vibro) {
|
|
|
- scene_state->notification_vibro = !scene_state->notification_vibro;
|
|
|
- } else if(scene_state->selected_control == BadUsb) {
|
|
|
- scene_state->badusb_enabled = !scene_state->badusb_enabled;
|
|
|
- }
|
|
|
+ break;
|
|
|
+ case InputKeyLeft:
|
|
|
+ if(scene_state->selected_control == HoursInput) {
|
|
|
+ totp_roll_value_int8_t(
|
|
|
+ &scene_state->tz_offset_hours, -1, -12, 12, RollOverflowBehaviorStop);
|
|
|
+ } else if(scene_state->selected_control == MinutesInput) {
|
|
|
+ totp_roll_value_uint8_t(
|
|
|
+ &scene_state->tz_offset_minutes, -15, 0, 45, RollOverflowBehaviorRoll);
|
|
|
+ } else if(scene_state->selected_control == Sound) {
|
|
|
+ scene_state->notification_sound = !scene_state->notification_sound;
|
|
|
+ } else if(scene_state->selected_control == 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;
|
|
|
- }
|
|
|
+ else if(scene_state->selected_control == BadBt) {
|
|
|
+ scene_state->badbt_enabled = !scene_state->badbt_enabled;
|
|
|
+ }
|
|
|
#endif
|
|
|
- break;
|
|
|
- case InputKeyOk:
|
|
|
- if(scene_state->selected_control == ConfirmButton) {
|
|
|
- plugin_state->timezone_offset = (float)scene_state->tz_offset_hours +
|
|
|
- (float)scene_state->tz_offset_minutes / 60.0f;
|
|
|
+ break;
|
|
|
+ case InputKeyOk:
|
|
|
+ break;
|
|
|
+ case InputKeyBack: {
|
|
|
+ totp_scene_director_activate_scene(plugin_state, TotpSceneTokenMenu);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } else if(
|
|
|
+ event->input.type == InputTypeRelease && event->input.key == InputKeyOk &&
|
|
|
+ scene_state->selected_control == ConfirmButton) {
|
|
|
+ plugin_state->timezone_offset =
|
|
|
+ (float)scene_state->tz_offset_hours + (float)scene_state->tz_offset_minutes / 60.0f;
|
|
|
|
|
|
- plugin_state->notification_method =
|
|
|
- (scene_state->notification_sound ? NotificationMethodSound :
|
|
|
- NotificationMethodNone) |
|
|
|
- (scene_state->notification_vibro ? NotificationMethodVibro :
|
|
|
- NotificationMethodNone);
|
|
|
+ plugin_state->notification_method =
|
|
|
+ (scene_state->notification_sound ? NotificationMethodSound : NotificationMethodNone) |
|
|
|
+ (scene_state->notification_vibro ? NotificationMethodVibro : NotificationMethodNone);
|
|
|
|
|
|
- plugin_state->automation_method =
|
|
|
- scene_state->badusb_enabled ? AutomationMethodBadUsb : AutomationMethodNone;
|
|
|
+ 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;
|
|
|
+ plugin_state->automation_method |= scene_state->badbt_enabled ? AutomationMethodBadBt :
|
|
|
+ AutomationMethodNone;
|
|
|
#endif
|
|
|
|
|
|
- if(!totp_config_file_update_user_settings(plugin_state)) {
|
|
|
- totp_dialogs_config_updating_error(plugin_state);
|
|
|
- return false;
|
|
|
- }
|
|
|
+ if(!totp_config_file_update_user_settings(plugin_state)) {
|
|
|
+ totp_dialogs_config_updating_error(plugin_state);
|
|
|
+ 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;
|
|
|
- }
|
|
|
+ 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
|
|
|
|
|
|
- totp_scene_director_activate_scene(plugin_state, TotpSceneTokenMenu);
|
|
|
- }
|
|
|
- break;
|
|
|
- case InputKeyBack: {
|
|
|
totp_scene_director_activate_scene(plugin_state, TotpSceneTokenMenu);
|
|
|
- break;
|
|
|
- }
|
|
|
- default:
|
|
|
- break;
|
|
|
}
|
|
|
|
|
|
return true;
|