|
5 | 5 | */ |
6 | 6 |
|
7 | 7 | #include "Controllers/ControllerTypes.h" |
| 8 | +#include "CommonFramework/Exceptions/OperationFailedException.h" |
8 | 9 | #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" |
9 | 10 | #include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h" |
10 | 11 | #include "CommonFramework/ImageTools/ImageStats.h" |
@@ -32,8 +33,8 @@ bool is_setting_selected(VideoStream& stream, ProControllerContext& context, Ima |
32 | 33 | overlays.add(COLOR_RED, selected_box); |
33 | 34 | overlays.add(COLOR_BLUE, unselected_box1); |
34 | 35 | overlays.add(COLOR_BLUE, unselected_box2); |
35 | | - context.wait_for(Milliseconds(100)); |
36 | 36 | context.wait_for_all_requests(); |
| 37 | + context.wait_for(Milliseconds(250)); |
37 | 38 | VideoSnapshot snapshot = stream.video().snapshot(); |
38 | 39 |
|
39 | 40 | ImageStats stats_unselected_box1 = image_stats(extract_box_reference(snapshot, unselected_box1)); |
@@ -72,7 +73,31 @@ void home_to_date_time(VideoStream& stream, ProControllerContext& context, bool |
72 | 73 |
|
73 | 74 | ssf_issue_scroll(context, SSF_SCROLL_LEFT, 0); |
74 | 75 |
|
| 76 | + // we expect to be at Settings icon |
| 77 | + ImageFloatBox system_settings(0.685, 0.69, 0.05, 0.03); |
| 78 | + ImageFloatBox other_setting1(0.615, 0.69, 0.05, 0.03); |
| 79 | + ImageFloatBox other_setting2(0.545, 0.69, 0.05, 0.03); |
| 80 | + if (!is_setting_selected(stream, context, system_settings, other_setting1, other_setting2)){ |
| 81 | + // not at Settings Icon |
| 82 | + // mash down, mash right. then left one |
| 83 | + size_t iterations = Milliseconds(1200) / 24ms + 1; |
| 84 | + for (size_t i = 0; i < iterations; i++){ |
| 85 | + ssf_issue_scroll(context, SSF_SCROLL_DOWN, 24ms); |
| 86 | + } |
75 | 87 |
|
| 88 | + for (size_t i = 0; i < iterations; i++){ |
| 89 | + ssf_issue_scroll(context, SSF_SCROLL_RIGHT, 24ms); |
| 90 | + } |
| 91 | + ssf_issue_scroll(context, SSF_SCROLL_LEFT, 0); |
| 92 | + |
| 93 | + if (!is_setting_selected(stream, context, system_settings, other_setting1, other_setting2)){ |
| 94 | + OperationFailedException::fire( |
| 95 | + ErrorReport::SEND_ERROR_REPORT, |
| 96 | + "home_to_date_time(): Failed to reach settings gear on Home page after 2 attempts.", |
| 97 | + stream |
| 98 | + ); |
| 99 | + } |
| 100 | + } |
76 | 101 |
|
77 | 102 | // Two A presses in case we drop the 1st one. |
78 | 103 | ssf_press_button(context, BUTTON_A, 3); |
@@ -105,18 +130,51 @@ void home_to_date_time(VideoStream& stream, ProControllerContext& context, bool |
105 | 130 | ssf_issue_scroll(context, SSF_SCROLL_DOWN, 3); |
106 | 131 | ssf_issue_scroll(context, SSF_SCROLL_DOWN, 3); |
107 | 132 |
|
108 | | - if (!to_date_change){ |
109 | | - // Triple up this A press to make sure it gets through. |
| 133 | + |
| 134 | + // double up this A press to make sure it gets through. |
| 135 | + ssf_press_button(context, BUTTON_A, 3); |
| 136 | + ssf_press_button(context, BUTTON_A, 3); |
| 137 | + |
| 138 | + context.wait_for_all_requests(); |
| 139 | + // we expect to be within "Date and Time", with "Synchronize Clock via Internet" being highlighted |
| 140 | + ImageFloatBox sync_clock(0.168, 0.185, 0.01, 0.1); |
| 141 | + ImageFloatBox other_setting3(0.1, 0.185, 0.01, 0.1); |
| 142 | + ImageFloatBox other_setting4(0.05, 0.185, 0.01, 0.1); |
| 143 | + if (!is_setting_selected(stream, context, sync_clock, other_setting3, other_setting4)){ |
| 144 | + // press B once, then mash Up. then try again to scroll down to Date and Time |
| 145 | + pbf_press_button(context, BUTTON_B, 100ms, 100ms); |
| 146 | + pbf_move_left_joystick(context, 128, 0, 3000ms, 100ms); |
| 147 | + |
| 148 | + size_t iterations = Milliseconds(1200) / 24ms + 1; |
| 149 | + for (size_t i = 0; i < iterations; i++){ |
| 150 | + ssf_issue_scroll(context, SSF_SCROLL_UP, 24ms); |
| 151 | + } |
| 152 | + |
| 153 | + ssf_issue_scroll(context, SSF_SCROLL_DOWN, 3); |
| 154 | + ssf_issue_scroll(context, SSF_SCROLL_DOWN, 3); |
| 155 | + ssf_issue_scroll(context, SSF_SCROLL_DOWN, 10); |
| 156 | + ssf_press_dpad(context, DPAD_DOWN, 45, 40); |
| 157 | + ssf_issue_scroll(context, SSF_SCROLL_DOWN, 3); |
| 158 | + ssf_issue_scroll(context, SSF_SCROLL_DOWN, 3); |
| 159 | + |
| 160 | + // double up this A press to make sure it gets through. |
110 | 161 | ssf_press_button(context, BUTTON_A, 3); |
111 | 162 | ssf_press_button(context, BUTTON_A, 3); |
112 | | - ssf_press_button(context, BUTTON_A, 45); |
| 163 | + |
| 164 | + if (!is_setting_selected(stream, context, sync_clock, other_setting3, other_setting4)){ |
| 165 | + OperationFailedException::fire( |
| 166 | + ErrorReport::SEND_ERROR_REPORT, |
| 167 | + "home_to_date_time(): Failed to reach settings gear on Home page after 2 attempts.", |
| 168 | + stream |
| 169 | + ); |
| 170 | + } |
| 171 | + |
| 172 | + } |
| 173 | + |
| 174 | + if (!to_date_change){ |
113 | 175 | return; |
114 | 176 | } |
115 | 177 |
|
116 | | - // Triple up this A press to make sure it gets through. |
117 | | - ssf_press_button(context, BUTTON_A, 3); |
118 | | - ssf_press_button(context, BUTTON_A, 3); |
119 | | - ssf_press_button(context, BUTTON_A, 3); |
120 | 178 | { |
121 | 179 | auto iterations = Milliseconds(250) / 24ms + 1; |
122 | 180 | do{ |
|
0 commit comments