Skip to content

Commit 5930362

Browse files
committed
Rename
1 parent 77211b4 commit 5930362

File tree

10 files changed

+51
-119
lines changed

10 files changed

+51
-119
lines changed

Common/SerialPABotBase/SerialPABotBase_Messages_NS_Generic.h renamed to Common/SerialPABotBase/SerialPABotBase_Messages_NS1_WiredController.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/* SerialPABotBase Messages (Nintendo Switch Generic Wired Controller)
1+
/* SerialPABotBase Messages (Nintendo Switch 1 Wired Controller)
22
*
33
* From: https://github.com/PokemonAutomation/
44
*
55
*/
66

7-
#ifndef PokemonAutomation_SerialPABotBase_Messages_NS_Generic_H
8-
#define PokemonAutomation_SerialPABotBase_Messages_NS_Generic_H
7+
#ifndef PokemonAutomation_SerialPABotBase_Messages_NS1_WiredController_H
8+
#define PokemonAutomation_SerialPABotBase_Messages_NS1_WiredController_H
99

1010
#include "SerialPABotBase_Protocol.h"
1111

@@ -25,23 +25,21 @@ namespace SerialPABotBase{
2525
#endif
2626

2727

28-
#define PABB_MSG_NS_GENERIC_CONTROLLER_STATE_MS 0x90
28+
#define PABB_MSG_REPORT_NS1_WIRED_CONTROLLER 0x90
2929
typedef struct{
3030
uint8_t buttons0;
3131
uint8_t buttons1;
32-
// uint8_t buttons2;
33-
// uint8_t buttons3;
3432
uint8_t dpad;
3533
uint8_t left_joystick_x;
3634
uint8_t left_joystick_y;
3735
uint8_t right_joystick_x;
3836
uint8_t right_joystick_y;
39-
} pabb_ControllerReport_NS_Generic_Controller;
37+
} pabb_Report_NS1_WiredController;
4038
typedef struct{
4139
seqnum_t seqnum;
4240
uint16_t milliseconds;
43-
pabb_ControllerReport_NS_Generic_Controller report;
44-
} PABB_PACK pabb_Message_NS_Generic_ControllerStateMs;
41+
pabb_Report_NS1_WiredController report;
42+
} PABB_PACK pabb_Message_Report_NS1_WiredController;
4543

4644

4745

