Skip to content

Commit 8cb7496

Browse files
committed
Add some ESP32 wireless paths for Switch 2.
1 parent d0dd14d commit 8cb7496

File tree

4 files changed

+172
-3
lines changed

4 files changed

+172
-3
lines changed

SerialPrograms/Source/CommonFramework/Globals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace PokemonAutomation{
2626
const bool IS_BETA_VERSION = true;
2727
const int PROGRAM_VERSION_MAJOR = 0;
2828
const int PROGRAM_VERSION_MINOR = 54;
29-
const int PROGRAM_VERSION_PATCH = 21;
29+
const int PROGRAM_VERSION_PATCH = 22;
3030

3131
const std::string PROGRAM_VERSION_BASE =
3232
"v" + std::to_string(PROGRAM_VERSION_MAJOR) +

SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch2_HomeToDateTime.cpp

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,42 @@ void home_to_settings_Switch2_wired_blind(
5151
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, delay, hold, cool);
5252
}
5353
}
54+
void home_to_settings_Switch2_wireless_blind(
55+
ProControllerContext& context
56+
){
57+
Milliseconds tv = context->timing_variation();
58+
Milliseconds unit = 24ms + tv;
59+
60+
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, unit);
61+
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, unit);
62+
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, unit);
63+
64+
// Down twice in case we drop one.
65+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
66+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
67+
68+
ssf_issue_scroll(context, SSF_SCROLL_LEFT, unit);
69+
70+
// Two A presses in case we drop the 1st one.
71+
ssf_press_button(context, BUTTON_A, unit);
72+
ssf_press_button(context, BUTTON_A, unit);
73+
74+
for (size_t c = 0; c < 40; c++){
75+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
76+
}
77+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 1000ms, 1000ms, unit);
78+
79+
// Scroll left and press A to exit the sleep menu if we happened to
80+
// land there.
81+
ssf_issue_scroll(context, SSF_SCROLL_LEFT, unit);
82+
ssf_press_button(context, BUTTON_A, unit);
83+
84+
for (size_t c = 0; c < 2; c++){
85+
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, unit);
86+
}
87+
}
88+
89+
5490
void settings_to_date_time_Switch2_wired_blind(
5591
Logger& logger, ProControllerContext& context,
5692
ConsoleType console_type, bool to_date_change
@@ -112,6 +148,77 @@ void settings_to_date_time_Switch2_wired_blind(
112148
// confirmation menus.
113149
ssf_issue_scroll(context, SSF_SCROLL_LEFT, delay, hold, cool);
114150
}
151+
void settings_to_date_time_Switch2_wireless_blind(
152+
Logger& logger, ProControllerContext& context,
153+
ConsoleType console_type, bool to_date_change
154+
){
155+
Milliseconds tv = context->timing_variation();
156+
Milliseconds unit = 24ms + tv;
157+
158+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
159+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
160+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 192ms, 2*unit, unit);
161+
162+
163+
switch (console_type){
164+
case ConsoleType::Switch2_FW19_International:
165+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 128ms, 2*unit, unit);
166+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 128ms, 2*unit, unit);
167+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 128ms, 2*unit, unit);
168+
break;
169+
case ConsoleType::Switch2_FW19_JapanLocked:
170+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 128ms, 2*unit, unit);
171+
break;
172+
case ConsoleType::Switch2_FW20_International:
173+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 128ms, 2*unit, unit);
174+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 128ms, 2*unit, unit);
175+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 128ms, 2*unit, unit);
176+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 128ms, 2*unit, unit);
177+
break;
178+
case ConsoleType::Switch2_FW20_JapanLocked:
179+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 128ms, 2*unit, unit);
180+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 128ms, 2*unit, unit);
181+
break;
182+
default:
183+
throw UserSetupError(
184+
logger,
185+
"You need to specify a specific Switch 2 model."
186+
);
187+
}
188+
189+
190+
if (!to_date_change){
191+
// Triple up this A press to make sure it gets through.
192+
ssf_press_button(context, BUTTON_A, 24ms, 48ms, 24ms);
193+
ssf_press_button(context, BUTTON_A, 24ms, 48ms, 24ms);
194+
ssf_press_button(context, BUTTON_A, 360ms, 48ms, 24ms);
195+
return;
196+
}
197+
198+
// Triple up this A press to make sure it gets through.
199+
ssf_press_button(context, BUTTON_A, 24ms, 48ms, 24ms);
200+
ssf_press_button(context, BUTTON_A, 24ms, 48ms, 24ms);
201+
ssf_press_button(context, BUTTON_A, 24ms, 48ms, 24ms);
202+
203+
for (size_t c = 0; c < 5; c++){
204+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit, 2*unit, unit);
205+
}
206+
207+
// Left scroll in case we missed and landed in the language change or sleep
208+
// confirmation menus.
209+
ssf_issue_scroll(context, SSF_SCROLL_LEFT, unit, 2*unit, unit);
210+
}
211+
212+
213+
214+
215+
216+
217+
218+
219+
220+
221+
115222
ConsoleType settings_detect_console_type(
116223
ConsoleHandle& console, ProControllerContext& context
117224
){
@@ -175,6 +282,17 @@ void home_to_date_time_Switch2_wired_blind(
175282
home_to_settings_Switch2_wired_blind(context);
176283
settings_to_date_time_Switch2_wired_blind(logger, context, console_type, to_date_change);
177284
}
285+
void home_to_date_time_Switch2_wireless_blind(
286+
Logger& logger, ProControllerContext& context,
287+
ConsoleType console_type, bool to_date_change
288+
){
289+
logger.log("home_to_date_time_Switch2_wireless_blind()");
290+
home_to_settings_Switch2_wireless_blind(context);
291+
settings_to_date_time_Switch2_wireless_blind(logger, context, console_type, to_date_change);
292+
}
293+
294+
295+
178296
void home_to_date_time_Switch2_wired_feedback(
179297
ConsoleHandle& console, ProControllerContext& context,
180298
bool to_date_change
@@ -184,6 +302,15 @@ void home_to_date_time_Switch2_wired_feedback(
184302
ConsoleType console_type = settings_detect_console_type(console, context);
185303
settings_to_date_time_Switch2_wired_blind(console, context, console_type, to_date_change);
186304
}
305+
void home_to_date_time_Switch2_wireless_feedback(
306+
ConsoleHandle& console, ProControllerContext& context,
307+
bool to_date_change
308+
){
309+
console.log("home_to_date_time_Switch2_wireless_feedback()");
310+
home_to_settings_Switch2_wireless_blind(context);
311+
ConsoleType console_type = settings_detect_console_type(console, context);
312+
settings_to_date_time_Switch2_wireless_blind(console, context, console_type, to_date_change);
313+
}
187314

188315

189316

SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch_HomeToDateTime.cpp

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,40 @@ bool home_to_date_time_Switch1_feedback(ConsoleHandle& console, ProControllerCon
5050
}
5151

5252

53+
void home_to_date_time_Switch2_blind(
54+
Logger& logger, ProControllerContext& context,
55+
ConsoleType console_type, bool to_date_change
56+
){
57+
switch (context->performance_class()){
58+
case ControllerPerformanceClass::SerialPABotBase_Wired_125Hz:
59+
home_to_date_time_Switch2_wired_blind(logger, context, console_type, to_date_change);
60+
return;
61+
case ControllerPerformanceClass::SerialPABotBase_Wireless_ESP32:
62+
home_to_date_time_Switch2_wireless_blind(logger, context, console_type, to_date_change);
63+
return;
64+
default:
65+
// Slow version for tick-imprecise controllers.
66+
home_to_date_time_Switch1_sbb_blind(logger, context, to_date_change);
67+
return;
68+
}
69+
}
70+
bool home_to_date_time_Switch2_feedback(
71+
ConsoleHandle& console, ProControllerContext& context,
72+
ConsoleType console_type, bool to_date_change
73+
){
74+
switch (context->performance_class()){
75+
case ControllerPerformanceClass::SerialPABotBase_Wired_125Hz:
76+
home_to_date_time_Switch2_wired_feedback(console, context, to_date_change);
77+
return true;
78+
case ControllerPerformanceClass::SerialPABotBase_Wireless_ESP32:
79+
home_to_date_time_Switch2_wireless_feedback(console, context, to_date_change);
80+
return true;
81+
default:;
82+
return false;
83+
}
84+
}
85+
86+
5387

5488

5589
// Returns true if success. False if not supported.
@@ -66,7 +100,7 @@ bool home_to_date_time_with_feedback(ConsoleHandle& console, ProControllerContex
66100
case ConsoleType::Switch2_FW19_JapanLocked:
67101
case ConsoleType::Switch2_FW20_International:
68102
case ConsoleType::Switch2_FW20_JapanLocked:
69-
home_to_date_time_Switch2_wired_feedback(console, context, to_date_change);
103+
home_to_date_time_Switch2_feedback(console, context, console_type, to_date_change);
70104
return true;
71105
default:;
72106
}
@@ -93,7 +127,7 @@ void home_to_date_time(ConsoleHandle& console, ProControllerContext& context, bo
93127
case ConsoleType::Switch2_FW19_JapanLocked:
94128
case ConsoleType::Switch2_FW20_International:
95129
case ConsoleType::Switch2_FW20_JapanLocked:
96-
home_to_date_time_Switch2_wired_blind(console, context, console_type, to_date_change);
130+
home_to_date_time_Switch2_blind(console, context, console_type, to_date_change);
97131
return;
98132
}
99133
}

SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch_HomeToDateTime.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,18 @@ void home_to_date_time_Switch2_wired_blind(
4343
Logger& logger, ProControllerContext& context,
4444
ConsoleType console_type, bool to_date_change
4545
);
46+
void home_to_date_time_Switch2_wireless_blind(
47+
Logger& logger, ProControllerContext& context,
48+
ConsoleType console_type, bool to_date_change
49+
);
4650
void home_to_date_time_Switch2_wired_feedback(
4751
ConsoleHandle& console, ProControllerContext& context,
4852
bool to_date_change
4953
);
54+
void home_to_date_time_Switch2_wireless_feedback(
55+
ConsoleHandle& console, ProControllerContext& context,
56+
bool to_date_change
57+
);
5058

5159

5260
ConsoleType settings_detect_console_type(

0 commit comments

Comments
 (0)