Skip to content

Commit 1f4c295

Browse files
committed
Rename SerialBotBaseConnection. Experiment with multiple controller layouts.
1 parent d4c4391 commit 1f4c295

File tree

7 files changed

+45
-46
lines changed

7 files changed

+45
-46
lines changed

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Connection.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace SerialPABotBase{
3535

3636

3737

38-
SerialPABotBaseConnection::SerialPABotBaseConnection(Logger& logger, const QSerialPortInfo* port)
38+
SerialPABotBase_Connection::SerialPABotBase_Connection(Logger& logger, const QSerialPortInfo* port)
3939
: m_logger(logger, GlobalSettings::instance().LOG_EVERYTHING)
4040
{
4141
set_label_text("Not Connected", COLOR_RED);
@@ -80,9 +80,9 @@ SerialPABotBaseConnection::SerialPABotBaseConnection(Logger& logger, const QSeri
8080
return;
8181
}
8282

83-
m_status_thread = std::thread(run_with_catch, "SerialPABotBaseConnection::thread_body()", [this]{ thread_body(); });
83+
m_status_thread = std::thread(run_with_catch, "SerialPABotBase_Connection::thread_body()", [this]{ thread_body(); });
8484
}
85-
SerialPABotBaseConnection::~SerialPABotBaseConnection(){
85+
SerialPABotBase_Connection::~SerialPABotBase_Connection(){
8686
m_ready.store(false, std::memory_order_release);
8787
signal_pre_not_ready();
8888
if (m_botbase == nullptr){
@@ -100,7 +100,7 @@ SerialPABotBaseConnection::~SerialPABotBaseConnection(){
100100
}
101101

102102

103-
void SerialPABotBaseConnection::update_with_capabilities(const std::set<ControllerFeature>& capabilities){
103+
void SerialPABotBase_Connection::update_with_capabilities(const std::set<ControllerFeature>& capabilities){
104104
Logger& logger = m_logger;
105105

106106
do{
@@ -130,16 +130,16 @@ void SerialPABotBaseConnection::update_with_capabilities(const std::set<Controll
130130

131131

132132

133-
BotBaseController* SerialPABotBaseConnection::botbase(){
133+
BotBaseController* SerialPABotBase_Connection::botbase(){
134134
BotBaseController* ret = m_botbase.get();
135135
if (ret == nullptr){
136-
m_logger.log("SerialPABotBaseConnection::botbase() called with null botbase...", COLOR_RED);
136+
m_logger.log("SerialPABotBase_Connection::botbase() called with null botbase...", COLOR_RED);
137137
}
138138
return ret;
139139
}
140140

141141

142-
void SerialPABotBaseConnection::set_label_text(const std::string& text, Color color){
142+
void SerialPABotBase_Connection::set_label_text(const std::string& text, Color color){
143143
m_label = html_color_text(text, color);
144144

145145
std::string status = m_label;
@@ -151,7 +151,7 @@ void SerialPABotBaseConnection::set_label_text(const std::string& text, Color co
151151
}
152152
set_status(status);
153153
}
154-
void SerialPABotBaseConnection::set_uptime_text(const std::string& text, Color color){
154+
void SerialPABotBase_Connection::set_uptime_text(const std::string& text, Color color){
155155
m_uptime = html_color_text(text, color);
156156

157157
std::string status = m_label;
@@ -168,13 +168,13 @@ void SerialPABotBaseConnection::set_uptime_text(const std::string& text, Color c
168168

169169

170170

171-
std::map<ControllerType, std::set<ControllerFeature>> SerialPABotBaseConnection::supported_controllers() const{
171+
std::map<ControllerType, std::set<ControllerFeature>> SerialPABotBase_Connection::supported_controllers() const{
172172
std::lock_guard<std::mutex> lg(m_lock);
173173
return m_controllers;
174174
}
175175

176176

177-
std::map<ControllerType, std::set<ControllerFeature>> SerialPABotBaseConnection::read_device_specs(){
177+
std::map<ControllerType, std::set<ControllerFeature>> SerialPABotBase_Connection::read_device_specs(){
178178
Logger& logger = m_logger;
179179

180180

@@ -223,7 +223,7 @@ std::map<ControllerType, std::set<ControllerFeature>> SerialPABotBaseConnection:
223223

224224

225225

226-
void SerialPABotBaseConnection::thread_body(){
226+
void SerialPABotBase_Connection::thread_body(){
227227
using namespace PokemonAutomation;
228228

229229
m_botbase->set_sniffer(&m_logger);
@@ -266,7 +266,8 @@ void SerialPABotBaseConnection::thread_body(){
266266
}
267267
if (error.empty()){
268268
m_ready.store(true, std::memory_order_release);
269-
std::string text = "Program: " + program_name(m_program_id) + " (" + std::to_string(m_protocol) + ")";
269+
// std::string text = "Program: " + program_name(m_program_id) + " (" + std::to_string(m_protocol) + ")";
270+
std::string text = program_name(m_program_id) + " (" + std::to_string(m_protocol) + ")";
270271
set_label_text(text, theme_friendly_darkblue());
271272
signal_post_ready(controllers);
272273
}else{

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Connection.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ namespace PokemonAutomation{
2222
namespace SerialPABotBase{
2323

2424

25-
class SerialPABotBaseConnection : public ControllerConnection{
25+
class SerialPABotBase_Connection : public ControllerConnection{
2626
public:
27-
SerialPABotBaseConnection(Logger& logger, const QSerialPortInfo* port);
28-
~SerialPABotBaseConnection();
27+
SerialPABotBase_Connection(Logger& logger, const QSerialPortInfo* port);
28+
~SerialPABotBase_Connection();
2929

3030
void update_with_capabilities(const std::set<ControllerFeature>& capabilities);
3131

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Descriptor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ JsonValue SerialPABotBase_Descriptor::to_json() const{
7878
std::unique_ptr<ControllerConnection> SerialPABotBase_Descriptor::open_connection(
7979
Logger& logger
8080
) const{
81-
return std::unique_ptr<ControllerConnection>(new SerialPABotBase::SerialPABotBaseConnection(logger, &m_port));
81+
return std::unique_ptr<ControllerConnection>(new SerialPABotBase::SerialPABotBase_Connection(logger, &m_port));
8282
}
8383
std::unique_ptr<AbstractController> SerialPABotBase_Descriptor::make_controller(
8484
Logger& logger,
@@ -91,7 +91,7 @@ std::unique_ptr<AbstractController> SerialPABotBase_Descriptor::make_controller(
9191
return std::unique_ptr<AbstractController>(
9292
new NintendoSwitch::SwitchController_SerialPABotBase(
9393
logger,
94-
static_cast<SerialPABotBase::SerialPABotBaseConnection&>(connection),
94+
static_cast<SerialPABotBase::SerialPABotBase_Connection&>(connection),
9595
requirements
9696
)
9797
);

SerialPrograms/Source/NintendoSwitch/Controllers/NintendoSwitch_SerialPABotBase.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,9 @@
55
*/
66

77
#include "Common/Cpp/Exceptions.h"
8-
//#include "Common/Cpp/Json/JsonValue.h"
9-
//#include "CommonFramework/GlobalSettingsPanel.h"
108
#include "CommonFramework/Options/Environment/ThemeSelectorOption.h"
119
#include "Controllers/ControllerCapability.h"
12-
//#include "Controllers/ControllerDescriptor.h"
13-
//#include "Controllers/SerialPABotBase/SerialPABotBase.h"
1410
#include "NintendoSwitch/Commands/NintendoSwitch_Messages_PushButtons.h"
15-
//#include "NintendoSwitch/Commands/NintendoSwitch_Messages_Superscalar.h"
1611
#include "NintendoSwitch_SerialPABotBase.h"
1712

1813
//#include <iostream>
@@ -22,13 +17,10 @@
2217
namespace PokemonAutomation{
2318
namespace NintendoSwitch{
2419

25-
2620
using namespace std::chrono_literals;
2721

2822

2923

30-
31-
3224
template <typename Type>
3325
PA_FORCE_INLINE Type milliseconds_to_ticks_8ms(Type milliseconds){
3426
return milliseconds / 8 + (milliseconds % 8 + 7) / 8;
@@ -38,14 +30,9 @@ PA_FORCE_INLINE Type milliseconds_to_ticks_8ms(Type milliseconds){
3830

3931

4032

41-
42-
43-
SwitchController_SerialPABotBase::~SwitchController_SerialPABotBase(){
44-
// m_handle.remove_status_listener(*this);
45-
}
4633
SwitchController_SerialPABotBase::SwitchController_SerialPABotBase(
4734
Logger& logger,
48-
SerialPABotBase::SerialPABotBaseConnection& connection,
35+
SerialPABotBase::SerialPABotBase_Connection& connection,
4936
const ControllerRequirements& requirements
5037
)
5138
: SwitchControllerWithScheduler(logger)

SerialPrograms/Source/NintendoSwitch/Controllers/NintendoSwitch_SerialPABotBase.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#define PokemonAutomation_NintendoSwitch_Controller_SerialPABotBase_H
1010

1111
#include "ClientSource/Connection/BotBase.h"
12-
//#include "Controllers/ControllerDescriptor.h"
13-
//#include "Controllers/ControllerConnection.h"
1412
#include "Controllers/SerialPABotBase/SerialPABotBase_Connection.h"
1513
#include "NintendoSwitch_ControllerWithScheduler.h"
1614

@@ -19,18 +17,15 @@ namespace NintendoSwitch{
1917

2018

2119

22-
23-
2420
class SwitchController_SerialPABotBase : public SwitchControllerWithScheduler
2521
{
2622
public:
2723
using ContextType = SwitchControllerContext;
2824

2925
public:
30-
~SwitchController_SerialPABotBase();
3126
SwitchController_SerialPABotBase(
3227
Logger& logger,
33-
SerialPABotBase::SerialPABotBaseConnection& connection,
28+
SerialPABotBase::SerialPABotBase_Connection& connection,
3429
const ControllerRequirements& requirements
3530
);
3631

@@ -79,7 +74,7 @@ class SwitchController_SerialPABotBase : public SwitchControllerWithScheduler
7974
Logger& m_logger;
8075
const ControllerRequirements& m_requirements;
8176

82-
SerialPABotBase::SerialPABotBaseConnection& m_handle;
77+
SerialPABotBase::SerialPABotBase_Connection& m_handle;
8378
BotBaseController* m_serial;
8479

8580
std::string m_error_string;

SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_SwitchSystemWidget.cpp

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,13 @@ SwitchSystemWidget::SwitchSystemWidget(
5757
QWidget* widget = new QWidget(m_group_box);
5858
m_group_box->set_widget(widget);
5959
{
60-
QVBoxLayout* group_layout = new QVBoxLayout(widget);
61-
group_layout->setAlignment(Qt::AlignTop);
62-
group_layout->setContentsMargins(0, 0, 0, 0);
63-
64-
m_controller = new ControllerSelectorWidget(*this, m_session.controller_session());
65-
group_layout->addWidget(m_controller);
66-
6760
m_audio_display = new AudioDisplayWidget(*this, m_session.logger(), m_session.audio_session());
6861
layout->addWidget(m_audio_display);
6962

7063
QVBoxLayout* video_holder = new QVBoxLayout();
7164
layout->addLayout(video_holder);
7265
video_holder->setContentsMargins(0, 0, 0, 0);
66+
7367
m_video_display = new VideoDisplayWidget(
7468
*this, *video_holder,
7569
m_session.console_number(),
@@ -78,6 +72,14 @@ SwitchSystemWidget::SwitchSystemWidget(
7872
m_session.overlay_session()
7973
);
8074
video_holder->addWidget(m_video_display);
75+
}
76+
{
77+
QVBoxLayout* group_layout = new QVBoxLayout(widget);
78+
group_layout->setAlignment(Qt::AlignTop);
79+
group_layout->setContentsMargins(0, 0, 0, 0);
80+
81+
m_controller = new ControllerSelectorWidget(*this, m_session.controller_session());
82+
group_layout->addWidget(m_controller);
8183

8284
m_camera_widget = new CameraSelectorWidget(
8385
m_session.camera_session(),
@@ -89,6 +91,20 @@ SwitchSystemWidget::SwitchSystemWidget(
8991
m_audio_widget = new AudioSelectorWidget(*widget, m_session.audio_session());
9092
group_layout->addWidget(m_audio_widget);
9193

94+
#if 0
95+
// Experiment with multiple controller layouts.
96+
m_controller = new ControllerSelectorWidget(*this, m_session.controller_session());
97+
group_layout->addWidget(m_controller);
98+
99+
group_layout->addWidget(new ControllerSelectorWidget(*this, m_session.controller_session()));
100+
group_layout->addWidget(new ControllerSelectorWidget(*this, m_session.controller_session()));
101+
group_layout->addWidget(new ControllerSelectorWidget(*this, m_session.controller_session()));
102+
group_layout->addWidget(new ControllerSelectorWidget(*this, m_session.controller_session()));
103+
group_layout->addWidget(new ControllerSelectorWidget(*this, m_session.controller_session()));
104+
group_layout->addWidget(new ControllerSelectorWidget(*this, m_session.controller_session()));
105+
group_layout->addWidget(new ControllerSelectorWidget(*this, m_session.controller_session()));
106+
#endif
107+
92108
m_command = new CommandRow(
93109
*widget,
94110
m_session.controller_session(),

SerialPrograms/Source/Tests/PokemonLA_Tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ int test_pokemonLA_SaveScreenDetector(const ImageViewRGB32& image, const std::ve
492492
int test_pokemonLA_shinySoundDetector(const std::vector<AudioSpectrum>& spectrums, bool target){
493493
auto& logger = global_logger_command_line();
494494
DummyBotBase botbase(logger);
495-
SerialPABotBase::SerialPABotBaseConnection connection(logger, nullptr);
495+
SerialPABotBase::SerialPABotBase_Connection connection(logger, nullptr);
496496
SwitchController_SerialPABotBase controller(logger, connection, {});
497497
DummyVideoFeed video_feed;
498498
DummyVideoOverlay video_overlay;

0 commit comments

Comments
 (0)