Skip to content

Commit 41925c5

Browse files
committed
Update FCEs to check console type early.
1 parent 8faec90 commit 41925c5

File tree

11 files changed

+65
-106
lines changed

11 files changed

+65
-106
lines changed

Common/PokemonSwSh/PokemonSwSh_Protocol_DaySkippers.h

Lines changed: 0 additions & 90 deletions
This file was deleted.

SerialPrograms/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ file(GLOB MAIN_SOURCES
231231
../Common/PokemonSwSh/PokemonSwSh_FossilTable.h
232232
../Common/PokemonSwSh/PokemonSwSh_MultiHostTable.cpp
233233
../Common/PokemonSwSh/PokemonSwSh_MultiHostTable.h
234-
../Common/PokemonSwSh/PokemonSwSh_Protocol_DaySkippers.h
235234
../Common/Qt/AutoHeightTable.cpp
236235
../Common/Qt/AutoHeightTable.h
237236
../Common/Qt/AutoWidthLineEdit.cpp

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 = 56;
29-
const int PROGRAM_VERSION_PATCH = 5;
29+
const int PROGRAM_VERSION_PATCH = 6;
3030

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

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
#include "PokemonSV/Inference/Boxes/PokemonSV_BoxShinyDetector.h"
143143
#include "PokemonSwSh/Inference/PokemonSwSh_DialogBoxDetector.h"
144144
#include "CommonTools/Images/SolidColorTest.h"
145+
#include "CommonTools/Async/InterruptableCommands.h"
145146

146147

147148
#include <QPixmap>
@@ -241,6 +242,9 @@ void TestProgram::on_press(){
241242

242243

243244

245+
246+
247+
244248
void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope& scope){
245249
using namespace Kernels;
246250
using namespace Kernels::Waterfill;
@@ -260,16 +264,55 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
260264
ProControllerContext context(scope, console.pro_controller());
261265
VideoOverlaySet overlays(overlay);
262266

267+
AsyncCommandSession<ProController> session(
268+
scope, logger, env.realtime_dispatcher(),
269+
console.pro_controller()
270+
);
271+
272+
Milliseconds delay = 500ms;
273+
274+
for (int c = 0; c < 100; c++){
275+
session.dispatch([](ProControllerContext& context){
276+
pbf_mash_button(context, BUTTON_A, 360000ms);
277+
});
278+
279+
delay = 552ms;
280+
281+
cout << "delay = " << delay.count() << endl;
282+
283+
context.wait_for(delay);
284+
285+
session.stop_command();
286+
287+
pbf_press_button(context, BUTTON_B, 5000ms, 800ms);
288+
context.wait_for_all_requests();
289+
290+
delay += 1ms;
291+
}
292+
263293

264294

295+
296+
297+
#if 0
265298
auto screenshot = feed.snapshot();
266299

300+
301+
302+
PokemonSV::OverworldDetector detector;
303+
detector.make_overlays(overlays);
304+
cout << detector.detect(screenshot) << endl;
305+
#endif
306+
307+
308+
309+
#if 0
267310
TeraCardReader detector;
268311
detector.make_overlays(overlays);
269312

270313
cout << detector.detect(screenshot) << endl;
271314
detector.pokemon_slug(logger, env.program_info(), screenshot);
272-
315+
#endif
273316

274317
#if 0
275318
NewsDetector detector;

SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ void ConsoleTypeDetector_StartGameUserSelect::commit_to_cache(){
8787
}
8888

8989
ConsoleType detect_console_type_from_in_game(ConsoleHandle& console, ProControllerContext& context){
90+
if (console.state().console_type_confirmed()){
91+
return console.state().console_type();
92+
}
93+
console.log("Unknown Switch type. Try to detect.", COLOR_ORANGE);
9094
go_home(console, context); // Automatically detects console type as well.
9195
resume_game_from_home(console, context);
9296
return console.state().console_type();

SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_HomeMenuDetector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ bool HomeMenuDetector::detect_only(const ImageViewRGB32& screen){
8888

8989
ImageStats stats_bottom_icons = image_stats(extract_box_reference(screen, m_bottom_icons));
9090
// cout << stats_bottom_icons.average << stats_bottom_icons.stddev << endl;
91-
if (stats_bottom_icons.stddev.sum() < 50){
91+
if (stats_bottom_icons.stddev.sum() < 10){
9292
return false;
9393
}
9494

SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_KeyboardCodeEntry.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,7 @@ void keyboard_enter_code(
287287
}
288288

289289

290-
ConsoleType console_type = console.state().console_type();
291-
if (console_type == ConsoleType::Unknown){
292-
console.log("Unknown Switch type. Try to detect.", COLOR_ORANGE);
293-
console_type = detect_console_type_from_in_game(console, context);
294-
}
290+
ConsoleType console_type = detect_console_type_from_in_game(console, context);
295291
bool switch2;
296292
if (is_switch1(console_type)){
297293
switch2 = false;

SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_NumberCodeEntry.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,7 @@ void numberpad_enter_code(
195195
}
196196

197197

198-
ConsoleType console_type = console.state().console_type();
199-
if (console_type == ConsoleType::Unknown){
200-
console.log("Unknown Switch type. Try to detect.", COLOR_ORANGE);
201-
console_type = detect_console_type_from_in_game(console, context);
202-
}
198+
ConsoleType console_type = detect_console_type_from_in_game(console, context);
203199
bool switch2;
204200
if (is_switch1(console_type)){
205201
switch2 = false;

SerialPrograms/Source/PokemonSV/Programs/FastCodeEntry/PokemonSV_ClipboardFastCodeEntry.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@
99
//#include "Common/Cpp/Exceptions.h"
1010
#include "Common/Cpp/CancellableScope.h"
1111
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
12+
#include "NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.h"
1213
#include "Pokemon/Pokemon_Strings.h"
1314
#include "PokemonSV_CodeEntry.h"
1415
#include "PokemonSV_ClipboardFastCodeEntry.h"
1516

17+
//#include <iostream>
18+
//using std::cout;
19+
//using std::endl;
20+
1621
namespace PokemonAutomation{
1722
namespace NintendoSwitch{
1823
namespace PokemonSV{
@@ -46,8 +51,10 @@ void ClipboardFastCodeEntry::program(MultiSwitchProgramEnvironment& env, Cancell
4651
// Connect the controller.
4752
env.run_in_parallel(scope, [&](ConsoleHandle& console, ProControllerContext& context){
4853
pbf_press_button(context, BUTTON_R | BUTTON_L, 5, 3);
54+
detect_console_type_from_in_game(console, context);
4955
});
5056

57+
5158
QClipboard* clipboard = QApplication::clipboard();
5259
#if 0
5360
std::atomic<bool> cleared(false);
@@ -66,6 +73,7 @@ void ClipboardFastCodeEntry::program(MultiSwitchProgramEnvironment& env, Cancell
6673

6774
while (true){
6875
std::string code = clipboard->text().toStdString();
76+
// cout << code << endl;
6977
if (code != start_text && !code.empty()){
7078
const char* error = enter_code(env, scope, SETTINGS, code, false, false);
7179
if (error == nullptr){

SerialPrograms/Source/PokemonSV/Programs/FastCodeEntry/PokemonSV_FastCodeEntry.cpp

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

7-
#include <map>
87
#include <mutex>
98
#include <condition_variable>
109
#include "Common/Cpp/Exceptions.h"
11-
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
10+
//#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
1211
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
12+
#include "NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.h"
1313
#include "Pokemon/Pokemon_Strings.h"
1414
#include "PokemonSV_CodeEntry.h"
1515
#include "PokemonSV_FastCodeEntry.h"
@@ -143,6 +143,7 @@ void FastCodeEntry::program(MultiSwitchProgramEnvironment& env, CancellableScope
143143
// Connect the controller.
144144
env.run_in_parallel(scope, [&](ConsoleHandle& console, ProControllerContext& context){
145145
ssf_press_button_ptv(context, BUTTON_R | BUTTON_L);
146+
detect_console_type_from_in_game(console, context);
146147
});
147148

148149
FceCodeListener listener(CODE);

0 commit comments

Comments
 (0)