Skip to content

Commit 9a1f3a1

Browse files
authored
Merge pull request #579 from PokemonAutomation/DPP-ClickDuration
Add duration to DPP button commands.
2 parents 65d905a + 37fa968 commit 9a1f3a1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

SerialPrograms/Source/Integrations/DppIntegration/DppCommandHandler.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ void Handler::create_unified_commands(commandhandler& handler){
376376
{"15", "DDOWN"},
377377
{"16", "DLEFT"},
378378
{"17", "DRIGHT"},}
379-
)}
379+
)},
380+
{"ticks", param_info(pt_integer, false, "How long to hold the button for, in ticks.")},
380381
},
381382
[&handler, this](const std::string& command, const parameter_list_t& params, command_source src){
382383
log_dpp("Executing " + command + "...", "Unified Command Handler", ll_info);
@@ -389,7 +390,7 @@ void Handler::create_unified_commands(commandhandler& handler){
389390
embed embed;
390391
embed.set_color((uint32_t)color).set_title("Command Response");
391392

392-
if (params.size() < 2){
393+
if (params.size() < 3){
393394
embed.set_description("Missing command arguments.");
394395
message.add_embed(embed);
395396
handler.reply(message, src);
@@ -401,6 +402,7 @@ void Handler::create_unified_commands(commandhandler& handler){
401402

402403
std::string name = "None";
403404
int64_t button = Utility::get_value_from_input(handler, command, button_input, name);
405+
int64_t ticks = Utility::sanitize_integer_input(params, 2);
404406

405407
if (button < 0){
406408
embed.set_description("No such button found: " + button_input);
@@ -411,9 +413,9 @@ void Handler::create_unified_commands(commandhandler& handler){
411413

412414
std::string response;
413415
if (button > 13){
414-
response = Integration::press_dpad(id, Utility::get_button(button), 50);
416+
response = Integration::press_dpad(id, Utility::get_button(button), ticks);
415417
}else{
416-
response = Integration::press_button(id, Utility::get_button(button), 50);
418+
response = Integration::press_button(id, Utility::get_button(button), ticks);
417419
}
418420

419421
if (!response.empty()){

0 commit comments

Comments
 (0)