@@ -277,6 +277,7 @@ void home_to_date_time_Switch1_wired_feedback(
277277 );
278278 if (ret < 0 ){ // failed to detect "System" being highlighted. press home and re-try
279279 pbf_press_button (context, BUTTON_HOME, 100ms, 2000ms);
280+ stream.log (" home_to_date_time_Switch1_wired_feedback: Failed to detect 'System' being highlighted. Re-try" , COLOR_YELLOW);
280281 continue ;
281282 }
282283
@@ -322,11 +323,13 @@ void home_to_date_time_Switch1_wired_feedback(
322323 );
323324 if (ret < 0 ){ // failed to detect "Synchronize clock" being highlighted. press home and re-try
324325 pbf_press_button (context, BUTTON_HOME, 100ms, 2000ms);
326+ stream.log (" home_to_date_time_Switch1_wired_feedback: Failed to detect 'Synchronize clock' being highlighted. Re-try" , COLOR_YELLOW);
325327 continue ;
326328 }
327329
328330
329331 if (!to_date_change){
332+ stream.log (" Arrived at Date and Time." , COLOR_ORANGE);
330333 return ;
331334 }
332335
@@ -346,7 +349,7 @@ void home_to_date_time_Switch1_wired_feedback(
346349 // Left scroll in case we missed landed in the language change or sleep
347350 // confirmation menus.
348351 ssf_issue_scroll (context, SSF_SCROLL_LEFT, 0ms);
349-
352+ stream. log ( " Arrived at Date and Time, date change. " , COLOR_ORANGE);
350353 return ;
351354 }
352355
@@ -358,7 +361,131 @@ void home_to_date_time_Switch1_wired_feedback(
358361
359362}
360363
364+ void home_to_date_time_Switch1_wireless_esp32_feedback (
365+ VideoStream& stream, ProControllerContext& context, bool to_date_change
366+ ){
367+ stream.log (" home_to_date_time_Switch1_wireless_esp32_feedback()" );
368+
369+ size_t max_attempts = 5 ;
370+ for (size_t i = 0 ; i < max_attempts; i++){
371+ ThrottleScope scope (context->logging_throttler ());
372+ if (scope){
373+ context->logger ().log (" NintendoSwitch::home_to_date_time_Switch1_wireless_esp32_feedback()" );
374+ }
375+
376+ Milliseconds tv = context->timing_variation ();
377+ Milliseconds unit = 24ms + tv;
378+
379+ ssf_issue_scroll (context, SSF_SCROLL_RIGHT, unit);
380+ ssf_issue_scroll (context, SSF_SCROLL_RIGHT, unit);
381+ ssf_issue_scroll (context, SSF_SCROLL_RIGHT, unit);
382+
383+ // Down twice in case we drop one.
384+ ssf_issue_scroll (context, SSF_SCROLL_DOWN, unit);
385+ ssf_issue_scroll (context, SSF_SCROLL_DOWN, unit);
386+
387+ ssf_issue_scroll (context, SSF_SCROLL_LEFT, 0ms, 2 *unit, unit);
388+
389+ // Two A presses in case we drop the 1st one.
390+ // the program can self recover even if the second button press is registered.
391+ pbf_press_button (context, BUTTON_A, 2 *unit, unit);
392+ pbf_press_button (context, BUTTON_A, 2 *unit, unit);
393+
394+ // Just button mash it. lol
395+ {
396+ auto iterations = Milliseconds (1100 ) / unit + 1 ;
397+ do {
398+ ssf_issue_scroll (context, SSF_SCROLL_DOWN, unit);
399+ }while (--iterations);
400+ }
401+
402+ context.wait_for_all_requests ();
403+ // Should now be in System Settings, with System highlighted
404+ ImageFloatBox system_setting_box (0.056 , 0.74 , 0.01 , 0.1 );
405+ ImageFloatBox other_setting1 (0.04 , 0.74 , 0.01 , 0.1 );
406+ ImageFloatBox other_setting2 (0.02 , 0.74 , 0.01 , 0.1 );
407+ SelectedSettingWatcher system_setting_selected (system_setting_box, other_setting1, other_setting2);
408+ int ret = run_until<ProControllerContext>(
409+ stream, context,
410+ [](ProControllerContext& context){
411+ for (int i = 0 ; i < 10 ; i++){
412+ ssf_issue_scroll (context, SSF_SCROLL_DOWN, 24ms);
413+ }
414+ },
415+ {system_setting_selected}
416+ );
417+ if (ret < 0 ){ // failed to detect "System" being highlighted. press home and re-try
418+ pbf_press_button (context, BUTTON_HOME, 100ms, 2000ms);
419+ stream.log (" home_to_date_time_Switch1_wireless_esp32_feedback: Failed to detect 'System' being highlighted. Re-try" , COLOR_YELLOW);
420+ continue ;
421+ }
361422
423+ {
424+ auto iterations = Milliseconds (312 ) / unit + 1 ;
425+ do {
426+ ssf_issue_scroll (context, SSF_SCROLL_RIGHT, unit);
427+ }while (--iterations);
428+ }
429+
430+ ssf_issue_scroll (context, SSF_SCROLL_DOWN, unit);
431+ ssf_issue_scroll (context, SSF_SCROLL_DOWN, unit);
432+ ssf_issue_scroll (context, SSF_SCROLL_DOWN, 400ms, 2 *unit, unit);
433+ ssf_press_dpad (context, DPAD_DOWN, 360ms, 304ms);
434+ ssf_issue_scroll (context, SSF_SCROLL_DOWN, unit);
435+ // if (i > 1){ // intentionally create a failure, for testing
436+ ssf_issue_scroll (context, SSF_SCROLL_DOWN, unit);
437+ // }
438+
439+ // only one ButtonA press since the program can self-recover if the button is dropped.
440+ // furthermore, the program can't self-recover if a second button press is registered.
441+ ssf_press_button (context, BUTTON_A, 24ms, 48ms, 24ms);
442+
443+ context.wait_for_all_requests ();
444+ context.wait_for (Milliseconds (300 ));
445+ // we expect to be within "Date and Time", with "Synchronize Clock via Internet" being highlighted
446+ ImageFloatBox sync_clock_box (0.168 , 0.185 , 0.01 , 0.1 );
447+ ImageFloatBox other_setting3 (0.1 , 0.185 , 0.01 , 0.1 );
448+ ImageFloatBox other_setting4 (0.05 , 0.185 , 0.01 , 0.1 );
449+ SelectedSettingWatcher sync_clock_selected (sync_clock_box, other_setting3, other_setting4);
450+ ret = wait_until (
451+ stream, context,
452+ Milliseconds (2000 ),
453+ {sync_clock_selected}
454+ );
455+ if (ret < 0 ){ // failed to detect "Synchronize clock" being highlighted. press home and re-try
456+ pbf_press_button (context, BUTTON_HOME, 100ms, 2000ms);
457+ stream.log (" home_to_date_time_Switch1_wireless_esp32_feedback: Failed to detect 'Synchronize clock' being highlighted. Re-try" , COLOR_YELLOW);
458+ continue ;
459+ }
460+
461+
462+ if (!to_date_change){
463+ stream.log (" Arrived at Date and Time." , COLOR_ORANGE);
464+ return ;
465+ }
466+
467+
468+ {
469+ auto iterations = Milliseconds (250 ) / unit + 1 ;
470+ do {
471+ ssf_issue_scroll (context, SSF_SCROLL_DOWN, unit);
472+ }while (--iterations);
473+ }
474+
475+ // Left scroll in case we missed landed in the language change or sleep
476+ // confirmation menus.
477+ ssf_issue_scroll (context, SSF_SCROLL_LEFT, 0ms, 2 *unit, unit);
478+ stream.log (" Arrived at Date and Time, date change." , COLOR_ORANGE);
479+ return ;
480+ }
481+
482+ OperationFailedException::fire (
483+ ErrorReport::SEND_ERROR_REPORT,
484+ " home_to_date_time(): Failed to reach Date and Time after several attempts." ,
485+ stream
486+ );
487+
488+ }
362489
363490
364491
0 commit comments