Skip to content

Commit c3b703c

Browse files
committed
Rename stuff to be less ESP32-specific.
1 parent 1598633 commit c3b703c

13 files changed

+142
-183
lines changed

Common/SerialPABotBase/SerialPABotBase_Messages_ESP32.h renamed to Common/SerialPABotBase/SerialPABotBase_Messages_NS1_WirelessControllers.h

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

7-
#ifndef PokemonAutomation_SerialPABotBase_Messages_ESP32_H
8-
#define PokemonAutomation_SerialPABotBase_Messages_ESP32_H
7+
#ifndef PokemonAutomation_SerialPABotBase_Messages_NS1_WirelessControllers_H
8+
#define PokemonAutomation_SerialPABotBase_Messages_NS1_WirelessControllers_H
99

1010
#include "../ControllerStates/NintendoSwitch_WirelessController_State.h"
1111
#include "SerialPABotBase_Protocol.h"
@@ -37,38 +37,38 @@ typedef struct{
3737

3838

3939

40-
#define PABB_MSG_ESP32_REQUEST_READ_SPI 0x60
40+
#define PABB_MSG_REQUEST_NS1_WIRELESS_CONTROLLER_READ_SPI 0x60
4141
typedef struct{
4242
seqnum_t seqnum;
4343
uint32_t controller_type;
4444
uint32_t address;
4545
uint8_t bytes;
46-
} PABB_PACK pabb_Message_ESP32_ReadSpi;
46+
} PABB_PACK pabb_Message_NS1_WirelessController_ReadSpi;
4747

48-
#define PABB_MSG_ESP32_REQUEST_WRITE_SPI 0x61
48+
#define PABB_MSG_REQUEST_NS1_WIRELESS_CONTROLLER_WRITE_SPI 0x61
4949
typedef struct{
5050
seqnum_t seqnum;
5151
uint32_t controller_type;
5252
uint32_t address;
5353
uint8_t bytes;
54-
} PABB_PACK pabb_Message_ESP32_WriteSpi;
54+
} PABB_PACK pabb_Message_NS1_WirelessController_WriteSpi;
5555

5656

5757

58-
#define PABB_MSG_ESP32_CONTROLLER_STATE_BUTTONS 0xa0
58+
#define PABB_MSG_COMMAND_NS1_WIRELESS_CONTROLLER_BUTTONS 0xa0
5959
typedef struct{
6060
seqnum_t seqnum;
6161
uint16_t milliseconds;
6262
pabb_NintendoSwitch_WirelessController_State0x30_Buttons buttons;
63-
} PABB_PACK pabb_Message_ESP32_CommandButtonState;
63+
} PABB_PACK pabb_Message_Command_NS1_WirelessController_Buttons;
6464

6565

66-
#define PABB_MSG_ESP32_CONTROLLER_STATE_FULL 0xa1
66+
#define PABB_MSG_COMMAND_NS1_WIRELESS_CONTROLLER_FULL_STATE 0xa1
6767
typedef struct{
6868
seqnum_t seqnum;
6969
uint16_t milliseconds;
7070
pabb_NintendoSwitch_WirelessController_State0x30 state;
71-
} PABB_PACK pabb_Message_ESP32_CommandFullState;
71+
} PABB_PACK pabb_Message_Command_NS1_WirelessController_FullState;
7272

7373

7474

Common/SerialPABotBase/SerialPABotBase_Messages_NS2_WiredController.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ namespace SerialPABotBase{
2626
#endif
2727

2828

29-
#define PABB_MSG_REPORT_NS2_WIRED_CONTROLLER 0x90
29+
#define PABB_MSG_COMMAND_NS2_WIRED_CONTROLLER_STATE 0x90
3030
typedef struct{
3131
seqnum_t seqnum;
3232
uint16_t milliseconds;
3333
pabb_NintendoSwitch2_WiredController_State report;
34-
} PABB_PACK pabb_Message_Report_NS2_WiredController;
34+
} PABB_PACK pabb_Message_Command_NS2_WiredController_State;
3535

3636

3737

Common/SerialPABotBase/SerialPABotBase_Protocol_IDs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
#define PABB_PID_PABOTBASE_ESP32 0x10
3232
#define PABB_PID_PABOTBASE_ESP32S3 0x12
3333

34+
// Raspberry Pi
35+
#define PABB_PID_PABOTBASE_PicoW 0x20
36+
3437

3538
//
3639
// Controller IDs

