Skip to content

Commit df72127

Browse files
committed
Post-refactor cleanup.
1 parent 1da599e commit df72127

File tree

6 files changed

+21
-29
lines changed

6 files changed

+21
-29
lines changed

SerialPrograms/Source/Controllers/ControllerSession.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
#include "Common/Cpp/Exceptions.h"
88
#include "ControllerSession.h"
99

10-
// REMOVE
11-
#include <iostream>
12-
using std::cout;
13-
using std::endl;
10+
//#include <iostream>
11+
//using std::cout;
12+
//using std::endl;
1413

1514
namespace PokemonAutomation{
1615

@@ -160,22 +159,24 @@ bool ControllerSession::set_device(const std::shared_ptr<const ControllerDescrip
160159

161160

162161
std::string ControllerSession::reset(){
163-
std::lock_guard<std::mutex> lg(m_state_lock);
164-
if (!m_connection){
165-
return "No controller set.";
166-
}
167-
if (m_options_locked){
168-
return "Options are locked.";
169-
}
162+
{
163+
std::lock_guard<std::mutex> lg(m_state_lock);
164+
if (!m_connection){
165+
return "No controller set.";
166+
}
167+
if (m_options_locked){
168+
return "Options are locked.";
169+
}
170170

171-
m_connection.reset();
172-
m_connection = m_descriptor->open(m_logger, m_requirements);
173-
if (m_connection){
174-
m_listeners.run_lambda_with_duplicates([&](Listener& listener){
175-
m_connection->add_status_listener(listener);
176-
});
171+
m_connection.reset();
172+
m_connection = m_descriptor->open(m_logger, m_requirements);
173+
if (m_connection){
174+
m_listeners.run_lambda_with_duplicates([&](Listener& listener){
175+
m_connection->add_status_listener(listener);
176+
});
177+
}
177178
}
178-
179+
signal_status_text_changed(status_text());
179180
return "";
180181
}
181182

SerialPrograms/Source/Integrations/ProgramTracker.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ std::string ProgramTracker::reset_serial(uint64_t console_id){
8787
global_logger_tagged().log("SwitchProgramTracker::" + error, COLOR_RED);
8888
return error;
8989
}
90-
const char* msg = iter->second.first->sender().try_reset();
91-
return msg == nullptr ? "Serial connection was reset." : msg;
90+
std::string error = iter->second.first->controller().reset();
91+
return error.empty() ? "Serial connection was reset." : error;
9292
}
9393
std::string ProgramTracker::start_program(uint64_t program_id){
9494
std::lock_guard<std::mutex> lg(m_lock);

SerialPrograms/Source/Integrations/ProgramTrackerInterfaces.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class BotBaseHandle;
2323

2424
class TrackableConsole{
2525
public:
26-
virtual BotBaseHandle& sender() = 0;
2726
virtual VideoFeed& video() = 0;
2827
virtual AudioFeed& audio() = 0;
2928
virtual ControllerSession& controller() = 0;

SerialPrograms/Source/NintendoSwitch/Controllers/NintendoSwitch_SerialPABotBase.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ class SwitchController_SerialPABotBase :
101101
virtual Logger& logger() override{
102102
return m_serial.logger();
103103
}
104-
BotBaseHandle& handle(){ return m_handle; } // REMOVE
105104

106105

107106
public:

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SwitchSystemSession.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "CommonFramework/VideoPipeline/Backends/CameraImplementations.h"
1010
#include "Integrations/ProgramTracker.h"
1111
#include "NintendoSwitch/NintendoSwitch_Settings.h"
12-
#include "NintendoSwitch/Controllers/NintendoSwitch_SerialPABotBase.h"
1312
#include "NintendoSwitch_SwitchSystemOption.h"
1413
#include "NintendoSwitch_SwitchSystemSession.h"
1514

@@ -70,11 +69,6 @@ SwitchSystemSession::SwitchSystemSession(
7069
}
7170

7271

73-
BotBaseHandle& SwitchSystemSession::sender(){
74-
// TODO: Don't do this. REMOVE
75-
return static_cast<SwitchController_SerialPABotBase&>(m_controller.connection()).handle();
76-
}
77-
7872
void SwitchSystemSession::get(SwitchSystemOption& option){
7973
m_controller.get(option.m_controller);
8074
m_camera->get(option.m_camera);

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SwitchSystemSession.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class SwitchSystemSession final : public TrackableConsole{
5656
Logger& logger(){ return m_logger; }
5757
virtual VideoFeed& video() override{ return *m_camera; }
5858
virtual AudioFeed& audio() override{ return m_audio; }
59-
virtual BotBaseHandle& sender() override;
6059
virtual ControllerSession& controller() override{ return m_controller; };
6160
VideoOverlay& overlay(){ return m_overlay; }
6261
const StreamHistorySession& stream_history() const{ return m_history; }

0 commit comments

Comments
 (0)