Skip to content

Commit 18c3c46

Browse files
committed
Migrate Sword/Shield settings to TimeDurationOption. Add program end notifications for some programs that are missing it. Various fixes.
1 parent 4827dce commit 18c3c46

File tree

91 files changed

+733
-570
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+733
-570
lines changed

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
#include "PokemonSwSh/MaxLair/Inference/PokemonSwSh_MaxLair_Detect_BattleMenu.h"
115115
#include "PokemonSwSh/MaxLair/Inference/PokemonSwSh_MaxLair_Detect_PokemonSwapMenu.h"
116116
#include "PokemonBDSP/Inference/PokemonBDSP_SelectionArrow.h"
117+
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_DigitEntry.h"
117118

118119

119120
#include <QPixmap>
@@ -133,6 +134,11 @@ using namespace PokemonAutomation::Kernels::Waterfill;
133134
namespace PokemonAutomation{
134135
namespace NintendoSwitch{
135136

137+
uint16_t scroll_to(
138+
SwitchControllerContext& context,
139+
uint8_t start_digit, uint8_t end_digit, bool actually_scroll
140+
);
141+
136142

137143
namespace PokemonSwSh{
138144
std::vector<ImagePixelBox> find_selection_arrows(const ImageViewRGB32& image, size_t min_area);
@@ -272,11 +278,36 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
272278
VideoOverlaySet overlays(overlay);
273279

274280

281+
ssf_press_button(context, BUTTON_A, 0);
282+
ssf_do_nothing(context, 4);
283+
ssf_press_button(context, BUTTON_A, 0);
284+
ssf_do_nothing(context, 4);
285+
ssf_press_button(context, BUTTON_A, 0);
286+
ssf_do_nothing(context, 4);
287+
ssf_press_button(context, BUTTON_A, 0);
288+
ssf_do_nothing(context, 4);
289+
290+
291+
275292

293+
// enter_digits(context, 8, (const uint8_t*)"56685459");
294+
295+
#if 0
296+
for (int c = 0; c < 10; c++){
297+
scroll_to(context, 1, 9, true);
298+
scroll_to(context, 9, 1, true);
299+
}
300+
// pbf_wait(context, 100);
301+
#endif
302+
303+
304+
#if 0
276305
ImageRGB32 image("20250131-170450792229.png");
277306

278307
PokemonSwSh::BattleBallReader reader(console, Language::Korean);
279308
reader.read_ball(image);
309+
#endif
310+
280311

281312

282313
#if 0

SerialPrograms/Source/PokemonSwSh/Commands/PokemonSwSh_Commands_AutoHosts.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ namespace PokemonSwSh{
2121

2222
void connect_to_internet(
2323
SwitchControllerContext& context,
24-
uint16_t open_ycomm_delay,
25-
uint16_t connect_to_internet_delay
24+
Milliseconds open_ycomm_delay,
25+
Milliseconds connect_to_internet_delay
2626
){
27-
ssf_press_button(context, BUTTON_Y, open_ycomm_delay, 10);
27+
ssf_press_button(context, BUTTON_Y, open_ycomm_delay, 80ms);
2828

2929
// Move the cursor as far away from Link Trade and Surprise Trade as possible.
3030
// This is added safety in case connect to internet takes too long.
@@ -75,16 +75,16 @@ void home_to_add_friends(
7575
void accept_FRs(
7676
VideoStream& stream, SwitchControllerContext& context,
7777
uint8_t slot, bool fix_cursor,
78-
uint16_t game_to_home_delay_safe,
79-
uint16_t auto_fr_duration,
78+
Milliseconds game_to_home_delay_safe,
79+
Milliseconds auto_fr_duration,
8080
bool tolerate_system_update_window_slow
8181
){
8282
if (slot > 7){
8383
slot = 7;
8484
}
8585

8686
// Go to Switch Home menu.
87-
pbf_press_button(context, BUTTON_HOME, 10, game_to_home_delay_safe);
87+
pbf_press_button(context, BUTTON_HOME, 80ms, game_to_home_delay_safe);
8888

8989
home_to_add_friends(context, slot, 0, fix_cursor);
9090

@@ -101,7 +101,8 @@ void accept_FRs(
101101
settings_to_enter_game_den_lobby(
102102
context,
103103
tolerate_system_update_window_slow, false,
104-
GameSettings::instance().ENTER_SWITCH_POKEMON, GameSettings::instance().EXIT_SWITCH_POKEMON
104+
GameSettings::instance().ENTER_SWITCH_POKEMON0,
105+
GameSettings::instance().EXIT_SWITCH_POKEMON0
105106
);
106107
}
107108
pbf_wait(context, 300);

SerialPrograms/Source/PokemonSwSh/Commands/PokemonSwSh_Commands_AutoHosts.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ namespace PokemonSwSh{
1717

1818
void connect_to_internet(
1919
SwitchControllerContext& context,
20-
uint16_t open_ycomm_delay,
21-
uint16_t connect_to_internet_delay
20+
Milliseconds open_ycomm_delay,
21+
Milliseconds connect_to_internet_delay
2222
);
2323
void home_to_add_friends(
2424
SwitchControllerContext& context,
@@ -29,8 +29,8 @@ void home_to_add_friends(
2929
void accept_FRs(
3030
VideoStream& stream, SwitchControllerContext& context,
3131
uint8_t slot, bool fix_cursor,
32-
uint16_t game_to_home_delay_safe,
33-
uint16_t auto_fr_duration,
32+
Milliseconds game_to_home_delay_safe,
33+
Milliseconds auto_fr_duration,
3434
bool tolerate_system_update_window_slow
3535
);
3636

SerialPrograms/Source/PokemonSwSh/Commands/PokemonSwSh_Commands_GameEntry.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,26 @@ namespace PokemonSwSh{
2020

2121

2222
void resume_game_no_interact_old(SwitchControllerContext& context, bool tolerate_update_menu){
23-
uint16_t HOME_TO_GAME_DELAY = GameSettings::instance().HOME_TO_GAME_DELAY;
23+
Milliseconds HOME_TO_GAME_DELAY = GameSettings::instance().HOME_TO_GAME_DELAY0;
2424
if (tolerate_update_menu){
25-
pbf_press_button(context, BUTTON_HOME, 10, HOME_TO_GAME_DELAY);
25+
pbf_press_button(context, BUTTON_HOME, 80ms, HOME_TO_GAME_DELAY);
2626
pbf_press_dpad(context, DPAD_DOWN, 10, 10);
2727
pbf_press_dpad(context, DPAD_UP, 10, 10);
28-
pbf_press_button(context, BUTTON_A, 10, HOME_TO_GAME_DELAY);
28+
pbf_press_button(context, BUTTON_A, 80ms, HOME_TO_GAME_DELAY);
2929
}else{
30-
pbf_press_button(context, BUTTON_HOME, 10, HOME_TO_GAME_DELAY);
30+
pbf_press_button(context, BUTTON_HOME, 80ms, HOME_TO_GAME_DELAY);
3131
}
3232
}
3333
void resume_game_back_out_old(SwitchControllerContext& context, bool tolerate_update_menu, uint16_t mash_B_time){
34-
uint16_t HOME_TO_GAME_DELAY = GameSettings::instance().HOME_TO_GAME_DELAY;
34+
Milliseconds HOME_TO_GAME_DELAY = GameSettings::instance().HOME_TO_GAME_DELAY0;
3535
if (tolerate_update_menu){
36-
pbf_press_button(context, BUTTON_HOME, 10, HOME_TO_GAME_DELAY);
36+
pbf_press_button(context, BUTTON_HOME, 80ms, HOME_TO_GAME_DELAY);
3737
pbf_press_dpad(context, DPAD_DOWN, 10, 10);
3838
pbf_press_dpad(context, DPAD_UP, 10, 10);
39-
pbf_press_button(context, BUTTON_A, 10, HOME_TO_GAME_DELAY);
39+
pbf_press_button(context, BUTTON_A, 80ms, HOME_TO_GAME_DELAY);
4040
pbf_mash_button(context, BUTTON_B, mash_B_time);
4141
}else{
42-
pbf_press_button(context, BUTTON_HOME, 10, HOME_TO_GAME_DELAY);
42+
pbf_press_button(context, BUTTON_HOME, 80ms, HOME_TO_GAME_DELAY);
4343
}
4444
}
4545
void resume_game_front_of_den_nowatts(SwitchControllerContext& context, bool tolerate_update_menu){
@@ -96,8 +96,8 @@ void settings_to_enter_game(SwitchControllerContext& context, bool fast){
9696
void settings_to_enter_game_den_lobby(
9797
SwitchControllerContext& context,
9898
bool tolerate_update_menu, bool fast,
99-
uint16_t enter_switch_pokemon_delay,
100-
uint16_t exit_switch_pokemon_delay
99+
Milliseconds enter_switch_pokemon_delay,
100+
Milliseconds exit_switch_pokemon_delay
101101
){
102102
settings_to_enter_game(context, fast);
103103
pbf_wait(context, 90);
@@ -108,7 +108,7 @@ void settings_to_enter_game_den_lobby(
108108
ssf_press_dpad(context, DPAD_DOWN, 10);
109109
ssf_press_dpad(context, DPAD_UP, 10);
110110
// lobby-switch update-start
111-
ssf_press_button(context, BUTTON_A, enter_switch_pokemon_delay, 10);
111+
ssf_press_button(context, BUTTON_A, enter_switch_pokemon_delay, 80ms);
112112
// lobby-select lobby-switch
113113
ssf_press_dpad(context, DPAD_LEFT, 10);
114114
// lobby-select lobby-switch

SerialPrograms/Source/PokemonSwSh/Commands/PokemonSwSh_Commands_GameEntry.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ void settings_to_enter_game (SwitchControllerContext& device, bool f
2222
void settings_to_enter_game_den_lobby(
2323
SwitchControllerContext& device,
2424
bool tolerate_update_menu, bool fast,
25-
uint16_t enter_switch_pokemon_delay,
26-
uint16_t exit_switch_pokemon_delay
25+
Milliseconds enter_switch_pokemon_delay,
26+
Milliseconds exit_switch_pokemon_delay
2727
);
2828
void enter_game(
2929
SwitchControllerContext& device,

SerialPrograms/Source/PokemonSwSh/Commands/PokemonSwSh_Commands_Misc.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,22 @@
44
*
55
*/
66

7-
#include <sstream>
87
#include "ClientSource/Libraries/MessageConverter.h"
98
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
109
#include "PokemonSwSh_Commands_Misc.h"
11-
//#include "PokemonSwSh_Messages_Misc.h"
1210

1311
namespace PokemonAutomation{
1412
namespace NintendoSwitch{
1513

1614

17-
void IoA_backout(SwitchControllerContext& context, uint16_t pokemon_to_menu_delay){
15+
void IoA_backout(SwitchControllerContext& context, Milliseconds pokemon_to_menu_delay){
1816
// Back out to menu.
1917
// Prepend each B press by a DOWN press so that the B gets
2018
// swallowed while in the summary.
2119
ssf_press_dpad(context, DPAD_DOWN, 5, 15);
2220
ssf_press_button(context, BUTTON_B, 60, 10);
2321
ssf_press_dpad(context, DPAD_DOWN, 5, 15);
24-
ssf_press_button(context, BUTTON_B, pokemon_to_menu_delay, 10);
22+
ssf_press_button(context, BUTTON_B, pokemon_to_menu_delay, 80ms);
2523
}
2624

2725

SerialPrograms/Source/PokemonSwSh/Commands/PokemonSwSh_Commands_Misc.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ namespace PokemonAutomation{
1313
namespace NintendoSwitch{
1414

1515

16-
//void mash_A (SwitchControllerContext& context, uint16_t ticks);
17-
void IoA_backout (SwitchControllerContext& context, uint16_t pokemon_to_menu_delay);
16+
void IoA_backout (SwitchControllerContext& context, Milliseconds pokemon_to_menu_delay);
1817

1918

2019

SerialPrograms/Source/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_Adventure.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ AdventureResult run_adventure(
8383
case StateMachineAction::STOP_PROGRAM:
8484
env.log("End of adventure. Stop program requested...", COLOR_PURPLE);
8585
if (runtime.go_home_when_done){
86-
pbf_press_button(context, BUTTON_HOME, 10, GameSettings::instance().GAME_TO_HOME_DELAY_SAFE);
86+
pbf_press_button(context, BUTTON_HOME, 80ms, GameSettings::instance().GAME_TO_HOME_DELAY_SAFE0);
8787
}
8888
stop.store(true, std::memory_order_release);
8989
return;
9090
case StateMachineAction::RESET_RECOVER:
9191
env.log("Error detected. Attempting to correct by resetting...", COLOR_RED);
9292
runtime.session_stats.add_error();
9393
error.store(true, std::memory_order_release);
94-
pbf_press_button(context, BUTTON_HOME, 10, GameSettings::instance().GAME_TO_HOME_DELAY_SAFE);
94+
pbf_press_button(context, BUTTON_HOME, 80ms, GameSettings::instance().GAME_TO_HOME_DELAY_SAFE0);
9595
reset_game_from_home_with_inference(console, context, ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST);
9696
return;
9797
}
@@ -147,7 +147,7 @@ void loop_adventures(
147147
if (TOUCH_DATE_INTERVAL.ok_to_touch_now()){
148148
env.run_in_parallel(scope, [&](ConsoleHandle& console, SwitchControllerContext& context){
149149
env.log("Touching date to prevent rollover.");
150-
pbf_press_button(context, BUTTON_HOME, 10, GameSettings::instance().GAME_TO_HOME_DELAY_SAFE);
150+
pbf_press_button(context, BUTTON_HOME, 80ms, GameSettings::instance().GAME_TO_HOME_DELAY_SAFE0);
151151
touch_date_from_home(context, ConsoleSettings::instance().SETTINGS_TO_HOME_DELAY0);
152152
resume_game_back_out(console, context, ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST, 5 * TICKS_PER_SECOND);
153153
});
@@ -176,7 +176,7 @@ void loop_adventures(
176176
}
177177
env.log("Failed to start adventure. Resetting all Switches...", COLOR_RED);
178178
env.run_in_parallel(scope, [&](ConsoleHandle& console, SwitchControllerContext& context){
179-
pbf_press_button(context, BUTTON_HOME, 10, GameSettings::instance().GAME_TO_HOME_DELAY_SAFE);
179+
pbf_press_button(context, BUTTON_HOME, 80ms, GameSettings::instance().GAME_TO_HOME_DELAY_SAFE0);
180180
reset_game_from_home_with_inference(console, context, ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST);
181181
});
182182
continue;

SerialPrograms/Source/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_CaughtScreen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ StateMachineAction run_caught_screen(
170170
if (state == StateMachineAction::RESET_RECOVER){
171171
throw_and_log<FatalProgramException>(
172172
stream.logger(),
173-
ErrorReport::SEND_ERROR_REPORT,
173+
ErrorReport::NO_ERROR_REPORT,
174174
"Unable to take " + Pokemon::STRING_POKEMON + ". Did you forget to disable nicknames?",
175175
stream
176176
);
@@ -181,7 +181,7 @@ StateMachineAction run_caught_screen(
181181
case CaughtScreenAction::RESET:
182182
stream.log("Resetting game...", COLOR_BLUE);
183183
synchronize_caught_screen(console_index, stream, context, state_tracker);
184-
pbf_press_button(context, BUTTON_HOME, 10, GameSettings::instance().GAME_TO_HOME_DELAY_SAFE);
184+
pbf_press_button(context, BUTTON_HOME, 80ms, GameSettings::instance().GAME_TO_HOME_DELAY_SAFE0);
185185
reset_game_from_home_with_inference(
186186
stream, context,
187187
ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST

0 commit comments

Comments
 (0)