From 44cc76f2f3f0fe3a98e99b37a026fb47080084a9 Mon Sep 17 00:00:00 2001 From: jw098 Date: Fri, 1 Aug 2025 23:32:31 -0700 Subject: [PATCH 1/3] add feedback to esp32 home to datetime routine --- .../NintendoSwitch1_HomeToDateTime.cpp | 129 +++++++++++++++++- .../NintendoSwitch_HomeToDateTime.cpp | 5 +- .../DateSpam/NintendoSwitch_HomeToDateTime.h | 3 + 3 files changed, 135 insertions(+), 2 deletions(-) diff --git a/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch1_HomeToDateTime.cpp b/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch1_HomeToDateTime.cpp index 2722d37433..e102340474 100644 --- a/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch1_HomeToDateTime.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch1_HomeToDateTime.cpp @@ -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; } @@ -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; } @@ -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; } @@ -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( + stream, context, + [](ProControllerContext& context){ + for (int i = 0; i < 10; i++){ + ssf_issue_scroll(context, SSF_SCROLL_DOWN, 24ms); + } + }, + {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, 24ms, 48ms, 24ms); + + 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 + ); + +} diff --git a/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch_HomeToDateTime.cpp b/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch_HomeToDateTime.cpp index 382e20e84f..94ae639523 100644 --- a/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch_HomeToDateTime.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch_HomeToDateTime.cpp @@ -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; } } diff --git a/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch_HomeToDateTime.h b/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch_HomeToDateTime.h index 1716a638f3..6dc9d870a9 100644 --- a/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch_HomeToDateTime.h +++ b/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch_HomeToDateTime.h @@ -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 +); From 6349e253cb20677725020d4a50b161df1a090349 Mon Sep 17 00:00:00 2001 From: jw098 Date: Fri, 1 Aug 2025 23:51:25 -0700 Subject: [PATCH 2/3] update timings --- .../Programs/DateSpam/NintendoSwitch1_HomeToDateTime.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch1_HomeToDateTime.cpp b/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch1_HomeToDateTime.cpp index e102340474..970314dea5 100644 --- a/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch1_HomeToDateTime.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch1_HomeToDateTime.cpp @@ -409,7 +409,7 @@ void home_to_date_time_Switch1_wireless_esp32_feedback( stream, context, [](ProControllerContext& context){ for (int i = 0; i < 10; i++){ - ssf_issue_scroll(context, SSF_SCROLL_DOWN, 24ms); + ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit); } }, {system_setting_selected} @@ -438,7 +438,7 @@ void home_to_date_time_Switch1_wireless_esp32_feedback( // 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, 24ms, 48ms, 24ms); + ssf_press_button(context, BUTTON_A, 360ms, 2*unit, unit); context.wait_for_all_requests(); context.wait_for(Milliseconds(300)); From e63c3fb75d798fbe4d2d57567b1be4b443a4ed9e Mon Sep 17 00:00:00 2001 From: jw098 Date: Sat, 2 Aug 2025 00:14:27 -0700 Subject: [PATCH 3/3] fix build --- .../Programs/DateSpam/NintendoSwitch1_HomeToDateTime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch1_HomeToDateTime.cpp b/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch1_HomeToDateTime.cpp index 970314dea5..593143555f 100644 --- a/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch1_HomeToDateTime.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch1_HomeToDateTime.cpp @@ -407,7 +407,7 @@ void home_to_date_time_Switch1_wireless_esp32_feedback( SelectedSettingWatcher system_setting_selected(system_setting_box, other_setting1, other_setting2); int ret = run_until( stream, context, - [](ProControllerContext& context){ + [&](ProControllerContext& context){ for (int i = 0; i < 10; i++){ ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit); }