Skip to content

Commit 5b30c01

Browse files
committed
Make the new date-spam less likely to sleep the Switch if it drops the left press.
1 parent 06cea40 commit 5b30c01

File tree

2 files changed

+59
-15
lines changed

2 files changed

+59
-15
lines changed

SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_Navigation.cpp

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ void home_to_date_time(ProControllerContext& context, bool to_date_change, bool
3838
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 24ms);
3939
}while (--iterations);
4040
}
41+
42+
// Scroll left and press A to exit the sleep menu if we happened to
43+
// land there.
44+
ssf_issue_scroll(context, SSF_SCROLL_LEFT, 3);
45+
ssf_press_button(context, BUTTON_A, 3);
46+
4147
{
42-
auto iterations = Milliseconds(336) / 24ms + 1;
48+
auto iterations = Milliseconds(312) / 24ms + 1;
4349
do{
4450
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, 24ms);
4551
}while (--iterations);
@@ -59,12 +65,17 @@ void home_to_date_time(ProControllerContext& context, bool to_date_change, bool
5965

6066
ssf_press_button(context, BUTTON_A, 3);
6167
{
62-
auto iterations = Milliseconds(216) / 24ms + 1;
68+
auto iterations = Milliseconds(240) / 24ms + 1;
6369
do{
6470
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 24ms);
6571
}while (--iterations);
6672
}
67-
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 0);
73+
// ssf_issue_scroll(context, SSF_SCROLL_DOWN, 0);
74+
75+
// Left scroll in case we missed landed in the language change or sleep
76+
// confirmation menus.
77+
ssf_issue_scroll(context, SSF_SCROLL_LEFT, 0ms);
78+
6879
break;
6980
}
7081
case ControllerPerformanceClass::SerialPABotBase_Wireless_ESP32:{
@@ -93,8 +104,14 @@ void home_to_date_time(ProControllerContext& context, bool to_date_change, bool
93104
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
94105
}while (--iterations);
95106
}
107+
108+
// Scroll left and press A to exit the sleep menu if we happened to
109+
// land there.
110+
ssf_issue_scroll(context, SSF_SCROLL_LEFT, unit);
111+
ssf_press_button(context, BUTTON_A, unit, 2*unit, unit);
112+
96113
{
97-
auto iterations = Milliseconds(336) / unit + 1;
114+
auto iterations = Milliseconds(312) / unit + 1;
98115
do{
99116
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, unit);
100117
}while (--iterations);
@@ -108,6 +125,8 @@ void home_to_date_time(ProControllerContext& context, bool to_date_change, bool
108125
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
109126

110127
if (!to_date_change){
128+
// Double up this A press in case one is dropped.
129+
ssf_press_button(context, BUTTON_A, unit);
111130
ssf_press_button(context, BUTTON_A, 360ms, 2*unit, unit);
112131
return;
113132
}
@@ -122,8 +141,8 @@ void home_to_date_time(ProControllerContext& context, bool to_date_change, bool
122141
}while (--iterations);
123142
}
124143

125-
// Left scroll in case we missed the date menu and landed in the
126-
// language change.
144+
// Left scroll in case we missed landed in the language change or sleep
145+
// confirmation menus.
127146
ssf_issue_scroll(context, SSF_SCROLL_LEFT, 0ms, 2*unit, unit);
128147

129148
break;

SerialPrograms/Source/PokemonSwSh/Commands/PokemonSwSh_Commands_DateSpam.cpp

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,27 +152,47 @@ void roll_date_backward_N(ProControllerContext& context, uint8_t skips, bool fas
152152
return;
153153
}
154154

155+
// We can no longer use A to scroll right since that may put the
156+
// Switch to sleep if we landed on the sleep confirmation menu.
157+
158+
155159
switch (context->performance_class()){
156160
case ControllerPerformanceClass::SerialPABotBase_Wired_125Hz:{
157161
uint8_t scroll_delay = fast ? 3 : 4;
158162
uint8_t up_delay = 3;
159-
160163
ssf_press_button(context, BUTTON_A, 20, 10);
161164
for (uint8_t c = 0; c < skips - 1; c++){
162165
ssf_issue_scroll(context, SSF_SCROLL_DOWN, up_delay);
163166
}
167+
#if 0
164168
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 0);
165-
ssf_press_button(context, BUTTON_A, up_delay);
166-
// ssf_issue_scroll(context, SSF_SCROLL_RIGHT, delay);
169+
// ssf_press_button(context, BUTTON_A, up_delay);
170+
#else
171+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, up_delay);
172+
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, scroll_delay);
173+
#endif
167174
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, scroll_delay);
168175
for (uint8_t c = 0; c < skips - 1; c++){
169176
ssf_issue_scroll(context, SSF_SCROLL_DOWN, up_delay);
170177
}
178+
#if 0
171179
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 0);
172180
ssf_press_button(context, BUTTON_A, up_delay);
181+
#else
182+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, up_delay);
173183
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, scroll_delay);
184+
#endif
174185
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, scroll_delay);
175-
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, 0);
186+
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, scroll_delay);
187+
188+
#if 0
189+
// ssf_issue_scroll(context, SSF_SCROLL_RIGHT, 0);
190+
#else
191+
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, scroll_delay);
192+
ssf_issue_scroll(context, SSF_SCROLL_LEFT, scroll_delay);
193+
ssf_press_button(context, BUTTON_A);
194+
#endif
195+
176196
ssf_press_button(context, BUTTON_A, 20, 10);
177197
break;
178198
}
@@ -186,19 +206,24 @@ void roll_date_backward_N(ProControllerContext& context, uint8_t skips, bool fas
186206
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
187207
}
188208

189-
// Left scroll in case we missed the date menu and landed in the
190-
// language change.
191-
ssf_issue_scroll(context, SSF_SCROLL_LEFT, unit);
192-
209+
#if 0
193210
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 0ms, 2*unit, unit);
194211
ssf_press_button(context, BUTTON_A, unit);
195-
// ssf_issue_scroll(context, SSF_SCROLL_RIGHT, unit);
212+
#else
213+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
214+
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, unit);
215+
#endif
196216
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, unit);
197217
for (uint8_t c = 0; c < skips - 1; c++){
198218
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
199219
}
220+
#if 0
200221
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 0ms, 2*unit, unit);
201222
ssf_press_button(context, BUTTON_A, unit);
223+
#else
224+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
225+
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, unit);
226+
#endif
202227
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, unit);
203228
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, unit);
204229
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, 0ms, 2*unit, unit);

0 commit comments

Comments
 (0)