@@ -47,61 +47,79 @@ bool gamemenu_to_ingame(
4747 VideoStream& stream, JoyconContext& context,
4848 Milliseconds mash_duration, Milliseconds enter_game_timeout
4949){
50- // Includes choosing the controller.
51- // Controllers are disconnected? on selection screen so make sure to mash.
50+ // Includes choosing the controller.
51+ // Controllers are disconnected? on selection screen so make sure to mash.
5252 stream.log (" Mashing A to enter game and select controller..." );
5353
5454 // Slow mash to minimize chance of silent disconnect while the controller
5555 // disconnects and reconnects.
56- for (Milliseconds t = 0ms; t < mash_duration; t += 1000ms){
57- pbf_press_button (context, BUTTON_A, 200ms, 800ms);
56+ {
57+ BlackScreenOverWatcher detector (COLOR_RED, {0.2 , 0.2 , 0.6 , 0.6 });
58+ stream.log (" Connecting controller..." );
59+ int ret = run_until<JoyconContext>(
60+ stream, context,
61+ [](JoyconContext& context){
62+ for (int c = 0 ; c < 20 ; c++){
63+ pbf_press_button (context, BUTTON_A, 200ms, 800ms);
64+ }
65+ },
66+ {detector}
67+ );
68+ if (ret == 0 ){
69+ stream.log (" Loading game..." );
70+ }else {
71+ stream.log (" Timed out waiting to connect controller." , COLOR_RED);
72+ return false ;
73+ }
5874 }
5975// pbf_mash_button(context, BUTTON_A, mash_duration);
6076
6177 context.wait_for_all_requests ();
6278
63- // White screen, Pikachu/Eevee running across the screen. Mash will not speed it up.
64- // Mash A at then end to enter continue screen
65- BlackScreenOverWatcher detector (COLOR_RED, {0.2 , 0.2 , 0.6 , 0.6 });
66- stream.log (" Waiting to enter game..." );
67- int ret = run_until<JoyconContext>(
68- stream, context,
69- [&enter_game_timeout](JoyconContext& context){
70- pbf_wait (context, enter_game_timeout);
71- for (int c = 0 ; c < 20 ; c++){
72- pbf_press_button (context, BUTTON_A, 200ms, 800ms);
73- }
74- },
75- {detector}
76- );
77- context.wait_for_all_requests ();
78- if (ret == 0 ){
79- stream.log (" At continue screen." );
80- }else {
81- stream.log (" Timed out waiting to enter game and select continue." , COLOR_RED);
82- return false ;
79+ // White screen, Pikachu/Eevee running across the screen. Mash will not speed it up.
80+ // Mash A at then end to enter continue screen
81+ {
82+ BlackScreenOverWatcher detector (COLOR_RED, {0.2 , 0.2 , 0.6 , 0.6 });
83+ stream.log (" Waiting to enter game..." );
84+ int ret = run_until<JoyconContext>(
85+ stream, context,
86+ [&enter_game_timeout](JoyconContext& context){
87+ pbf_wait (context, enter_game_timeout);
88+ for (int c = 0 ; c < 20 ; c++){
89+ pbf_press_button (context, BUTTON_A, 200ms, 800ms);
90+ }
91+ },
92+ {detector}
93+ );
94+ if (ret == 0 ){
95+ stream.log (" At continue screen." );
96+ }else {
97+ stream.log (" Timed out waiting to enter game and select continue." , COLOR_RED);
98+ return false ;
99+ }
83100 }
84101 pbf_wait (context, 1000ms);
85102 context.wait_for_all_requests ();
86103
87- // Continue your adventure.
88- BlackScreenOverWatcher detector2 (COLOR_YELLOW, {0.2 , 0.2 , 0.6 , 0.6 });
89- int ret2 = run_until<JoyconContext>(
90- stream, context,
91- [](JoyconContext& context){
92- for (int c = 0 ; c < 20 ; c++){
93- pbf_press_button (context, BUTTON_A, 200ms, 800ms);
94- }
95- },
96- {detector2}
97- );
98- context.wait_for_all_requests ();
99- if (ret2 == 0 ){
100- stream.log (" Entered game!" );
101- return true ;
102- }else {
103- stream.log (" Timed out waiting to enter game." , COLOR_RED);
104- return false ;
104+ // Continue your adventure.
105+ {
106+ BlackScreenOverWatcher detector (COLOR_YELLOW, {0.2 , 0.2 , 0.6 , 0.6 });
107+ int ret = run_until<JoyconContext>(
108+ stream, context,
109+ [](JoyconContext& context){
110+ for (int c = 0 ; c < 20 ; c++){
111+ pbf_press_button (context, BUTTON_A, 200ms, 800ms);
112+ }
113+ },
114+ {detector}
115+ );
116+ if (ret == 0 ){
117+ stream.log (" Entered game!" );
118+ return true ;
119+ }else {
120+ stream.log (" Timed out waiting to enter game." , COLOR_RED);
121+ return false ;
122+ }
105123 }
106124}
107125
0 commit comments