Просмотр исходного кода

Revert "Totp: Temp fix automation abstractions"

This reverts commit 8a1ca6258286d7ed3bf7db44cd20c7a1addc3dec.
Willy-JL 1 год назад
Родитель
Сommit
9f127edcad

+ 3 - 4
totp/workers/bt_type_code/bt_type_code.c

@@ -61,10 +61,9 @@ static void totp_type_code_worker_type_code(TotpBtTypeCodeWorkerContext* context
 
     if(context->is_connected &&
        furi_mutex_acquire(context->code_buffer_sync, 500) == FuriStatusOk) {
-        totp_type_code_worker_execute_automation_ctx(
-            (TOTP_AUTOMATION_KEY_HANDLER_CTX)&ble_profile_hid_kb_press,
-            (TOTP_AUTOMATION_KEY_HANDLER_CTX)&ble_profile_hid_kb_release,
-            context->ble_hid_profile,
+        totp_type_code_worker_execute_automation(
+            &furi_hal_bt_hid_kb_press,
+            &furi_hal_bt_hid_kb_release,
             context->code_buffer,
             context->code_buffer_size,
             context->flags,

+ 0 - 59
totp/workers/type_code_common.c

@@ -75,62 +75,3 @@ void totp_type_code_worker_execute_automation(
         totp_type_code_worker_press_key(HID_KEYBOARD_TAB, key_press_fn, key_release_fn, features);
     }
 }
-
-static void totp_type_code_worker_press_key_ctx(
-    uint16_t key,
-    TOTP_AUTOMATION_KEY_HANDLER_CTX key_press_fn,
-    TOTP_AUTOMATION_KEY_HANDLER_CTX key_release_fn,
-    void* ctx,
-    TokenAutomationFeature features) {
-    (*key_press_fn)(ctx, key);
-    furi_delay_ms(get_keypress_delay(features));
-    (*key_release_fn)(ctx, key);
-}
-
-void totp_type_code_worker_execute_automation_ctx(
-    TOTP_AUTOMATION_KEY_HANDLER_CTX key_press_fn,
-    TOTP_AUTOMATION_KEY_HANDLER_CTX key_release_fn,
-    void* ctx,
-    const char* code_buffer,
-    uint8_t code_buffer_size,
-    TokenAutomationFeature features,
-    AutomationKeyboardLayout keyboard_layout,
-    uint16_t initial_delay) {
-    uint16_t keyboard_layout_dict[TOTP_KB_LAYOUT_DATA_LENGTH];
-    if(!totp_kb_layout_provider_get_layout_data(keyboard_layout, &keyboard_layout_dict[0])) {
-        return;
-    }
-
-    furi_delay_ms(initial_delay);
-
-    uint32_t keystroke_delay = get_keystroke_delay(features);
-
-    char cb_char;
-    uint8_t i = 0;
-    while(i < code_buffer_size && (cb_char = code_buffer[i]) != 0) {
-        uint8_t char_index = CONVERT_CHAR_TO_DIGIT(cb_char);
-        if(char_index > 9) {
-            char_index = cb_char - 'A' + 10;
-        }
-
-        if(char_index >= TOTP_KB_LAYOUT_DATA_LENGTH) break;
-
-        uint16_t hid_kb_key = keyboard_layout_dict[char_index];
-        totp_type_code_worker_press_key_ctx(
-            hid_kb_key, key_press_fn, key_release_fn, ctx, features);
-        furi_delay_ms(keystroke_delay);
-        i++;
-    }
-
-    if(features & TokenAutomationFeatureEnterAtTheEnd) {
-        furi_delay_ms(keystroke_delay);
-        totp_type_code_worker_press_key_ctx(
-            HID_KEYBOARD_RETURN, key_press_fn, key_release_fn, ctx, features);
-    }
-
-    if(features & TokenAutomationFeatureTabAtTheEnd) {
-        furi_delay_ms(keystroke_delay);
-        totp_type_code_worker_press_key_ctx(
-            HID_KEYBOARD_TAB, key_press_fn, key_release_fn, ctx, features);
-    }
-}

+ 0 - 22
totp/workers/type_code_common.h

@@ -4,7 +4,6 @@
 #include "../types/automation_kb_layout.h"
 
 typedef bool (*TOTP_AUTOMATION_KEY_HANDLER)(uint16_t key);
-typedef bool (*TOTP_AUTOMATION_KEY_HANDLER_CTX)(void* ctx, uint16_t key);
 
 /**
  * @brief Executes token input automation using given key press\release handlers
@@ -24,24 +23,3 @@ void totp_type_code_worker_execute_automation(
     TokenAutomationFeature features,
     AutomationKeyboardLayout keyboard_layout,
     uint16_t initial_delay);
-
-/**
- * @brief Executes token input automation using given key press\release handlers
- * @param key_press_fn key press handler
- * @param key_release_fn key release handler
- * @param ctx user data context
- * @param code_buffer code buffer to be typed
- * @param code_buffer_size code buffer size
- * @param features automation features
- * @param keyboard_layout keyboard layout to be used
- * @param initial_delay initial delay before starting automation
- */
-void totp_type_code_worker_execute_automation_ctx(
-    TOTP_AUTOMATION_KEY_HANDLER_CTX key_press_fn,
-    TOTP_AUTOMATION_KEY_HANDLER_CTX key_release_fn,
-    void* ctx,
-    const char* code_buffer,
-    uint8_t code_buffer_size,
-    TokenAutomationFeature features,
-    AutomationKeyboardLayout keyboard_layout,
-    uint16_t initial_delay);