From a52c47ef1485d0b3f7f3318f34dc46a0213e149a Mon Sep 17 00:00:00 2001 From: jw098 Date: Thu, 9 Jul 2026 23:54:46 -0700 Subject: [PATCH 1/2] change PybindSwitchController to PABB2 --- .../Source/Integrations/PybindSwitchController.cpp | 6 +++--- .../NintendoSwitch/DevPrograms/TestProgramComputer.cpp | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/SerialPrograms/Source/Integrations/PybindSwitchController.cpp b/SerialPrograms/Source/Integrations/PybindSwitchController.cpp index 00bb6bf226..c17b21803f 100644 --- a/SerialPrograms/Source/Integrations/PybindSwitchController.cpp +++ b/SerialPrograms/Source/Integrations/PybindSwitchController.cpp @@ -9,7 +9,7 @@ #include "Common/Cpp/Logging/TaggedLogger.h" #include "CommonFramework/Logging/Logger.h" #include "Controllers/ControllerConnection.h" -#include "Controllers/SerialPABotBase/SerialPABotBase_Descriptor.h" +#include "Controllers/PABotBase2/SerialPABotBase2_Descriptor.h" #include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" #include "PybindSwitchController.h" @@ -25,7 +25,7 @@ namespace NintendoSwitch{ class PybindSwitchProControllerInternal final : public ControllerConnection::StatusListener{ public: PybindSwitchProControllerInternal(const std::string& name) - : m_logger(global_logger_raw(), "Pybind") + : m_logger(global_logger_command_line(), "Pybind") , m_descriptor(name) , m_connection(m_descriptor.open_connection(m_logger)) { @@ -75,7 +75,7 @@ class PybindSwitchProControllerInternal final : public ControllerConnection::Sta public: TaggedLogger m_logger; - SerialPABotBase::SerialPABotBase_Descriptor m_descriptor; + SerialPABotBase::SerialPABotBase2_Descriptor m_descriptor; std::unique_ptr m_connection; std::unique_ptr m_controller; std::atomic m_procon; diff --git a/SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramComputer.cpp b/SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramComputer.cpp index b4d6fcf708..46cc20b4a1 100644 --- a/SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramComputer.cpp +++ b/SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramComputer.cpp @@ -147,7 +147,7 @@ #include "Common/Cpp/StreamConnections/MockDevice.h" #include "CommonTools/Random.h" #include "CommonTools/OCR/OCR_TextMatcher.h" - +#include "Integrations/PybindSwitchController.h" //#include #include @@ -386,6 +386,12 @@ void TestProgramComputer::program(ProgramEnvironment& env, CancellableScope& sco cout << OCR::random_match_probability(10, 1, 0.5) << endl; +#if 0 + PybindSwitchProController controller("COM3"); + controller.wait_for_ready(5000); + controller.push_button(1000, 200, 800, BUTTON_X); + controller.wait_for_all_requests(); +#endif #if 0 ImageRGB32 image(IMAGE_PATH); From 21a9944f8f3f3ee602373dc987453797cd3b9fb3 Mon Sep 17 00:00:00 2001 From: jw098 Date: Fri, 10 Jul 2026 09:16:33 -0700 Subject: [PATCH 2/2] updated SerialPABotBase2_Connection::open_serial_port. QSerialPortInfo is initialized based on whether the QT UI is available. --- .../Source/CommandLine/CommandLine_Main.cpp | 5 ++ .../Source/CommonFramework/Globals.h | 2 + .../Source/CommonFramework/Main.cpp | 4 ++ .../SerialPABotBase2_Connection.cpp | 52 +++++++++++-------- 4 files changed, 41 insertions(+), 22 deletions(-) diff --git a/SerialPrograms/Source/CommandLine/CommandLine_Main.cpp b/SerialPrograms/Source/CommandLine/CommandLine_Main.cpp index e8dc5b5825..bf8fe04748 100644 --- a/SerialPrograms/Source/CommandLine/CommandLine_Main.cpp +++ b/SerialPrograms/Source/CommandLine/CommandLine_Main.cpp @@ -8,6 +8,7 @@ #include #include "Common/Cpp/Color.h" +#include "CommonFramework/Globals.h" #include "CommonFramework/Logging/Logger.h" // #include "CommonFramework/Logging/OutputRedirector.h" #include "Integrations/PybindSwitchController.h" @@ -16,6 +17,10 @@ using namespace PokemonAutomation; using namespace PokemonAutomation::NintendoSwitch; +namespace PokemonAutomation{ + bool USE_QT_UI = false; +} + int main(int argc, char* argv[]){ // // Set up output redirection for logging // OutputRedirector redirect_stdout(std::cout, "stdout", Color()); diff --git a/SerialPrograms/Source/CommonFramework/Globals.h b/SerialPrograms/Source/CommonFramework/Globals.h index 7b68be402d..f6368394f6 100644 --- a/SerialPrograms/Source/CommonFramework/Globals.h +++ b/SerialPrograms/Source/CommonFramework/Globals.h @@ -43,6 +43,8 @@ extern const std::string COMPILER_VERSION; extern const size_t LOG_HISTORY_LINES; +extern bool USE_QT_UI; + // Set a profile for program settings (/UserSettings/PROFILE_NAME/) on MacOS. // Have to run the program with command-line argument "open -n PATH_TO_APP --args --profile PROFILE_NAME" to set the profile and launch a new window. // This allows multiple instances of the program to run since settings are no longer shared. diff --git a/SerialPrograms/Source/CommonFramework/Main.cpp b/SerialPrograms/Source/CommonFramework/Main.cpp index f5dfd09985..3302907079 100644 --- a/SerialPrograms/Source/CommonFramework/Main.cpp +++ b/SerialPrograms/Source/CommonFramework/Main.cpp @@ -48,6 +48,10 @@ using std::endl; using namespace PokemonAutomation; +namespace PokemonAutomation{ + bool USE_QT_UI = true; +} + Q_DECLARE_METATYPE(std::string) void set_working_directory(){ diff --git a/SerialPrograms/Source/Controllers/PABotBase2/SerialPABotBase2_Connection.cpp b/SerialPrograms/Source/Controllers/PABotBase2/SerialPABotBase2_Connection.cpp index 9e7be59ff7..4fc1625238 100644 --- a/SerialPrograms/Source/Controllers/PABotBase2/SerialPABotBase2_Connection.cpp +++ b/SerialPrograms/Source/Controllers/PABotBase2/SerialPABotBase2_Connection.cpp @@ -118,30 +118,38 @@ bool SerialPABotBase2_Connection::open_serial_port(){ return false; } - QSerialPortInfo info = SerialPortPoller::instance().get_port(m_device_name); - - // Port is invalid. - if (info.isNull()){ - std::string text = "Serial port " + m_device_name + " is invalid."; - m_logger.log(text, COLOR_RED); - set_status_line0(text, COLOR_RED); - return false; + QSerialPortInfo info; + if(USE_QT_UI){ + info = SerialPortPoller::instance().get_port(m_device_name); + }else{ + info = QSerialPortInfo(QString::fromStdString(m_device_name)); } - // Prolific is banned - if (info.description().indexOf("Prolific") != -1){ - QMessageBox box; - box.critical( - nullptr, - "Error", - "Cannot select Prolific controller.

" - "Prolific controllers do not work for Arduino and similar microcontrollers.
" - "You were warned of this in the setup instructions. Please buy a CP210x controller instead." - ); - std::string text = "Cannot connect to Prolific controller."; - m_logger.log(text, COLOR_RED); - set_status_line0(text, COLOR_RED); - return false; + + if(USE_QT_UI){ + // Port is invalid. + if (info.isNull()){ + std::string text = "Serial port " + m_device_name + " is invalid."; + m_logger.log(text, COLOR_RED); + set_status_line0(text, COLOR_RED); + return false; + } + + // Prolific is banned + if (info.description().indexOf("Prolific") != -1){ + QMessageBox box; + box.critical( + nullptr, + "Error", + "Cannot select Prolific controller.

" + "Prolific controllers do not work for Arduino and similar microcontrollers.
" + "You were warned of this in the setup instructions. Please buy a CP210x controller instead." + ); + std::string text = "Cannot connect to Prolific controller."; + m_logger.log(text, COLOR_RED); + set_status_line0(text, COLOR_RED); + return false; + } } if (cancelled()){