diff --git a/applications/main/archive/helpers/archive_files.c b/applications/main/archive/helpers/archive_files.c index 7e7ab1774..83eb2a845 100644 --- a/applications/main/archive/helpers/archive_files.c +++ b/applications/main/archive/helpers/archive_files.c @@ -17,8 +17,8 @@ void archive_set_file_type(ArchiveFile_t* file, const char* path, bool is_folder if((known_ext[i][0] == '?') || (known_ext[i][0] == '*')) continue; if(furi_string_search(file->path, known_ext[i], 0) != FURI_STRING_FAILURE) { if(i == ArchiveFileTypeBadKb) { - if(furi_string_search( - file->path, archive_get_default_path(ArchiveTabBadKb)) == 0) { + if(furi_string_search(file->path, archive_get_default_path(ArchiveTabBadKb)) == + 0) { file->type = i; return; // *.txt file is a BadKB script only if it is in BadKB folder } diff --git a/applications/main/bad_kb/bad_kb_app.c b/applications/main/bad_kb/bad_kb_app.c index c62af4733..4181b08d4 100644 --- a/applications/main/bad_kb/bad_kb_app.c +++ b/applications/main/bad_kb/bad_kb_app.c @@ -112,10 +112,14 @@ BadKbApp* bad_kb_app_alloc(char* arg) { app->var_item_list_bt = variable_item_list_alloc(); view_dispatcher_add_view( - app->view_dispatcher, BadKbAppViewConfigBt, variable_item_list_get_view(app->var_item_list_bt)); + app->view_dispatcher, + BadKbAppViewConfigBt, + variable_item_list_get_view(app->var_item_list_bt)); app->var_item_list_usb = variable_item_list_alloc(); view_dispatcher_add_view( - app->view_dispatcher, BadKbAppViewConfigUsb, variable_item_list_get_view(app->var_item_list_usb)); + app->view_dispatcher, + BadKbAppViewConfigUsb, + variable_item_list_get_view(app->var_item_list_usb)); app->bad_kb_view = bad_kb_alloc(); view_dispatcher_add_view( @@ -184,15 +188,14 @@ void bad_kb_app_free(BadKbApp* app) { // restores bt config // BtProfile have already been switched to the previous one - // so we directly modify the right profile - if (strcmp(app->bt_old_config.name, app->name) != 0) { + // so we directly modify the right profile + if(strcmp(app->bt_old_config.name, app->name) != 0) { furi_hal_bt_set_profile_adv_name(FuriHalBtProfileHidKeyboard, app->bt_old_config.name); } - if (memcmp(app->bt_old_config.mac, app->mac, BAD_KB_MAC_ADDRESS_LEN) != 0) { + if(memcmp(app->bt_old_config.mac, app->mac, BAD_KB_MAC_ADDRESS_LEN) != 0) { furi_hal_bt_set_profile_mac_addr(FuriHalBtProfileHidKeyboard, app->bt_old_config.mac); } - // Close records furi_record_close(RECORD_GUI); furi_record_close(RECORD_NOTIFICATION); diff --git a/applications/main/bad_kb/bad_kb_script.c b/applications/main/bad_kb/bad_kb_script.c index 80d203db6..18aabe860 100644 --- a/applications/main/bad_kb/bad_kb_script.c +++ b/applications/main/bad_kb/bad_kb_script.c @@ -231,8 +231,8 @@ static bool ducky_is_line_end(const char chr) { } static void ducky_numlock_on(BadKbScript* bad_kb) { - if (bad_kb->bt) { - if((furi_hal_hid_get_led_state() & HID_KB_LED_NUM) == 0) { // FIXME + if(bad_kb->bt) { + if((furi_hal_hid_get_led_state() & HID_KB_LED_NUM) == 0) { // FIXME bt_hid_hold_while_keyboard_buffer_full(1, -1); furi_hal_bt_hid_kb_press(HID_KEYBOARD_LOCK_NUM_LOCK); furi_delay_ms(bt_timeout); @@ -251,7 +251,7 @@ static bool ducky_numpad_press(BadKbScript* bad_kb, const char num) { uint16_t key = numpad_keys[num - '0']; FURI_LOG_I(WORKER_TAG, "Pressing %c\r\n", num); - if (bad_kb->bt) { + if(bad_kb->bt) { bt_hid_hold_while_keyboard_buffer_full(1, -1); furi_hal_bt_hid_kb_press(key); furi_delay_ms(bt_timeout); @@ -270,7 +270,7 @@ static bool ducky_altchar(BadKbScript* bad_kb, const char* charcode) { FURI_LOG_I(WORKER_TAG, "char %s", charcode); - if (bad_kb->bt) { + if(bad_kb->bt) { bt_hid_hold_while_keyboard_buffer_full(1, -1); furi_hal_bt_hid_kb_press(KEY_MOD_LEFT_ALT); } else { @@ -283,7 +283,7 @@ static bool ducky_altchar(BadKbScript* bad_kb, const char* charcode) { i++; } - if (bad_kb->bt) { + if(bad_kb->bt) { furi_hal_bt_hid_kb_release(KEY_MOD_LEFT_ALT); } else { furi_hal_hid_kb_release(KEY_MOD_LEFT_ALT); @@ -316,7 +316,7 @@ static bool ducky_string(BadKbScript* bad_kb, const char* param) { while(param[i] != '\0') { uint16_t keycode = BADKB_ASCII_TO_KEY(bad_kb, param[i]); if(keycode != HID_KEYBOARD_NONE) { - if (bad_kb->bt) { + if(bad_kb->bt) { bt_hid_hold_while_keyboard_buffer_full(1, -1); furi_hal_bt_hid_kb_press(keycode); furi_delay_ms(bt_timeout); @@ -429,7 +429,7 @@ static int32_t // SYSRQ line_tmp = &line_tmp[ducky_get_command_len(line_tmp) + 1]; uint16_t key = ducky_get_keycode(bad_kb, line_tmp, true); - if (bad_kb->bt) { + if(bad_kb->bt) { bt_hid_hold_while_keyboard_buffer_full(1, -1); furi_hal_bt_hid_kb_press(KEY_MOD_LEFT_ALT | HID_KEYBOARD_PRINT_SCREEN); furi_hal_bt_hid_kb_press(key); @@ -456,7 +456,7 @@ static int32_t line_tmp = &line_tmp[ducky_get_command_len(line_tmp) + 1]; key |= ducky_get_keycode(bad_kb, line_tmp, true); } - if (bad_kb->bt) { + if(bad_kb->bt) { furi_hal_bt_hid_kb_press(key); furi_delay_ms(bt_timeout); furi_hal_bt_hid_kb_release(key); @@ -520,7 +520,7 @@ static bool ducky_script_preload(BadKbScript* bad_kb, File* script_file) { } } while(ret > 0); - if (!bad_kb->bt) { + if(!bad_kb->bt) { const char* line_tmp = furi_string_get_cstr(bad_kb->line); bool id_set = false; // Looking for ID command at first line if(strncmp(line_tmp, ducky_cmd_id, strlen(ducky_cmd_id)) == 0) { @@ -643,12 +643,12 @@ static int32_t bad_kb_worker(void* context) { FuriHalUsbInterface* usb_mode_prev = NULL; GapPairing old_pairing_method = GapPairingNone; - if (bad_kb->bt) { + if(bad_kb->bt) { bt_timeout = bt_hid_delays[LevelRssi39_0]; bt_disconnect(bad_kb->bt); furi_delay_ms(200); bt_keys_storage_set_storage_path(bad_kb->bt, HID_BT_KEYS_STORAGE_PATH); - if (!bt_set_profile(bad_kb->bt, BtProfileHidKeyboard)) { + if(!bt_set_profile(bad_kb->bt, BtProfileHidKeyboard)) { FURI_LOG_E(TAG, "Failed to switch to HID profile"); return -1; } @@ -674,7 +674,7 @@ static int32_t bad_kb_worker(void* context) { FSAM_READ, FSOM_OPEN_EXISTING)) { if((ducky_script_preload(bad_kb, script_file)) && (bad_kb->st.line_nb > 0)) { - if (bad_kb->bt) { + if(bad_kb->bt) { worker_state = BadKbStateNotConnected; // Ready to run } else { if(furi_hal_hid_is_connected()) { @@ -750,7 +750,7 @@ static int32_t bad_kb_worker(void* context) { storage_file_seek(script_file, 0, true); // extra time for PC to recognize Flipper as keyboard furi_thread_flags_wait(0, FuriFlagWaitAny, 1500); - if (bad_kb->bt) { + if(bad_kb->bt) { update_bt_timeout(bad_kb->bt); FURI_LOG_I(WORKER_TAG, "BLE Key timeout : %u", bt_timeout); } @@ -771,14 +771,14 @@ static int32_t bad_kb_worker(void* context) { break; } else if(flags & WorkerEvtToggle) { worker_state = BadKbStateIdle; // Stop executing script - if (bad_kb->bt) { + if(bad_kb->bt) { furi_hal_bt_hid_kb_release_all(); } else { furi_hal_hid_kb_release_all(); } } else if(flags & WorkerEvtDisconnect) { worker_state = BadKbStateNotConnected; // Disconnected - if (bad_kb->bt) { + if(bad_kb->bt) { furi_hal_bt_hid_kb_release_all(); } else { furi_hal_hid_kb_release_all(); @@ -803,7 +803,7 @@ static int32_t bad_kb_worker(void* context) { delay_val = 0; worker_state = BadKbStateIdle; bad_kb->st.state = BadKbStateDone; - if (bad_kb->bt) { + if(bad_kb->bt) { furi_hal_bt_hid_kb_release_all(); } else { furi_hal_hid_kb_release_all(); @@ -827,13 +827,13 @@ static int32_t bad_kb_worker(void* context) { break; } } - if (bad_kb->bt) { + if(bad_kb->bt) { update_bt_timeout(bad_kb->bt); FURI_LOG_D(WORKER_TAG, "BLE Key timeout : %u", bt_timeout); } } - if (bad_kb->bt) { + if(bad_kb->bt) { // release all keys bt_hid_hold_while_keyboard_buffer_full(6, 3000); diff --git a/applications/main/bad_kb/scenes/bad_kb_scene_config_bt.c b/applications/main/bad_kb/scenes/bad_kb_scene_config_bt.c index fc1d19e76..6d01f1df1 100644 --- a/applications/main/bad_kb/scenes/bad_kb_scene_config_bt.c +++ b/applications/main/bad_kb/scenes/bad_kb_scene_config_bt.c @@ -31,16 +31,14 @@ void bad_kb_scene_config_bt_on_enter(void* context) { variable_item_set_current_value_index(item, bad_kb->is_bt); variable_item_set_current_value_text(item, bad_kb->is_bt ? "BT" : "USB"); - item = variable_item_list_add( - var_item_list, "Keyboard layout", 0, NULL, bad_kb); + item = variable_item_list_add(var_item_list, "Keyboard layout", 0, NULL, bad_kb); - item = variable_item_list_add( - var_item_list, "Change adv name", 0, NULL, bad_kb); + item = variable_item_list_add(var_item_list, "Change adv name", 0, NULL, bad_kb); - item = variable_item_list_add( - var_item_list, "Change MAC address", 0, NULL, bad_kb); + item = variable_item_list_add(var_item_list, "Change MAC address", 0, NULL, bad_kb); - variable_item_list_set_enter_callback(var_item_list, bad_kb_scene_config_bt_var_item_list_callback, bad_kb); + variable_item_list_set_enter_callback( + var_item_list, bad_kb_scene_config_bt_var_item_list_callback, bad_kb); view_dispatcher_switch_to_view(bad_kb->view_dispatcher, BadKbAppViewConfigBt); } @@ -56,10 +54,11 @@ bool bad_kb_scene_config_bt_on_event(void* context, SceneManagerEvent event) { scene_manager_next_scene(bad_kb->scene_manager, BadKbSceneConfigLayout); } else if(event.event == VarItemListIndexConnection) { bad_kb_script_close(bad_kb->bad_kb_script); - bad_kb->bad_kb_script = bad_kb_script_open(bad_kb->file_path, bad_kb->is_bt ? bad_kb->bt : NULL); + bad_kb->bad_kb_script = + bad_kb_script_open(bad_kb->file_path, bad_kb->is_bt ? bad_kb->bt : NULL); bad_kb_script_set_keyboard_layout(bad_kb->bad_kb_script, bad_kb->keyboard_layout); scene_manager_previous_scene(bad_kb->scene_manager); - if (bad_kb->is_bt) { + if(bad_kb->is_bt) { scene_manager_next_scene(bad_kb->scene_manager, BadKbSceneConfigBt); } else { scene_manager_next_scene(bad_kb->scene_manager, BadKbSceneConfigUsb); @@ -68,8 +67,8 @@ bool bad_kb_scene_config_bt_on_event(void* context, SceneManagerEvent event) { scene_manager_next_scene(bad_kb->scene_manager, BadKbSceneConfigName); } else if(event.event == VarItemListIndexMacAddress) { scene_manager_next_scene(bad_kb->scene_manager, BadKbSceneConfigMac); - // } else { - // furi_crash("Unknown key type"); + // } else { + // furi_crash("Unknown key type"); } } diff --git a/applications/main/bad_kb/scenes/bad_kb_scene_config_name.c b/applications/main/bad_kb/scenes/bad_kb_scene_config_name.c index d3d7628b1..82dd7a850 100644 --- a/applications/main/bad_kb/scenes/bad_kb_scene_config_name.c +++ b/applications/main/bad_kb/scenes/bad_kb_scene_config_name.c @@ -3,8 +3,7 @@ static void bad_kb_scene_config_name_text_input_callback(void* context) { BadKbApp* bad_kb = context; - view_dispatcher_send_custom_event( - bad_kb->view_dispatcher, BadKbAppCustomEventTextEditResult); + view_dispatcher_send_custom_event(bad_kb->view_dispatcher, BadKbAppCustomEventTextEditResult); } void bad_kb_scene_config_name_on_enter(void* context) { diff --git a/applications/main/bad_kb/scenes/bad_kb_scene_config_usb.c b/applications/main/bad_kb/scenes/bad_kb_scene_config_usb.c index 35c5ab8d2..27457e5f2 100644 --- a/applications/main/bad_kb/scenes/bad_kb_scene_config_usb.c +++ b/applications/main/bad_kb/scenes/bad_kb_scene_config_usb.c @@ -29,10 +29,10 @@ void bad_kb_scene_config_usb_on_enter(void* context) { variable_item_set_current_value_index(item, bad_kb->is_bt); variable_item_set_current_value_text(item, bad_kb->is_bt ? "BT" : "USB"); - item = variable_item_list_add( - var_item_list, "Keyboard layout", 0, NULL, bad_kb); + item = variable_item_list_add(var_item_list, "Keyboard layout", 0, NULL, bad_kb); - variable_item_list_set_enter_callback(var_item_list, bad_kb_scene_config_usb_var_item_list_callback, bad_kb); + variable_item_list_set_enter_callback( + var_item_list, bad_kb_scene_config_usb_var_item_list_callback, bad_kb); view_dispatcher_switch_to_view(bad_kb->view_dispatcher, BadKbAppViewConfigUsb); } @@ -48,16 +48,17 @@ bool bad_kb_scene_config_usb_on_event(void* context, SceneManagerEvent event) { scene_manager_next_scene(bad_kb->scene_manager, BadKbSceneConfigLayout); } else if(event.event == VarItemListIndexConnection) { bad_kb_script_close(bad_kb->bad_kb_script); - bad_kb->bad_kb_script = bad_kb_script_open(bad_kb->file_path, bad_kb->is_bt ? bad_kb->bt : NULL); + bad_kb->bad_kb_script = + bad_kb_script_open(bad_kb->file_path, bad_kb->is_bt ? bad_kb->bt : NULL); bad_kb_script_set_keyboard_layout(bad_kb->bad_kb_script, bad_kb->keyboard_layout); scene_manager_previous_scene(bad_kb->scene_manager); - if (bad_kb->is_bt) { + if(bad_kb->is_bt) { scene_manager_next_scene(bad_kb->scene_manager, BadKbSceneConfigBt); } else { scene_manager_next_scene(bad_kb->scene_manager, BadKbSceneConfigUsb); } - // } else { - // furi_crash("Unknown key type"); + // } else { + // furi_crash("Unknown key type"); } } diff --git a/applications/main/bad_kb/scenes/bad_kb_scene_file_select.c b/applications/main/bad_kb/scenes/bad_kb_scene_file_select.c index 44012f68d..df1c93feb 100644 --- a/applications/main/bad_kb/scenes/bad_kb_scene_file_select.c +++ b/applications/main/bad_kb/scenes/bad_kb_scene_file_select.c @@ -29,7 +29,8 @@ void bad_kb_scene_file_select_on_enter(void* context) { } if(bad_kb_file_select(bad_kb)) { - bad_kb->bad_kb_script = bad_kb_script_open(bad_kb->file_path, bad_kb->is_bt ? bad_kb->bt : NULL); + bad_kb->bad_kb_script = + bad_kb_script_open(bad_kb->file_path, bad_kb->is_bt ? bad_kb->bt : NULL); bad_kb_script_set_keyboard_layout(bad_kb->bad_kb_script, bad_kb->keyboard_layout); scene_manager_next_scene(bad_kb->scene_manager, BadKbSceneWork); diff --git a/applications/main/bad_kb/scenes/bad_kb_scene_work.c b/applications/main/bad_kb/scenes/bad_kb_scene_work.c index a7eac1786..2f6ae6057 100644 --- a/applications/main/bad_kb/scenes/bad_kb_scene_work.c +++ b/applications/main/bad_kb/scenes/bad_kb_scene_work.c @@ -16,7 +16,7 @@ bool bad_kb_scene_work_on_event(void* context, SceneManagerEvent event) { if(event.type == SceneManagerEventTypeCustom) { if(event.event == InputKeyLeft) { - if (app->is_bt) { + if(app->is_bt) { scene_manager_next_scene(app->scene_manager, BadKbSceneConfigBt); } else { scene_manager_next_scene(app->scene_manager, BadKbSceneConfigUsb); diff --git a/applications/main/bad_kb/views/bad_kb_view.c b/applications/main/bad_kb/views/bad_kb_view.c index a0fb39f88..581a703b9 100644 --- a/applications/main/bad_kb/views/bad_kb_view.c +++ b/applications/main/bad_kb/views/bad_kb_view.c @@ -60,8 +60,8 @@ static void bad_kb_draw_callback(Canvas* canvas, void* _model) { elements_button_center(canvas, "Cancel"); } - if((model->state.state == BadKbStateNotConnected) || - (model->state.state == BadKbStateIdle) || (model->state.state == BadKbStateDone)) { + if((model->state.state == BadKbStateNotConnected) || (model->state.state == BadKbStateIdle) || + (model->state.state == BadKbStateDone)) { elements_button_left(canvas, "Config"); } @@ -204,19 +204,13 @@ void bad_kb_set_button_callback(BadKb* bad_kb, BadKbButtonCallback callback, voi void bad_kb_set_file_name(BadKb* bad_kb, const char* name) { furi_assert(name); with_view_model( - bad_kb->view, - BadKbModel * model, - { strlcpy(model->file_name, name, MAX_NAME_LEN); }, - true); + bad_kb->view, BadKbModel * model, { strlcpy(model->file_name, name, MAX_NAME_LEN); }, true); } void bad_kb_set_layout(BadKb* bad_kb, const char* layout) { furi_assert(layout); with_view_model( - bad_kb->view, - BadKbModel * model, - { strlcpy(model->layout, layout, MAX_NAME_LEN); }, - true); + bad_kb->view, BadKbModel * model, { strlcpy(model->layout, layout, MAX_NAME_LEN); }, true); } void bad_kb_set_state(BadKb* bad_kb, BadKbState* st) { diff --git a/applications/services/bt/bt_service/bt.c b/applications/services/bt/bt_service/bt.c index 6108a7790..6c2fb9307 100644 --- a/applications/services/bt/bt_service/bt.c +++ b/applications/services/bt/bt_service/bt.c @@ -76,10 +76,9 @@ static void bt_pin_code_hide(Bt* bt) { static bool bt_pin_code_verify_event_handler(Bt* bt, uint32_t pin) { furi_assert(bt); - - if (bt_get_profile_pairing_method(bt) == GapPairingNone) - return true; - + + if(bt_get_profile_pairing_method(bt) == GapPairingNone) return true; + notification_message(bt->notification, &sequence_display_backlight_on); FuriString* pin_str; dialog_message_set_icon(bt->dialog_message, XTREME_ASSETS()->I_BLE_Pairing_128x64, 0, 0); diff --git a/firmware/targets/f7/ble_glue/gap.c b/firmware/targets/f7/ble_glue/gap.c index 892fbd2a9..83944b4b5 100644 --- a/firmware/targets/f7/ble_glue/gap.c +++ b/firmware/targets/f7/ble_glue/gap.c @@ -378,7 +378,7 @@ static void gap_init_svc(Gap* gap) { } else if(gap->config->pairing_method == GapPairingPinCodeVerifyYesNo) { aci_gap_set_io_capability(IO_CAP_DISPLAY_YES_NO); keypress_supported = true; - } else if (gap->config->pairing_method == GapPairingNone) { + } else if(gap->config->pairing_method == GapPairingNone) { // Just works pairing method (IOS accept it, it seems android and linux doesn't) conf_mitm = 0; conf_used_fixed_pin = 0; @@ -387,8 +387,6 @@ static void gap_init_svc(Gap* gap) { keypress_supported = true; } - - // Setup authentication aci_gap_set_authentication_requirement( gap->config->bonding_mode,