Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1372,8 +1372,12 @@ file(GLOB MAIN_SOURCES
Source/PokemonLA/Resources/PokemonLA_PokemonSprites.h
Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.cpp
Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.h
Source/PokemonLGPE/Commands/PokemonLGPE_DateSpam.cpp
Source/PokemonLGPE/Commands/PokemonLGPE_DateSpam.h
Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.cpp
Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.h
Source/PokemonLGPE/Programs/Farming/PokemonLGPE_DailyItemFarmer.cpp
Source/PokemonLGPE/Programs/Farming/PokemonLGPE_DailyItemFarmer.h
Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_AlolanTrade.cpp
Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_AlolanTrade.h
Source/PokemonLGPE/Programs/PokemonLGPE_GameEntry.cpp
Expand Down
2 changes: 2 additions & 0 deletions SerialPrograms/SerialPrograms.pro
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ SOURCES += \
Source/PokemonLA/Resources/PokemonLA_PokemonSprites.cpp \
Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.cpp \
Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.cpp \
Source/PokemonLGPE/Programs/Farming/PokemonLGPE_DailyItemFarmer.cpp \
Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_AlolanTrade.cpp \
Source/PokemonLGPE/Programs/PokemonLGPE_GameEntry.cpp \
Source/PokemonLGPE/PokemonLGPE_Panels.cpp \
Expand Down Expand Up @@ -1864,6 +1865,7 @@ HEADERS += \
Source/PokemonLA/Resources/PokemonLA_PokemonSprites.h \
Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.h \
Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.h \
Source/PokemonLGPE/Programs/Farming/PokemonLGPE_DailyItemFarmer.h \
Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_AlolanTrade.h \
Source/PokemonLGPE/Programs/PokemonLGPE_GameEntry.h \
Source/PokemonLGPE/PokemonLGPE_Panels.h \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,44 @@ bool openedgame_to_gamemenu(



void resume_game_from_home(
VideoStream& stream, JoyconContext& context,
bool skip_home_press
){
if (!skip_home_press){
pbf_press_button(context, BUTTON_HOME, 20ms, 10ms);
}
context.wait_for_all_requests();

while (true){
{
UpdateMenuWatcher update_detector;
int ret = wait_until(
stream, context,
std::chrono::milliseconds(1000),
{ update_detector }
);
if (ret == 0){
stream.log("Detected update window.", COLOR_RED);

pbf_move_joystick(context, 128, 0, 10ms, 0ms);
pbf_press_button(context, BUTTON_A, 10ms, 500ms);
context.wait_for_all_requests();
continue;
}
}

// In case we failed to enter the game.
HomeWatcher home_detector;
if (home_detector.detect(stream.video().snapshot())){
stream.log("Failed to re-enter game. Trying again...", COLOR_RED);
pbf_press_button(context, BUTTON_HOME, 20ms, 10ms);
continue;
}else{
break;
}
}
}
void move_to_user(JoyconContext& context, uint8_t user_slot){
if (user_slot != 0){
// Move to correct user.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ bool openedgame_to_gamemenu(
);



void resume_game_from_home(
VideoStream& stream, JoyconContext& context,
bool skip_home_press = false
);
void start_game_from_home_with_inference(
VideoStream& stream, JoyconContext& context,
uint8_t game_slot,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,66 @@ void home_to_date_time(ProControllerContext& context, bool to_date_change, bool



void home_to_date_time(JoyconContext& context, bool to_date_change){
Milliseconds tv = context->timing_variation();
Milliseconds unit = 32ms + tv;

//From ControllerPerformanceClass::SerialPABotBase_Wireless_ESP32
//as Joycon will only have that controller type

pbf_move_joystick(context, 255, 128, 2*unit, unit);
pbf_move_joystick(context, 255, 128, 2*unit, unit);

// Down twice in case we drop one.
pbf_move_joystick(context, 128, 255, 2*unit, unit);
pbf_move_joystick(context, 128, 255, 2*unit, unit);

pbf_move_joystick(context, 255, 128, 2*unit, unit);

// Press A multiple times to make sure one goes through.
pbf_press_button(context, BUTTON_A, 2*unit, unit);
pbf_press_button(context, BUTTON_A, 2*unit, unit);
pbf_press_button(context, BUTTON_A, 2*unit, unit);


// Just button mash it. lol
{
auto iterations = Milliseconds(1100) / unit + 1;
do{
pbf_move_joystick(context, 128, 255, 2*unit, unit);
}while (--iterations);
}
{
auto iterations = Milliseconds(336) / unit + 1;
do{
pbf_move_joystick(context, 255, 128, 2*unit, unit);
}while (--iterations);
}

pbf_move_joystick(context, 128, 255, 2*unit, unit);
pbf_move_joystick(context, 128, 255, 2*unit, unit);
pbf_move_joystick(context, 128, 255, 4*unit, unit);
pbf_move_joystick(context, 128, 255, 360ms, 304ms);
pbf_move_joystick(context, 128, 255, 2*unit, unit);
//pbf_move_joystick(context, 128, 255, 2*unit, unit);

if (!to_date_change){
ssf_press_button(context, BUTTON_A, 360ms, 2*unit, unit);
return;
}

ssf_press_button(context, BUTTON_A, unit);
{
auto iterations = Milliseconds(216) / unit + 1;
do{
pbf_move_joystick(context, 128, 255, 2*unit, unit);
}while (--iterations);
}
pbf_move_joystick(context, 128, 255, 2*unit, 0ms);
}




}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define PokemonAutomation_NintendoSwitch_Navigation_H

#include "NintendoSwitch/Controllers/NintendoSwitch_ProController.h"
#include "NintendoSwitch/Controllers/NintendoSwitch_Joycon.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
Expand All @@ -16,6 +17,9 @@ namespace NintendoSwitch{

void home_to_date_time(ProControllerContext& context, bool to_date_change, bool fast);

//Joycon must not be sideways
void home_to_date_time(JoyconContext& context, bool to_date_change);



}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* Auto Host Routines
*
* From: https://github.com/PokemonAutomation/
*
*/

#include "ClientSource/Libraries/MessageConverter.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
#include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h"
#include "NintendoSwitch/Programs/NintendoSwitch_Navigation.h"
#include "PokemonLGPE_DateSpam.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonLGPE{

void roll_date_forward_1(JoyconContext& context){
Milliseconds tv = context->timing_variation();
Milliseconds unit = 34ms + tv;

pbf_press_button(context, BUTTON_A, 2*unit, unit);
pbf_move_joystick(context, 128, 0, 2*unit, unit);
pbf_press_button(context, BUTTON_A, 2*unit, unit);

pbf_move_joystick(context, 255, 128, 2*unit, unit);
pbf_move_joystick(context, 128, 0, 2*unit, unit);
pbf_move_joystick(context, 255, 128, 2*unit, unit);
pbf_press_button(context, BUTTON_A, 2*unit, unit);
pbf_move_joystick(context, 255, 128, 2*unit, unit);
pbf_move_joystick(context, 255, 128, 2*unit, unit);
pbf_press_button(context, BUTTON_A, 2*unit, unit);
}

void roll_date_backward_N(JoyconContext& context, uint8_t skips){
if (skips == 0){
return;
}

Milliseconds tv = context->timing_variation();
Milliseconds unit = 32ms + tv;

pbf_press_button(context, BUTTON_A, 2*unit, unit);

for (uint8_t c = 0; c < skips - 1; c++){
pbf_move_joystick(context, 128, 255, 2*unit, unit);
}

pbf_press_button(context, BUTTON_A, 2*unit, unit);
pbf_move_joystick(context, 255, 128, 2*unit, unit);

for (uint8_t c = 0; c < skips - 1; c++){
pbf_move_joystick(context, 128, 255, 2*unit, unit);
}

pbf_press_button(context, BUTTON_A, 2*unit, unit);
pbf_move_joystick(context, 255, 128, 2*unit, unit);
pbf_move_joystick(context, 255, 128, 2*unit, unit);
pbf_press_button(context, BUTTON_A, 2*unit, unit);
pbf_press_button(context, BUTTON_A, 2*unit, unit);
}





}

}
}

24 changes: 24 additions & 0 deletions SerialPrograms/Source/PokemonLGPE/Commands/PokemonLGPE_DateSpam.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* Date Spamming Routines
*
* From: https://github.com/PokemonAutomation/
*
*/

#ifndef PokemonAutomation_PokemonLGPE_Commands_DateSpam_H
#define PokemonAutomation_PokemonLGPE_Commands_DateSpam_H

#include "CommonFramework/Tools/VideoStream.h"
#include "NintendoSwitch/Controllers/NintendoSwitch_Joycon.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonLGPE{

void roll_date_forward_1 (JoyconContext& context);
void roll_date_backward_N (JoyconContext& context, uint8_t skips);

}

}
}
#endif
4 changes: 3 additions & 1 deletion SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Panels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "PokemonLGPE_Panels.h"
#include "PokemonLGPE_Settings.h"

#include "Programs/Farming/PokemonLGPE_DailyItemFarmer.h"
#include "Programs/ShinyHunting/PokemonLGPE_AlolanTrade.h"

namespace PokemonAutomation{
Expand All @@ -25,7 +26,8 @@ std::vector<PanelEntry> PanelListFactory::make_panels() const{
ret.emplace_back("---- Settings ----");
ret.emplace_back(make_settings<GameSettings_Descriptor, GameSettingsPanel>());

//ret.emplace_back("---- General ----");
ret.emplace_back("---- General ----");
ret.emplace_back(make_single_switch_program<DailyItemFarmer_Descriptor, DailyItemFarmer>());

ret.emplace_back("---- Shiny Hunting ----");
ret.emplace_back(make_single_switch_program<AlolanTrade_Descriptor, AlolanTrade>());
Expand Down
Loading