SerialPrograms/CMakeLists.txt

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ file(GLOB MAIN_SOURCES
280280
../Common/Qt/WidgetStackFixedAspectRatio.cpp
281281
../Common/Qt/WidgetStackFixedAspectRatio.h
282282
../Common/SerialPABotBase/SerialPABotBase_Messages_ESP32.h
283-
../Common/SerialPABotBase/SerialPABotBase_Messages_NS_Generic.h
283+
../Common/SerialPABotBase/SerialPABotBase_Messages_NS1_WiredController.h
284284
../Common/SerialPABotBase/SerialPABotBase_Protocol.h
285285
../Common/SerialPABotBase/SerialPABotBase_Protocol_IDs.h
286286
../IconResource/IconResource.rc
@@ -693,8 +693,8 @@ file(GLOB MAIN_SOURCES
693693
Source/Controllers/SerialPABotBase/SerialPABotBase_PostConnectActions.h
694694
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_ESP32.cpp
695695
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_ESP32.h
696-
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS_Generic.cpp
697-
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS_Generic.h
696+
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS1_WiredController.cpp
697+
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS1_WiredController.h
698698
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_Protocol.cpp
699699
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_Protocol.h
700700
Source/Controllers/SerialPABotBase/SerialPABotBase_SelectorWidget.h
@@ -939,8 +939,8 @@ file(GLOB MAIN_SOURCES
939939
Source/NintendoSwitch/Controllers/NintendoSwitch_VirtualControllerState.h
940940
Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_Controller.cpp
941941
Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_Controller.h
942-
Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_PokkenController.cpp
943-
Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_PokkenController.h
942+
Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_WiredController.cpp
943+
Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_WiredController.h
944944
Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_WirelessController.cpp
945945
Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_WirelessController.h
946946
Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_WirelessJoycon.cpp
@@ -2609,14 +2609,11 @@ else() # macOS and Linux
26092609
endif()
26102610

26112611
if (APPLE)
2612-
###################################################
2613-
# Compiler flag change history:
2614-
# Removed -Wno-c11-extensions since we no long have following error:
2612+
# Add -Wno-c11-extensions to avoid clang gives
26152613
# /usr/local/Cellar/opencv/4.5.5_3/include/opencv4/opencv2/core/mat.inl.hpp:2116:9: error: '_Atomic' is a C11 extension
26162614
# when compiling OpenCV
2617-
###################################################
2618-
# Use https://clang.llvm.org/docs/DiagnosticsReference.html to query Clang warnings
2619-
target_compile_options(SerialPrograms PRIVATE -Wall -Wextra -Wpedantic -Werror -Wshorten-64-to-32 -Wtautological-constant-in-range-compare -Wsequence-point)
2615+
# target_compile_options(SerialPrograms PRIVATE -Wall -Wextra -Wpedantic -Werror -Wno-c11-extensions)
2616+
target_compile_options(SerialPrograms PRIVATE -Wall -Wextra -Wpedantic -Werror -Wshorten-64-to-32)
26202617
else()
26212618
# Assume GCC
26222619
target_compile_options(SerialPrograms PRIVATE -Wall -Wextra -Wpedantic -Werror -fno-strict-aliasing)

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Descriptor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "SerialPABotBase_Descriptor.h"
1111
#include "SerialPABotBase_SelectorWidget.h"
1212

13-
#include "NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_PokkenController.h"
13+
#include "NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_WiredController.h"
1414
#include "NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_WirelessProController.h"
1515
#include "NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_WirelessJoycon.h"
1616

@@ -71,7 +71,7 @@ std::unique_ptr<AbstractController> SerialPABotBase_Descriptor::make_controller(
7171
switch (controller_type){
7272
case ControllerType::NintendoSwitch_WiredProController:
7373
return std::unique_ptr<AbstractController>(
74-
new PokemonAutomation::NintendoSwitch::SerialPABotBase_PokkenController(
74+
new PokemonAutomation::NintendoSwitch::SerialPABotBase_WiredController(
7575
logger,
7676
static_cast<SerialPABotBase_Connection&>(connection)
7777
)

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS_Generic.cpp renamed to SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS1_WiredController.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ namespace SerialPABotBase{
1717

1818
int register_message_converters_push_button_framework(){
1919
register_message_converter(
20-
PABB_MSG_NS_GENERIC_CONTROLLER_STATE_MS,
20+
PABB_MSG_REPORT_NS1_WIRED_CONTROLLER,
2121
[](const std::string& body){
2222
// Disable this by default since it's very spammy.
2323
if (!GlobalSettings::instance().LOG_EVERYTHING){
2424
return std::string();
2525
}
2626
std::ostringstream ss;
27-
ss << "controller_state_ms() - ";
28-
if (body.size() != sizeof(pabb_Message_NS_Generic_ControllerStateMs)){ ss << "(invalid size)" << std::endl; return ss.str(); }
29-
const auto* params = (const pabb_Message_NS_Generic_ControllerStateMs*)body.c_str();
27+
ss << "PABB_MSG_REPORT_NS1_WIRED_CONTROLLER: ";
28+
if (body.size() != sizeof(pabb_Message_Report_NS1_WiredController)){ ss << "(invalid size)" << std::endl; return ss.str(); }
29+
const auto* params = (const pabb_Message_Report_NS1_WiredController*)body.c_str();
3030
ss << "seqnum = " << (uint64_t)params->seqnum;
3131

3232
uint16_t buttons = params->report.buttons0;

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS_Generic.h renamed to SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS1_WiredController.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
/* SerialPABotBase (Nintendo Switch Generic Wired Controller)
1+
/* SerialPABotBase (Nintendo Switch 1 Wired Controller)
22
*
33
* From: https://github.com/PokemonAutomation/
44
*
55
*/
66

7-
#ifndef PokemonAutomation_SerialPABotBase_NS_Generic_H
8-
#define PokemonAutomation_SerialPABotBase_NS_Generic_H
7+
#ifndef PokemonAutomation_SerialPABotBase_NS1_WiredController_H
8+
#define PokemonAutomation_SerialPABotBase_NS1_WiredController_H
99

10-
#include "Common/SerialPABotBase/SerialPABotBase_Messages_NS_Generic.h"
10+
#include "Common/SerialPABotBase/SerialPABotBase_Messages_NS1_WiredController.h"
1111
#include "ClientSource/Connection/BotBaseMessage.h"
1212

1313
namespace PokemonAutomation{
1414
namespace SerialPABotBase{
1515

1616

17-
class DeviceRequest_NS_Generic_ControllerStateMs : public BotBaseRequest{
17+
class DeviceRequest_NS1_WiredController_ControllerStateMs : public BotBaseRequest{
1818
public:
19-
pabb_Message_NS_Generic_ControllerStateMs params;
20-
DeviceRequest_NS_Generic_ControllerStateMs(
19+
pabb_Message_Report_NS1_WiredController params;
20+
DeviceRequest_NS1_WiredController_ControllerStateMs(
2121
uint16_t milliseconds,
2222
uint16_t buttons,
2323
uint8_t dpad,
@@ -45,7 +45,7 @@ class DeviceRequest_NS_Generic_ControllerStateMs : public BotBaseRequest{
4545
params.report.right_joystick_y = right_joystick_y;
4646
}
4747
virtual BotBaseMessage message() const override{
48-
return BotBaseMessage(PABB_MSG_NS_GENERIC_CONTROLLER_STATE_MS, params);
48+
return BotBaseMessage(PABB_MSG_REPORT_NS1_WIRED_CONTROLLER, params);
4949
}
5050
};
5151

SerialPrograms/Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_PokkenController.cpp renamed to SerialPrograms/Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_WiredController.cpp

Lines changed: 11 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* SerialPABotBase: Pokken Controller
1+
/* SerialPABotBase: Wired Controller (Switch 1)
22
*
33
* From: https://github.com/PokemonAutomation/
44
*
@@ -7,12 +7,11 @@
77
#include "Common/Cpp/PrettyPrint.h"
88
#include "Common/Cpp/Exceptions.h"
99
#include "Common/Cpp/Concurrency/ReverseLockGuard.h"
10-
#include "Common/Cpp/Options/TimeExpressionOption.h"
11-
#include "Common/SerialPABotBase/SerialPABotBase_Protocol_IDs.h"
10+
//#include "Common/SerialPABotBase/SerialPABotBase_Protocol_IDs.h"
1211
#include "CommonFramework/Options/Environment/ThemeSelectorOption.h"
1312
#include "Controllers/SerialPABotBase/SerialPABotBase_Routines_Protocol.h"
14-
#include "Controllers/SerialPABotBase/SerialPABotBase_Routines_NS_Generic.h"
15-
#include "NintendoSwitch_SerialPABotBase_PokkenController.h"
13+
#include "Controllers/SerialPABotBase/SerialPABotBase_Routines_NS1_WiredController.h"
14+
#include "NintendoSwitch_SerialPABotBase_WiredController.h"
1615

1716
//#include <iostream>
1817
//using std::cout;
@@ -26,7 +25,7 @@ using namespace std::chrono_literals;
2625

2726

2827

29-
SerialPABotBase_PokkenController::SerialPABotBase_PokkenController(
28+
SerialPABotBase_WiredController::SerialPABotBase_WiredController(
3029
Logger& logger,
3130
SerialPABotBase::SerialPABotBase_Connection& connection
3231
)
@@ -37,13 +36,13 @@ SerialPABotBase_PokkenController::SerialPABotBase_PokkenController(
3736
connection
3837
)
3938
, m_stopping(false)
40-
, m_status_thread(&SerialPABotBase_PokkenController::status_thread, this)
39+
, m_status_thread(&SerialPABotBase_WiredController::status_thread, this)
4140
{}
42-
SerialPABotBase_PokkenController::~SerialPABotBase_PokkenController(){
41+
SerialPABotBase_WiredController::~SerialPABotBase_WiredController(){
4342
stop();
4443
m_status_thread.join();
4544
}
46-
void SerialPABotBase_PokkenController::stop(){
45+
void SerialPABotBase_WiredController::stop(){
4746
if (m_stopping.exchange(true)){
4847
return;
4948
}
@@ -62,7 +61,7 @@ void SerialPABotBase_PokkenController::stop(){
6261

6362

6463

65-
void SerialPABotBase_PokkenController::push_state(const Cancellable* cancellable, WallDuration duration){
64+
void SerialPABotBase_WiredController::push_state(const Cancellable* cancellable, WallDuration duration){
6665
// Must be called inside "m_state_lock".
6766

6867
if (!is_ready()){
@@ -192,7 +191,7 @@ void SerialPABotBase_PokkenController::push_state(const Cancellable* cancellable
192191
while (time_left > Milliseconds::zero()){
193192
Milliseconds current = std::min(time_left, 65535ms);
194193
m_serial->issue_request(
195-
SerialPABotBase::DeviceRequest_NS_Generic_ControllerStateMs(
194+
SerialPABotBase::DeviceRequest_NS1_WiredController_ControllerStateMs(
196195
(uint16_t)current.count(),
197196
buttons,
198197
dpad,
@@ -231,69 +230,8 @@ class ExtendedLengthCounter{
231230
};
232231

233232

234-
#if 0
235-
class TickRateTracker{
236-
public:
237-
TickRateTracker(double expected_ticks_per_second)
238-
: m_expected_ticks_per_second(expected_ticks_per_second)
239-
// , m_history(10)
240-
{}
241-
242-
243-
double push_ticks(uint64_t ticks){
244-
WallClock now = current_time();
245-
246-
// if (m_history.full()){
247-
// m_history.pop_front();
248-
// }
249-
250-
if (ticks <= m_last_ticks){
251-
m_last_push = WallClock::min();
252-
m_last_ticks = 0;
253-
m_consecutive_off = 0;
254-
}
255-
256-
double ticks_per_second = 0;
257-
258-
if (m_last_push != WallClock::min()){
259-
uint64_t elapsed_ticks = ticks - m_last_ticks;
260-
double elapsed_seconds = std::chrono::duration_cast<std::chrono::microseconds>(now - m_last_push).count() * 0.000001;
261-
ticks_per_second = elapsed_ticks / elapsed_seconds;
262-
// m_history.push_back(ticks_per_second);
263-
264-
double rate_error = std::abs(ticks_per_second - m_expected_ticks_per_second) / m_expected_ticks_per_second;
265-
if (rate_error > 0.1){
266-
m_consecutive_off++;
267-
}else{
268-
m_consecutive_off = 0;
269-
}
270-
271-
}
272-
273-
m_last_push = now;
274-
m_last_ticks = ticks;
275-
276-
return ticks_per_second;
277-
}
278-
279-
size_t consecutive_off_readings() const{
280-
return m_consecutive_off;
281-
}
282-
283-
284-
private:
285-
double m_expected_ticks_per_second;
286-
WallClock m_last_push = WallClock::min();
287-
uint64_t m_last_ticks = 0;
288-
289-
size_t m_consecutive_off = 0;
290-
291-
// CircularBuffer<double> m_history;
292-
};
293-
#endif
294-
295233

296-
void SerialPABotBase_PokkenController::status_thread(){
234+
void SerialPABotBase_WiredController::status_thread(){
297235
constexpr std::chrono::milliseconds PERIOD(1000);
298236
std::atomic<WallClock> last_ack(current_time());
299237

SerialPrograms/Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_PokkenController.h renamed to SerialPrograms/Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_WiredController.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/* SerialPABotBase: Pokken Controller
1+
/* SerialPABotBase: Wired Controller (Switch 1)
22
*
33
* From: https://github.com/PokemonAutomation/
44
*
55
*/
66

7-
#ifndef PokemonAutomation_NintendoSwitch_SerialPABotBase_PokkenController_H
8-
#define PokemonAutomation_NintendoSwitch_SerialPABotBase_PokkenController_H
7+
#ifndef PokemonAutomation_NintendoSwitch_SerialPABotBase_WiredControllerNS1_H
8+
#define PokemonAutomation_NintendoSwitch_SerialPABotBase_WiredControllerNS1_H
99

1010
#include "Controllers/ControllerCapability.h"
1111
#include "NintendoSwitch/NintendoSwitch_Settings.h"
@@ -16,7 +16,7 @@ namespace PokemonAutomation{
1616
namespace NintendoSwitch{
1717

1818

19-
class SerialPABotBase_PokkenController final :
19+
class SerialPABotBase_WiredController final :
2020
public ProController,
2121
public SerialPABotBase_Controller
2222
{
@@ -25,11 +25,11 @@ class SerialPABotBase_PokkenController final :
2525

2626

2727
public:
28-
SerialPABotBase_PokkenController(
28+
SerialPABotBase_WiredController(
2929
Logger& logger,
3030
SerialPABotBase::SerialPABotBase_Connection& connection
3131
);
32-
~SerialPABotBase_PokkenController();
32+
~SerialPABotBase_WiredController();
3333
void stop();
3434

3535
virtual Logger& logger() override{

SerialPrograms/Source/Tests/NintendoSwitch_Tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "CommonFramework/ImageTypes/ImageRGB32.h"
1111
#include "CommonFramework/ImageTypes/ImageViewRGB32.h"
1212
#include "CommonFramework/Recording/StreamHistorySession.h"
13-
#include "NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_PokkenController.h"
13+
#include "NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_WiredController.h"
1414
#include "NintendoSwitch/Inference/NintendoSwitch_UpdatePopupDetector.h"
1515
#include "NintendoSwitch_Tests.h"
1616
#include "TestUtils.h"
@@ -29,7 +29,7 @@ int test_NintendoSwitch_UpdatePopupDetector(const ImageViewRGB32& image, bool ta
2929
auto& logger = global_logger_command_line();
3030
DummyBotBase botbase(logger);
3131
SerialPABotBase::SerialPABotBase_Connection connection(logger, nullptr, {});
32-
SerialPABotBase_PokkenController controller(logger, connection);
32+
SerialPABotBase_WiredController controller(logger, connection);
3333
DummyVideoFeed video_feed;
3434
DummyVideoOverlay video_overlay;
3535
DummyAudioFeed audio_feed;

SerialPrograms/Source/Tests/PokemonLA_Tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "CommonFramework/ImageTools/ImageBoxes.h"
1313
#include "CommonFramework/Recording/StreamHistorySession.h"
1414
#include "Controllers/ControllerCapability.h"
15-
#include "NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_PokkenController.h"
15+
#include "NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_WiredController.h"
1616
#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h"
1717
#include "PokemonLA/Inference/Battles/PokemonLA_BattleMenuDetector.h"
1818
#include "PokemonLA/Inference/Battles/PokemonLA_BattlePokemonSwitchDetector.h"
@@ -493,7 +493,7 @@ int test_pokemonLA_shinySoundDetector(const std::vector<AudioSpectrum>& spectrum
493493
auto& logger = global_logger_command_line();
494494
DummyBotBase botbase(logger);
495495
SerialPABotBase::SerialPABotBase_Connection connection(logger, nullptr, {});
496-
SerialPABotBase_PokkenController controller(logger, connection);
496+
SerialPABotBase_WiredController controller(logger, connection);
497497
DummyVideoFeed video_feed;
498498
DummyVideoOverlay video_overlay;
499499
DummyAudioFeed audio_feed;

SerialPrograms/Source/Tests/PokemonLZA_Tests.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "CommonFramework/ImageTools/ImageBoxes.h"
1212
#include "CommonFramework/Recording/StreamHistorySession.h"
1313
#include "Controllers/ControllerCapability.h"
14-
#include "NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_PokkenController.h"
1514
#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h"
1615
#include "PokemonLZA/Inference/PokemonLZA_DialogDetector.h"
1716
#include <QFileInfo>
@@ -46,4 +45,4 @@ int test_pokemonZLA_NormalDialogBoxDetector(const ImageViewRGB32& image, bool ta
4645
}
4746

4847

49-
}
48+
}

0 commit comments

Comments
 (0)