Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ void home_to_date_time_Switch1_wired_feedback(
);
if (ret < 0){ // failed to detect "System" being highlighted. press home and re-try
pbf_press_button(context, BUTTON_HOME, 100ms, 2000ms);
stream.log("home_to_date_time_Switch1_wired_feedback: Failed to detect 'System' being highlighted. Re-try", COLOR_YELLOW);
continue;
}

Expand Down Expand Up @@ -322,11 +323,13 @@ void home_to_date_time_Switch1_wired_feedback(
);
if (ret < 0){ // failed to detect "Synchronize clock" being highlighted. press home and re-try
pbf_press_button(context, BUTTON_HOME, 100ms, 2000ms);
stream.log("home_to_date_time_Switch1_wired_feedback: Failed to detect 'Synchronize clock' being highlighted. Re-try", COLOR_YELLOW);
continue;
}


if (!to_date_change){
stream.log("Arrived at Date and Time.", COLOR_ORANGE);
return;
}

Expand All @@ -346,7 +349,7 @@ void home_to_date_time_Switch1_wired_feedback(
// Left scroll in case we missed landed in the language change or sleep
// confirmation menus.
ssf_issue_scroll(context, SSF_SCROLL_LEFT, 0ms);

stream.log("Arrived at Date and Time, date change.", COLOR_ORANGE);
return;
}

Expand All @@ -358,7 +361,131 @@ void home_to_date_time_Switch1_wired_feedback(

}

void home_to_date_time_Switch1_wireless_esp32_feedback(
VideoStream& stream, ProControllerContext& context, bool to_date_change
){
stream.log("home_to_date_time_Switch1_wireless_esp32_feedback()");

size_t max_attempts = 5;
for (size_t i = 0; i < max_attempts; i++){
ThrottleScope scope(context->logging_throttler());
if (scope){
context->logger().log("NintendoSwitch::home_to_date_time_Switch1_wireless_esp32_feedback()");
}

Milliseconds tv = context->timing_variation();
Milliseconds unit = 24ms + tv;

ssf_issue_scroll(context, SSF_SCROLL_RIGHT, unit);
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, unit);
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, unit);

// Down twice in case we drop one.
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);

ssf_issue_scroll(context, SSF_SCROLL_LEFT, 0ms, 2*unit, unit);

// Two A presses in case we drop the 1st one.
// the program can self recover even if the second button press is registered.
pbf_press_button(context, BUTTON_A, 2*unit, unit);
pbf_press_button(context, BUTTON_A, 2*unit, unit);

// Just button mash it. lol
{
auto iterations = Milliseconds(1100) / unit + 1;
do{
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
}while (--iterations);
}

context.wait_for_all_requests();
// Should now be in System Settings, with System highlighted
ImageFloatBox system_setting_box(0.056, 0.74, 0.01, 0.1);
ImageFloatBox other_setting1(0.04, 0.74, 0.01, 0.1);
ImageFloatBox other_setting2(0.02, 0.74, 0.01, 0.1);
SelectedSettingWatcher system_setting_selected(system_setting_box, other_setting1, other_setting2);
int ret = run_until<ProControllerContext>(
stream, context,
[&](ProControllerContext& context){
for (int i = 0; i < 10; i++){
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
}
},
{system_setting_selected}
);
if (ret < 0){ // failed to detect "System" being highlighted. press home and re-try
pbf_press_button(context, BUTTON_HOME, 100ms, 2000ms);
stream.log("home_to_date_time_Switch1_wireless_esp32_feedback: Failed to detect 'System' being highlighted. Re-try", COLOR_YELLOW);
continue;
}

{
auto iterations = Milliseconds(312) / unit + 1;
do{
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, unit);
}while (--iterations);
}

ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 400ms, 2*unit, unit);
ssf_press_dpad(context, DPAD_DOWN, 360ms, 304ms);
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
// if (i > 1){ // intentionally create a failure, for testing
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
// }

// only one ButtonA press since the program can self-recover if the button is dropped.
// furthermore, the program can't self-recover if a second button press is registered.
ssf_press_button(context, BUTTON_A, 360ms, 2*unit, unit);

context.wait_for_all_requests();
context.wait_for(Milliseconds(300));
// we expect to be within "Date and Time", with "Synchronize Clock via Internet" being highlighted
ImageFloatBox sync_clock_box(0.168, 0.185, 0.01, 0.1);
ImageFloatBox other_setting3(0.1, 0.185, 0.01, 0.1);
ImageFloatBox other_setting4(0.05, 0.185, 0.01, 0.1);
SelectedSettingWatcher sync_clock_selected(sync_clock_box, other_setting3, other_setting4);
ret = wait_until(
stream, context,
Milliseconds(2000),
{sync_clock_selected}
);
if (ret < 0){ // failed to detect "Synchronize clock" being highlighted. press home and re-try
pbf_press_button(context, BUTTON_HOME, 100ms, 2000ms);
stream.log("home_to_date_time_Switch1_wireless_esp32_feedback: Failed to detect 'Synchronize clock' being highlighted. Re-try", COLOR_YELLOW);
continue;
}


if (!to_date_change){
stream.log("Arrived at Date and Time.", COLOR_ORANGE);
return;
}


{
auto iterations = Milliseconds(250) / unit + 1;
do{
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
}while (--iterations);
}

// Left scroll in case we missed landed in the language change or sleep
// confirmation menus.
ssf_issue_scroll(context, SSF_SCROLL_LEFT, 0ms, 2*unit, unit);
stream.log("Arrived at Date and Time, date change.", COLOR_ORANGE);
return;
}

OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"home_to_date_time(): Failed to reach Date and Time after several attempts.",
stream
);

}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ bool home_to_date_time_Switch1_feedback(ConsoleHandle& console, ProControllerCon
case ControllerPerformanceClass::SerialPABotBase_Wired:
home_to_date_time_Switch1_wired_feedback(console, context, to_date_change);
return true;
default:;
case ControllerPerformanceClass::SerialPABotBase_Wireless:
home_to_date_time_Switch1_wireless_esp32_feedback(console, context, to_date_change);
return true;
default:
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ void home_to_date_time_Switch1_sbb_blind(
void home_to_date_time_Switch1_wired_feedback(
VideoStream& stream, ProControllerContext& context, bool to_date_change
);
void home_to_date_time_Switch1_wireless_esp32_feedback(
VideoStream& stream, ProControllerContext& context, bool to_date_change
);



Expand Down