Skip to content

Commit

Permalink
Update ducky_script_commands.c
Browse files Browse the repository at this point in the history
  • Loading branch information
zricote authored Mar 18, 2024
1 parent 3a566a1 commit 0a50303
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion applications/main/bad_usb/helpers/ducky_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,25 @@ static int32_t ducky_fnc_strdelay(BadUsbScript* bad_usb, const char* line, int32
return 0;
}

static int32_t ducky_fnc_defstrdelay(BadUsbScript* bad_usb, const char* line, int32_t param) {
UNUSED(param);

line = &line[ducky_get_command_len(line) + 1];
bool state = ducky_get_number(line, &bad_usb->defstringdelay);
if(!state) {
return ducky_error(bad_usb, "Invalid number %s", line);
}
return 0;
}

static int32_t ducky_fnc_string(BadUsbScript* bad_usb, const char* line, int32_t param) {
line = &line[ducky_get_command_len(line) + 1];
furi_string_set_str(bad_usb->string_print, line);
if(param == 1) {
furi_string_cat(bad_usb->string_print, "\n");
}

if(bad_usb->stringdelay == 0) { // stringdelay not set - run command immediately
if(bad_usb->stringdelay == 0 && bad_usb->defstringdelay == 0) { // stringdelay not set - run command immediately
bool state = ducky_string(bad_usb, furi_string_get_cstr(bad_usb->string_print));
if(!state) {
return ducky_error(bad_usb, "Invalid string %s", line);
Expand Down Expand Up @@ -161,6 +172,8 @@ static const DuckyCmd ducky_commands[] = {
{"DEFAULTDELAY", ducky_fnc_defdelay, -1},
{"STRINGDELAY", ducky_fnc_strdelay, -1},
{"STRING_DELAY", ducky_fnc_strdelay, -1},
{"DEFAULT_STRING_DELAY", ducky_fnc_defstrdelay, -1},
{"DEFAULTSTRINGDELAY", ducky_fnc_defstrdelay, -1},
{"REPEAT", ducky_fnc_repeat, -1},
{"SYSRQ", ducky_fnc_sysrq, -1},
{"ALTCHAR", ducky_fnc_altchar, -1},
Expand Down

0 comments on commit 0a50303

Please sign in to comment.