From dbb0408f9961e6ca37e0b968e5beea1119a1b8a3 Mon Sep 17 00:00:00 2001 From: oldip Date: Mon, 18 Mar 2024 21:56:56 +0800 Subject: [PATCH] Construct the numpad key name --- applications/system/js_app/modules/js_badusb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/applications/system/js_app/modules/js_badusb.c b/applications/system/js_app/modules/js_badusb.c index 1064d9c3c..307e0bb13 100644 --- a/applications/system/js_app/modules/js_badusb.c +++ b/applications/system/js_app/modules/js_badusb.c @@ -406,8 +406,12 @@ static bool ducky_altchar(struct mjs* mjs, const char* ascii_code) { // Loop through each digit of the ASCII code and press the corresponding numpad key for(size_t i = 0; ascii_code[i] != '\0'; i++) { - char digit = ascii_code[i] - '0'; // Convert char to digit - uint16_t numpad_keycode = get_keycode_by_digit(digit); + char digitChar[5] = {'N', 'U', 'M', ascii_code[i], '\0'}; // Construct the numpad key name + uint16_t numpad_keycode = get_keycode_by_name(digitChar, strlen(digitChar)); + if(numpad_keycode == HID_KEYBOARD_NONE) { + // Handle error or unsupported keycode + continue; + } furi_hal_hid_kb_press(numpad_keycode); js_delay_with_flags(mjs, 200); furi_hal_hid_kb_release(numpad_keycode);