SerialPrograms/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ file(GLOB MAIN_SOURCES
299299
../Common/Qt/TimeQt.h
300300
../Common/Qt/WidgetStackFixedAspectRatio.cpp
301301
../Common/Qt/WidgetStackFixedAspectRatio.h
302-
../Common/SerialPABotBase/SerialPABotBase_Messages_ESP32.h
302+
../Common/SerialPABotBase/SerialPABotBase_Messages_NS1_WirelessControllers.h
303303
../Common/SerialPABotBase/SerialPABotBase_Messages_NS2_WiredController.h
304304
../Common/SerialPABotBase/SerialPABotBase_Protocol.h
305305
../Common/SerialPABotBase/SerialPABotBase_Protocol_IDs.h
@@ -714,8 +714,8 @@ file(GLOB MAIN_SOURCES
714714
Source/Controllers/SerialPABotBase/SerialPABotBase_Descriptor.h
715715
Source/Controllers/SerialPABotBase/SerialPABotBase_PostConnectActions.cpp
716716
Source/Controllers/SerialPABotBase/SerialPABotBase_PostConnectActions.h
717-
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_ESP32.cpp
718-
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_ESP32.h
717+
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS1_WirelessControllers.cpp
718+
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS1_WirelessControllers.h
719719
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS2_WiredController.cpp
720720
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS2_WiredController.h
721721
Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_Protocol.cpp

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_PostConnectActions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "Controllers/ControllerTypeStrings.h"
1010
#include "NintendoSwitch/NintendoSwitch_Settings.h"
1111
#include "SerialPABotBase_Routines_Protocol.h"
12-
#include "SerialPABotBase_Routines_ESP32.h"
12+
#include "SerialPABotBase_Routines_NS1_WirelessControllers.h"
1313
#include "SerialPABotBase.h"
1414
#include "SerialPABotBase_PostConnectActions.h"
1515

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_ESP32.cpp

Lines changed: 0 additions & 145 deletions
This file was deleted.
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/* SerialPABotBase (Nintendo Switch 1 Wireless Controllers)
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#include <sstream>
8+
#include "Common/Cpp/PrettyPrint.h"
9+
#include "Common/SerialPABotBase/SerialPABotBase_Messages_NS1_WirelessControllers.h"
10+
#include "ClientSource/Libraries/MessageConverter.h"
11+
#include "CommonFramework/GlobalSettingsPanel.h"
12+
13+
namespace PokemonAutomation{
14+
namespace SerialPABotBase{
15+
16+
17+
18+
int register_message_converters_NS1_WirelessControllers(){
19+
register_message_converter(
20+
PABB_MSG_REQUEST_STATUS,
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 << "PABB_MSG_REQUEST_STATUS() - ";
28+
if (body.size() != sizeof(pabb_Message_RequestStatus)){ ss << "(invalid size)" << std::endl; return ss.str(); }
29+
const auto* params = (const pabb_Message_RequestStatus*)body.c_str();
30+
ss << "seqnum = " << (uint64_t)params->seqnum;
31+
return ss.str();
32+
}
33+
);
34+
register_message_converter(
35+
PABB_MSG_REQUEST_NS1_WIRELESS_CONTROLLER_READ_SPI,
36+
[](const std::string& body){
37+
std::ostringstream ss;
38+
ss << "PABB_MSG_REQUEST_NS1_WIRELESS_CONTROLLER_READ_SPI() - ";
39+
if (body.size() != sizeof(pabb_Message_NS1_WirelessController_ReadSpi)){ ss << "(invalid size)" << std::endl; return ss.str(); }
40+
const auto* params = (const pabb_Message_NS1_WirelessController_ReadSpi*)body.c_str();
41+
ss << "seqnum = " << params->seqnum;
42+
ss << ", controller = " << params->controller_type;
43+
ss << ", address = 0x" << tostr_hex(params->address);
44+
ss << ", bytes = " << (size_t)params->bytes;
45+
return ss.str();
46+
}
47+
);
48+
register_message_converter(
49+
PABB_MSG_REQUEST_NS1_WIRELESS_CONTROLLER_WRITE_SPI,
50+
[](const std::string& body){
51+
std::ostringstream ss;
52+
ss << "PABB_MSG_REQUEST_NS1_WIRELESS_CONTROLLER_WRITE_SPI() - ";
53+
if (body.size() <= sizeof(pabb_Message_NS1_WirelessController_WriteSpi)){ ss << "(invalid size)" << std::endl; return ss.str(); }
54+
const auto* params = (const pabb_Message_NS1_WirelessController_WriteSpi*)body.c_str();
55+
ss << "seqnum = " << params->seqnum;
56+
ss << ", controller = " << params->controller_type;
57+
ss << ", address = 0x" << tostr_hex(params->address);
58+
ss << ", bytes = " << (size_t)params->bytes;
59+
return ss.str();
60+
}
61+
);
62+
register_message_converter(
63+
PABB_MSG_COMMAND_NS1_WIRELESS_CONTROLLER_BUTTONS,
64+
[](const std::string& body){
65+
// Disable this by default since it's very spammy.
66+
if (!GlobalSettings::instance().LOG_EVERYTHING){
67+
return std::string();
68+
}
69+
std::ostringstream ss;
70+
ss << "PABB_MSG_COMMAND_NS1_WIRELESS_CONTROLLER_BUTTONS() - ";
71+
if (body.size() != sizeof(pabb_Message_Command_NS1_WirelessController_Buttons)){ ss << "(invalid size)" << std::endl; return ss.str(); }
72+
const auto* params = (const pabb_Message_Command_NS1_WirelessController_Buttons*)body.c_str();
73+
ss << "seqnum = " << (uint64_t)params->seqnum;
74+
ss << ", milliseconds = " << params->milliseconds;
75+
return ss.str();
76+
}
77+
);
78+
register_message_converter(
79+
PABB_MSG_COMMAND_NS1_WIRELESS_CONTROLLER_FULL_STATE,
80+
[](const std::string& body){
81+
// Disable this by default since it's very spammy.
82+
if (!GlobalSettings::instance().LOG_EVERYTHING){
83+
return std::string();
84+
}
85+
std::ostringstream ss;
86+
ss << "PABB_MSG_COMMAND_NS1_WIRELESS_CONTROLLER_FULL_STATE() - ";
87+
if (body.size() != sizeof(pabb_Message_Command_NS1_WirelessController_FullState)){ ss << "(invalid size)" << std::endl; return ss.str(); }
88+
const auto* params = (const pabb_Message_Command_NS1_WirelessController_FullState*)body.c_str();
89+
ss << "seqnum = " << (uint64_t)params->seqnum;
90+
ss << ", milliseconds = " << params->milliseconds;
91+
return ss.str();
92+
}
93+
);
94+
return 0;
95+
}
96+
int init_Messages_ESP32 = register_message_converters_NS1_WirelessControllers();
97+
98+
99+
100+
}
101+
}

0 commit comments

Comments
 (0)