Skip to content

Commit 35e77b3

Browse files
committed
detect console type from in game
1 parent 1c16677 commit 35e77b3

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
88
#include "CommonFramework/ImageTools/ImageStats.h"
99
#include "NintendoSwitch_ConsoleTypeDetector.h"
10+
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
11+
#include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h"
12+
#include "CommonFramework/VideoPipeline/VideoFeed.h"
1013

1114
//#include <iostream>
1215
//using std::cout;
@@ -83,6 +86,17 @@ void ConsoleTypeDetector_StartGameUserSelect::commit_to_cache(){
8386
m_console.state().set_console_type(m_console, m_last);
8487
}
8588

89+
ConsoleType detect_console_type_from_in_game(ConsoleHandle& console, ProControllerContext& context){
90+
go_home(console, context);
91+
92+
ConsoleTypeDetector_Home detector(console);
93+
ConsoleType console_type = detector.detect_only(console.video().snapshot());
94+
detector.commit_to_cache();
95+
96+
resume_game_from_home(console, context);
97+
98+
return console_type;
99+
}
86100

87101

88102

SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ConsoleTypeDetector_StartGameUserSelect{
4949
ConsoleType m_last;
5050
};
5151

52-
52+
ConsoleType detect_console_type_from_in_game(ConsoleHandle& console, ProControllerContext& context);
5353

5454

5555

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "NintendoSwitch/NintendoSwitch_Settings.h"
1111
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
1212
#include "NintendoSwitch/Options/NintendoSwitch_CodeEntrySettingsOption.h"
13+
#include "NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.h"
1314
#include "NintendoSwitch_CodeEntryTools.h"
1415
#include "NintendoSwitch_KeyboardCodeEntry.h"
1516

@@ -285,6 +286,11 @@ void keyboard_enter_code(
285286

286287

287288
ConsoleType console_type = console.state().console_type();
289+
290+
if (console_type == ConsoleType::Unknown){
291+
console.log("Unknown Switch type. Try to detect.");
292+
console_type = detect_console_type_from_in_game(console, context);
293+
}
288294
bool switch2;
289295
if (is_switch1(console_type)){
290296
switch2 = false;

SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ClaimMysteryGift.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,11 @@ void ClaimMysteryGift::on_config_value_changed(void* object){
114114
}
115115

116116
void ClaimMysteryGift::enter_mystery_gift_code(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
117+
env.log("Enter mystery gift code.");
118+
117119
std::string normalized_code;
118120
bool force_keyboard_mode = true;
119-
bool connect_controller_press = true;
121+
bool connect_controller_press = false;
120122
normalize_code(normalized_code, CODE, force_keyboard_mode);
121123

122124
const FastCodeEntrySettings& settings = SETTINGS;
@@ -140,6 +142,7 @@ void ClaimMysteryGift::claim_mystery_gift(SingleSwitchProgramEnvironment& env, P
140142
pbf_press_button(context, BUTTON_A, 20, 4 * TICKS_PER_SECOND);
141143
pbf_press_button(context, BUTTON_A, 20, 10 * TICKS_PER_SECOND);
142144
clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 10);
145+
143146
enter_mystery_gift_code(env, context);
144147
}
145148

0 commit comments

Comments
 (0)