Skip to content

Commit e8b2c6b

Browse files
committed
ESP32-S3
1 parent d07b543 commit e8b2c6b

File tree

15 files changed

+273
-70
lines changed

15 files changed

+273
-70
lines changed

ClientSource/Connection/PABotBase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <thread>
3232
#include "Common/Cpp/AbstractLogger.h"
3333
#include "Common/Cpp/Concurrency/SpinLock.h"
34+
#include "Common/SerialPABotBase/SerialPABotBase_Protocol.h"
3435
#include "ClientSource/Connection/MessageLogger.h"
3536
#include "ClientSource/Connection/PABotBaseConnection.h"
3637
#include "BotBase.h"

ClientSource/Connection/PABotBaseConnection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include <memory>
1818
#include <deque>
19-
#include "Common/SerialPABotBase/SerialPABotBase_Protocol.h"
19+
//#include "Common/SerialPABotBase/SerialPABotBase_Protocol.h"
2020
#include "BotBase.h"
2121
#include "MessageSniffer.h"
2222
#include "StreamInterface.h"
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/* SerialPABotBase Messages (Nintendo Switch Generic Wired Controller)
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_SerialPABotBase_Messages_NS_Generic_H
8+
#define PokemonAutomation_SerialPABotBase_Messages_NS_Generic_H
9+
10+
#include "SerialPABotBase_Protocol.h"
11+
12+
#if _WIN32
13+
#pragma pack(push, 1)
14+
#define PABB_PACK
15+
#else
16+
#define PABB_PACK __attribute__((packed))
17+
#endif
18+
19+
20+
#ifdef __cplusplus
21+
namespace PokemonAutomation{
22+
namespace SerialPABotBase{
23+
#endif
24+
25+
26+
27+
#define PABB_MSG_NS_GENERIC_CONTROLLER_STATE_TICKS 0x9f
28+
typedef struct{
29+
seqnum_t seqnum;
30+
uint16_t buttons;
31+
uint8_t dpad;
32+
uint8_t left_joystick_x;
33+
uint8_t left_joystick_y;
34+
uint8_t right_joystick_x;
35+
uint8_t right_joystick_y;
36+
uint8_t ticks;
37+
} PABB_PACK pabb_Message_NS_Generic_ControllerStateTicks;
38+
39+
40+
41+
#define PABB_MSG_NS_GENERIC_CONTROLLER_STATE_MS 0x90
42+
typedef struct{
43+
seqnum_t seqnum;
44+
uint16_t milliseconds;
45+
uint16_t buttons;
46+
uint8_t dpad;
47+
uint8_t left_joystick_x;
48+
uint8_t left_joystick_y;
49+
uint8_t right_joystick_x;
50+
uint8_t right_joystick_y;
51+
} PABB_PACK pabb_Message_NS_Generic_ControllerStateMs;
52+
53+
54+
55+
#ifdef __cplusplus
56+
}
57+
}
58+
#endif
59+
60+
61+
#if _WIN32
62+
#pragma pack(pop)
63+
#endif
64+
65+
#endif

SerialPrograms/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ file(GLOB MAIN_SOURCES
188188
../Common/Cpp/Unicode.cpp
189189
../Common/Cpp/Unicode.h
190190
../Common/Cpp/ValueDebouncer.h
191-
../Common/SerialPABotBase/SerialPABotBase_Messages_AVR8.h
192191
../Common/SerialPABotBase/SerialPABotBase_Messages_ESP32.h
192+
../Common/SerialPABotBase/SerialPABotBase_Messages_NS_Generic.h
193193
../Common/SerialPABotBase/SerialPABotBase_Protocol.h
194194
../Common/SerialPABotBase/SerialPABotBase_Protocol_IDs.h
195195
../Common/NintendoSwitch/NintendoSwitch_ControllerDefs.h
@@ -655,10 +655,10 @@ file(GLOB MAIN_SOURCES
655655
Source/Controllers/SerialPABotBase/SerialPABotBase_Connection.h
656656
Source/Controllers/SerialPABotBase/SerialPABotBase_Descriptor.cpp
657657
Source/Controllers/SerialPABotBase/SerialPABotBase_Descriptor.h
658-
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_AVR8.cpp
659-
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_AVR8.h
660658
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_ESP32.cpp
661659
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_ESP32.h
660+
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS_Generic.cpp
661+
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS_Generic.h
662662
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_Protocol.cpp
663663
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_Protocol.h
664664
Source/Controllers/SerialPABotBase/SerialPABotBase_SelectorWidget.h

SerialPrograms/SerialPrograms.pro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ SOURCES += \
326326
Source/Controllers/SerialPABotBase/SerialPABotBase.cpp \
327327
Source/Controllers/SerialPABotBase/SerialPABotBase_Connection.cpp \
328328
Source/Controllers/SerialPABotBase/SerialPABotBase_Descriptor.cpp \
329-
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_AVR8.cpp \
330329
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_ESP32.cpp \
330+
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS_Generic.cpp \
331331
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_Protocol.cpp \
332332
Source/Controllers/SuperscalarScheduler.cpp \
333333
Source/Integrations/DiscordIntegrationSettings.cpp \
@@ -1280,6 +1280,7 @@ HEADERS += \
12801280
../Common/Qt/TimeQt.h \
12811281
../Common/Qt/WidgetStackFixedAspectRatio.h \
12821282
../Common/SerialPABotBase/SerialPABotBase_Messages_ESP32.h \
1283+
../Common/SerialPABotBase/SerialPABotBase_Messages_NS_Generic.h \
12831284
../Common/SerialPABotBase/SerialPABotBase_Protocol.h \
12841285
../Common/SerialPABotBase/SerialPABotBase_Protocol_IDs.h \
12851286
../SerialPrograms/Source/PokemonSwSh/Inference/PokemonSwSh_DialogTriangleDetector.h \
@@ -1501,8 +1502,8 @@ HEADERS += \
15011502
Source/Controllers/SerialPABotBase/SerialPABotBase.h \
15021503
Source/Controllers/SerialPABotBase/SerialPABotBase_Connection.h \
15031504
Source/Controllers/SerialPABotBase/SerialPABotBase_Descriptor.h \
1504-
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_AVR8.h \
15051505
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_ESP32.h \
1506+
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS_Generic.h \
15061507
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_Protocol.h \
15071508
Source/Controllers/SerialPABotBase/SerialPABotBase_SelectorWidget.h \
15081509
Source/Controllers/SuperscalarScheduler.h \

SerialPrograms/Source/CommonFramework/Globals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace PokemonAutomation{
2626
const bool IS_BETA_VERSION = true;
2727
const int PROGRAM_VERSION_MAJOR = 0;
2828
const int PROGRAM_VERSION_MINOR = 52;
29-
const int PROGRAM_VERSION_PATCH = 14;
29+
const int PROGRAM_VERSION_PATCH = 15;
3030

3131
const std::string PROGRAM_VERSION_BASE =
3232
"v" + std::to_string(PROGRAM_VERSION_MAJOR) +

SerialPrograms/Source/Controllers/ControllerTypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ enum class ControllerType{
3737

3838
enum class ControllerFeature{
3939
TickPrecise,
40+
TimingFlexibleMilliseconds,
4041
QueryTickSize,
4142
QueryCommandQueueSize,
4243
NintendoSwitch_ProController,

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase.cpp

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -85,57 +85,23 @@ const std::map<
8585
std::map<ControllerType, ControllerFeatures>
8686
>
8787
> SUPPORTED_VERSIONS{
88-
#if 0
89-
{2021052600, {
90-
{PABB_PID_UNSPECIFIED, {{ControllerType::None, {}}}},
91-
{PABB_PID_PABOTBASE_12KB, {
92-
{ControllerType::NintendoSwitch_WiredProController, {
93-
ControllerFeature::TickPrecise,
94-
ControllerFeature::NintendoSwitch_ProController,
95-
}},
96-
}},
97-
{PABB_PID_PABOTBASE_31KB, {
98-
{ControllerType::NintendoSwitch_WiredProController, {
99-
ControllerFeature::TickPrecise,
100-
ControllerFeature::NintendoSwitch_ProController,
101-
ControllerFeature::NintendoSwitch_DateSkip,
102-
}},
103-
}},
104-
}},
105-
{2023121900, {
106-
{PABB_PID_UNSPECIFIED, {{ControllerType::None, {}}}},
107-
{PABB_PID_PABOTBASE_12KB, {
108-
{ControllerType::NintendoSwitch_WiredProController, {
109-
ControllerFeature::TickPrecise,
110-
ControllerFeature::QueryCommandQueueSize,
111-
ControllerFeature::NintendoSwitch_ProController,
112-
ControllerFeature::NintendoSwitch_DateSkip,
113-
}},
114-
}},
115-
{PABB_PID_PABOTBASE_31KB, {
116-
{ControllerType::NintendoSwitch_WiredProController, {
117-
ControllerFeature::TickPrecise,
118-
ControllerFeature::QueryCommandQueueSize,
119-
ControllerFeature::NintendoSwitch_ProController,
120-
ControllerFeature::NintendoSwitch_DateSkip,
121-
}},
122-
}},
123-
}},
124-
#endif
12588
{2025040500, {
12689
{PABB_PID_PABOTBASE_ESP32, {
12790
{ControllerType::NintendoSwitch_WirelessProController, {
12891
ControllerFeature::TickPrecise,
92+
ControllerFeature::TimingFlexibleMilliseconds,
12993
ControllerFeature::QueryCommandQueueSize,
13094
ControllerFeature::NintendoSwitch_ProController,
13195
}},
13296
{ControllerType::NintendoSwitch_LeftJoycon, {
13397
ControllerFeature::TickPrecise,
98+
ControllerFeature::TimingFlexibleMilliseconds,
13499
ControllerFeature::QueryCommandQueueSize,
135100
ControllerFeature::NintendoSwitch_LeftJoycon,
136101
}},
137102
{ControllerType::NintendoSwitch_RightJoycon, {
138103
ControllerFeature::TickPrecise,
104+
ControllerFeature::TimingFlexibleMilliseconds,
139105
ControllerFeature::QueryCommandQueueSize,
140106
ControllerFeature::NintendoSwitch_RightJoycon,
141107
}},
@@ -182,9 +148,12 @@ const std::map<
182148
ControllerFeature::NintendoSwitch_DateSkip,
183149
}},
184150
}},
151+
}},
152+
{2025041400, {
185153
{PABB_PID_PABOTBASE_ESP32S3, {
186154
{ControllerType::NintendoSwitch_WiredProController, {
187155
ControllerFeature::TickPrecise,
156+
ControllerFeature::TimingFlexibleMilliseconds,
188157
ControllerFeature::QueryCommandQueueSize,
189158
ControllerFeature::NintendoSwitch_ProController,
190159
ControllerFeature::NintendoSwitch_DateSkip,

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Connection.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class SerialPABotBase_Connection : public ControllerConnection{
3535

3636

3737
public:
38+
// uint8_t program_id() const{
39+
// return m_program_id;
40+
// }
3841
BotBaseController* botbase();
3942

4043
public:
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/* SerialPABotBase AVR8 Routines
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#include <sstream>
8+
#include "Common/SerialPABotBase/SerialPABotBase_Messages_NS_Generic.h"
9+
#include "ClientSource/Libraries/MessageConverter.h"
10+
#include "CommonFramework/GlobalSettingsPanel.h"
11+
#include "NintendoSwitch/Controllers/NintendoSwitch_ControllerState.h"
12+
13+
namespace PokemonAutomation{
14+
namespace SerialPABotBase{
15+
16+
17+
18+
int register_message_converters_push_button_framework(){
19+
register_message_converter(
20+
PABB_MSG_NS_GENERIC_CONTROLLER_STATE_TICKS,
21+
[](const std::string& body){
22+
// Disable this by default since it's very spammy.
23+
if (!GlobalSettings::instance().LOG_EVERYTHING){
24+
return std::string();
25+
}
26+
std::ostringstream ss;
27+
ss << "controller_state_ticks() - ";
28+
if (body.size() != sizeof(pabb_Message_NS_Generic_ControllerStateTicks)){ ss << "(invalid size)" << std::endl; return ss.str(); }
29+
const auto* params = (const pabb_Message_NS_Generic_ControllerStateTicks*)body.c_str();
30+
ss << "seqnum = " << (uint64_t)params->seqnum;
31+
ss << ", buttons = " << params->buttons << "(" << button_to_string((NintendoSwitch::Button)params->buttons) << ")";
32+
ss << ", dpad = " << dpad_to_string((NintendoSwitch::DpadPosition)params->dpad);
33+
ss << ", LJ = (" << (int)params->left_joystick_x << "," << (int)params->left_joystick_y << ")";
34+
ss << ", RJ = (" << (int)params->right_joystick_x << "," << (int)params->right_joystick_y << ")";
35+
ss << ", ticks = " << (int)params->ticks;
36+
return ss.str();
37+
}
38+
);
39+
register_message_converter(
40+
PABB_MSG_NS_GENERIC_CONTROLLER_STATE_MS,
41+
[](const std::string& body){
42+
// Disable this by default since it's very spammy.
43+
if (!GlobalSettings::instance().LOG_EVERYTHING){
44+
return std::string();
45+
}
46+
std::ostringstream ss;
47+
ss << "controller_state_ms() - ";
48+
if (body.size() != sizeof(pabb_Message_NS_Generic_ControllerStateMs)){ ss << "(invalid size)" << std::endl; return ss.str(); }
49+
const auto* params = (const pabb_Message_NS_Generic_ControllerStateMs*)body.c_str();
50+
ss << "seqnum = " << (uint64_t)params->seqnum;
51+
ss << ", buttons = " << params->buttons << "(" << button_to_string((NintendoSwitch::Button)params->buttons) << ")";
52+
ss << ", dpad = " << dpad_to_string((NintendoSwitch::DpadPosition)params->dpad);
53+
ss << ", LJ = (" << (int)params->left_joystick_x << "," << (int)params->left_joystick_y << ")";
54+
ss << ", RJ = (" << (int)params->right_joystick_x << "," << (int)params->right_joystick_y << ")";
55+
ss << ", milliseconds = " << params->milliseconds;
56+
return ss.str();
57+
}
58+
);
59+
return 0;
60+
}
61+
int init_PushButtonFramework = register_message_converters_push_button_framework();
62+
63+
64+
65+
}
66+
}

0 commit comments

Comments
 (0)