|
@@ -25,10 +25,11 @@ static void totp_type_code_worker_press_key(
|
|
|
uint16_t key,
|
|
uint16_t key,
|
|
|
TOTP_AUTOMATION_KEY_HANDLER key_press_fn,
|
|
TOTP_AUTOMATION_KEY_HANDLER key_press_fn,
|
|
|
TOTP_AUTOMATION_KEY_HANDLER key_release_fn,
|
|
TOTP_AUTOMATION_KEY_HANDLER key_release_fn,
|
|
|
- TokenAutomationFeature features) {
|
|
|
|
|
- (*key_press_fn)(key);
|
|
|
|
|
|
|
+ TokenAutomationFeature features,
|
|
|
|
|
+ void* context) {
|
|
|
|
|
+ (*key_press_fn)(key, context);
|
|
|
furi_delay_ms(get_keypress_delay(features));
|
|
furi_delay_ms(get_keypress_delay(features));
|
|
|
- (*key_release_fn)(key);
|
|
|
|
|
|
|
+ (*key_release_fn)(key, context);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void totp_type_code_worker_execute_automation(
|
|
void totp_type_code_worker_execute_automation(
|
|
@@ -38,7 +39,8 @@ void totp_type_code_worker_execute_automation(
|
|
|
uint8_t code_buffer_size,
|
|
uint8_t code_buffer_size,
|
|
|
TokenAutomationFeature features,
|
|
TokenAutomationFeature features,
|
|
|
AutomationKeyboardLayout keyboard_layout,
|
|
AutomationKeyboardLayout keyboard_layout,
|
|
|
- uint16_t initial_delay) {
|
|
|
|
|
|
|
+ uint16_t initial_delay,
|
|
|
|
|
+ void* context) {
|
|
|
uint16_t keyboard_layout_dict[TOTP_KB_LAYOUT_DATA_LENGTH];
|
|
uint16_t keyboard_layout_dict[TOTP_KB_LAYOUT_DATA_LENGTH];
|
|
|
if(!totp_kb_layout_provider_get_layout_data(keyboard_layout, &keyboard_layout_dict[0])) {
|
|
if(!totp_kb_layout_provider_get_layout_data(keyboard_layout, &keyboard_layout_dict[0])) {
|
|
|
return;
|
|
return;
|
|
@@ -59,78 +61,21 @@ void totp_type_code_worker_execute_automation(
|
|
|
if(char_index >= TOTP_KB_LAYOUT_DATA_LENGTH) break;
|
|
if(char_index >= TOTP_KB_LAYOUT_DATA_LENGTH) break;
|
|
|
|
|
|
|
|
uint16_t hid_kb_key = keyboard_layout_dict[char_index];
|
|
uint16_t hid_kb_key = keyboard_layout_dict[char_index];
|
|
|
- totp_type_code_worker_press_key(hid_kb_key, key_press_fn, key_release_fn, features);
|
|
|
|
|
- furi_delay_ms(keystroke_delay);
|
|
|
|
|
- i++;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if(features & TokenAutomationFeatureEnterAtTheEnd) {
|
|
|
|
|
- furi_delay_ms(keystroke_delay);
|
|
|
|
|
totp_type_code_worker_press_key(
|
|
totp_type_code_worker_press_key(
|
|
|
- HID_KEYBOARD_RETURN, key_press_fn, key_release_fn, features);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if(features & TokenAutomationFeatureTabAtTheEnd) {
|
|
|
|
|
- furi_delay_ms(keystroke_delay);
|
|
|
|
|
- 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);
|
|
|
|
|
|
|
+ hid_kb_key, key_press_fn, key_release_fn, features, context);
|
|
|
furi_delay_ms(keystroke_delay);
|
|
furi_delay_ms(keystroke_delay);
|
|
|
i++;
|
|
i++;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(features & TokenAutomationFeatureEnterAtTheEnd) {
|
|
if(features & TokenAutomationFeatureEnterAtTheEnd) {
|
|
|
furi_delay_ms(keystroke_delay);
|
|
furi_delay_ms(keystroke_delay);
|
|
|
- totp_type_code_worker_press_key_ctx(
|
|
|
|
|
- HID_KEYBOARD_RETURN, key_press_fn, key_release_fn, ctx, features);
|
|
|
|
|
|
|
+ totp_type_code_worker_press_key(
|
|
|
|
|
+ HID_KEYBOARD_RETURN, key_press_fn, key_release_fn, features, context);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(features & TokenAutomationFeatureTabAtTheEnd) {
|
|
if(features & TokenAutomationFeatureTabAtTheEnd) {
|
|
|
furi_delay_ms(keystroke_delay);
|
|
furi_delay_ms(keystroke_delay);
|
|
|
- totp_type_code_worker_press_key_ctx(
|
|
|
|
|
- HID_KEYBOARD_TAB, key_press_fn, key_release_fn, ctx, features);
|
|
|
|
|
|
|
+ totp_type_code_worker_press_key(
|
|
|
|
|
+ HID_KEYBOARD_TAB, key_press_fn, key_release_fn, features, context);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|