Skip to content

Commit 01fbfa3

Browse files
committed
Remove the old tick-based messages.
1 parent e2b9d27 commit 01fbfa3

File tree

8 files changed

+42
-122
lines changed

8 files changed

+42
-122
lines changed

Common/SerialPABotBase/SerialPABotBase_Messages_NS_Generic.h

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,22 @@ namespace SerialPABotBase{
2525
#endif
2626

2727

28-
29-
#define PABB_MSG_NS_GENERIC_CONTROLLER_STATE_TICKS 0x9f
28+
#define PABB_MSG_NS_GENERIC_CONTROLLER_STATE_MS 0x90
3029
typedef struct{
31-
seqnum_t seqnum;
32-
uint16_t buttons;
30+
uint8_t buttons0;
31+
uint8_t buttons1;
32+
// uint8_t buttons2;
33+
// uint8_t buttons3;
3334
uint8_t dpad;
3435
uint8_t left_joystick_x;
3536
uint8_t left_joystick_y;
3637
uint8_t right_joystick_x;
3738
uint8_t right_joystick_y;
38-
uint8_t ticks;
39-
} PABB_PACK pabb_Message_NS_Generic_ControllerStateTicks;
40-
41-
42-
43-
#define PABB_MSG_NS_GENERIC_CONTROLLER_STATE_MS 0x90
39+
} pabb_ControllerReport_NS_Generic_Controller;
4440
typedef struct{
4541
seqnum_t seqnum;
4642
uint16_t milliseconds;
47-
uint16_t buttons;
48-
uint8_t dpad;
49-
uint8_t left_joystick_x;
50-
uint8_t left_joystick_y;
51-
uint8_t right_joystick_x;
52-
uint8_t right_joystick_y;
43+
pabb_ControllerReport_NS_Generic_Controller report;
5344
} PABB_PACK pabb_Message_NS_Generic_ControllerStateMs;
5445

5546

SerialPrograms/Source/Controllers/ControllerTypes.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ enum class ControllerType{
4343

4444
enum class ControllerFeature{
4545
TickPrecise,
46-
TimingFlexibleMilliseconds,
4746

4847
// If we add support gyro or rumble, we will need to split this feature
4948
// since the Pokken controller doesn't support those.

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,14 @@ const std::map<
9696
{PABB_PID_PABOTBASE_ESP32, {
9797
{ControllerType::NintendoSwitch_WirelessProController, {
9898
ControllerFeature::TickPrecise,
99-
ControllerFeature::TimingFlexibleMilliseconds,
10099
ControllerFeature::NintendoSwitch_ProController,
101100
}},
102101
{ControllerType::NintendoSwitch_LeftJoycon, {
103102
ControllerFeature::TickPrecise,
104-
ControllerFeature::TimingFlexibleMilliseconds,
105103
ControllerFeature::NintendoSwitch_LeftJoycon,
106104
}},
107105
{ControllerType::NintendoSwitch_RightJoycon, {
108106
ControllerFeature::TickPrecise,
109-
ControllerFeature::TimingFlexibleMilliseconds,
110107
ControllerFeature::NintendoSwitch_RightJoycon,
111108
}},
112109
}},
@@ -115,7 +112,6 @@ const std::map<
115112
{PABB_PID_PABOTBASE_ESP32S3, {
116113
{ControllerType::NintendoSwitch_WiredProController, {
117114
ControllerFeature::TickPrecise,
118-
ControllerFeature::TimingFlexibleMilliseconds,
119115
ControllerFeature::NintendoSwitch_ProController,
120116
ControllerFeature::NintendoSwitch_DateSkip,
121117
}},
@@ -125,39 +121,34 @@ const std::map<
125121
{PABB_PID_PABOTBASE_ArduinoUnoR3, {
126122
{ControllerType::NintendoSwitch_WiredProController, {
127123
ControllerFeature::TickPrecise,
128-
ControllerFeature::TimingFlexibleMilliseconds,
129124
ControllerFeature::NintendoSwitch_ProController,
130125
ControllerFeature::NintendoSwitch_DateSkip,
131126
}},
132127
}},
133128
{PABB_PID_PABOTBASE_ArduinoLeonardo, {
134129
{ControllerType::NintendoSwitch_WiredProController, {
135130
ControllerFeature::TickPrecise,
136-
ControllerFeature::TimingFlexibleMilliseconds,
137131
ControllerFeature::NintendoSwitch_ProController,
138132
ControllerFeature::NintendoSwitch_DateSkip,
139133
}},
140134
}},
141135
{PABB_PID_PABOTBASE_ProMicro, {
142136
{ControllerType::NintendoSwitch_WiredProController, {
143137
ControllerFeature::TickPrecise,
144-
ControllerFeature::TimingFlexibleMilliseconds,
145138
ControllerFeature::NintendoSwitch_ProController,
146139
ControllerFeature::NintendoSwitch_DateSkip,
147140
}},
148141
}},
149142
{PABB_PID_PABOTBASE_Teensy2, {
150143
{ControllerType::NintendoSwitch_WiredProController, {
151144
ControllerFeature::TickPrecise,
152-
ControllerFeature::TimingFlexibleMilliseconds,
153145
ControllerFeature::NintendoSwitch_ProController,
154146
ControllerFeature::NintendoSwitch_DateSkip,
155147
}},
156148
}},
157149
{PABB_PID_PABOTBASE_TeensyPP2, {
158150
{ControllerType::NintendoSwitch_WiredProController, {
159151
ControllerFeature::TickPrecise,
160-
ControllerFeature::TimingFlexibleMilliseconds,
161152
ControllerFeature::NintendoSwitch_ProController,
162153
ControllerFeature::NintendoSwitch_DateSkip,
163154
}},

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS_Generic.cpp

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,6 @@ namespace SerialPABotBase{
1616

1717

1818
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-
);
3919
register_message_converter(
4020
PABB_MSG_NS_GENERIC_CONTROLLER_STATE_MS,
4121
[](const std::string& body){
@@ -48,10 +28,14 @@ int register_message_converters_push_button_framework(){
4828
if (body.size() != sizeof(pabb_Message_NS_Generic_ControllerStateMs)){ ss << "(invalid size)" << std::endl; return ss.str(); }
4929
const auto* params = (const pabb_Message_NS_Generic_ControllerStateMs*)body.c_str();
5030
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 << ")";
31+
32+
uint16_t buttons = params->report.buttons0;
33+
buttons |= (uint16_t)params->report.buttons1 << 8;
34+
ss << ", buttons = " << buttons << " (" << button_to_string((NintendoSwitch::Button)buttons) << ")";
35+
36+
ss << ", dpad = " << dpad_to_string((NintendoSwitch::DpadPosition)params->report.dpad);
37+
ss << ", LJ = (" << (int)params->report.left_joystick_x << "," << (int)params->report.left_joystick_y << ")";
38+
ss << ", RJ = (" << (int)params->report.right_joystick_x << "," << (int)params->report.right_joystick_y << ")";
5539
ss << ", milliseconds = " << params->milliseconds;
5640
return ss.str();
5741
}

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Routines_NS_Generic.h

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,6 @@ namespace PokemonAutomation{
1414
namespace SerialPABotBase{
1515

1616

17-
18-
class DeviceRequest_NS_Generic_ControllerStateTicks : public BotBaseRequest{
19-
public:
20-
pabb_Message_NS_Generic_ControllerStateTicks params;
21-
DeviceRequest_NS_Generic_ControllerStateTicks(
22-
uint16_t buttons,
23-
uint8_t dpad,
24-
uint8_t left_joystick_x,
25-
uint8_t left_joystick_y,
26-
uint8_t right_joystick_x,
27-
uint8_t right_joystick_y,
28-
uint8_t ticks
29-
)
30-
: BotBaseRequest(true)
31-
{
32-
params.seqnum = 0;
33-
params.buttons = buttons;
34-
params.dpad = dpad;
35-
params.left_joystick_x = left_joystick_x;
36-
params.left_joystick_y = left_joystick_y;
37-
params.right_joystick_x = right_joystick_x;
38-
params.right_joystick_y = right_joystick_y;
39-
params.ticks = ticks;
40-
}
41-
virtual BotBaseMessage message() const override{
42-
return BotBaseMessage(PABB_MSG_NS_GENERIC_CONTROLLER_STATE_TICKS, params);
43-
}
44-
};
45-
46-
47-
4817
class DeviceRequest_NS_Generic_ControllerStateMs : public BotBaseRequest{
4918
public:
5019
pabb_Message_NS_Generic_ControllerStateMs params;
@@ -59,14 +28,21 @@ class DeviceRequest_NS_Generic_ControllerStateMs : public BotBaseRequest{
5928
)
6029
: BotBaseRequest(true)
6130
{
31+
memset(&params, 0, sizeof(params));
32+
6233
params.seqnum = 0;
6334
params.milliseconds = milliseconds;
64-
params.buttons = buttons;
65-
params.dpad = dpad;
66-
params.left_joystick_x = left_joystick_x;
67-
params.left_joystick_y = left_joystick_y;
68-
params.right_joystick_x = right_joystick_x;
69-
params.right_joystick_y = right_joystick_y;
35+
36+
params.report.buttons0 = (uint8_t)buttons;
37+
params.report.buttons1 = (uint8_t)(buttons >> 8);
38+
// params.report.buttons2 = 0;
39+
// params.report.buttons3 = 0;
40+
41+
params.report.dpad = dpad;
42+
params.report.left_joystick_x = left_joystick_x;
43+
params.report.left_joystick_y = left_joystick_y;
44+
params.report.right_joystick_x = right_joystick_x;
45+
params.report.right_joystick_y = right_joystick_y;
7046
}
7147
virtual BotBaseMessage message() const override{
7248
return BotBaseMessage(PABB_MSG_NS_GENERIC_CONTROLLER_STATE_MS, params);

SerialPrograms/Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_PokkenController.cpp

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ SerialPABotBase_PokkenController::SerialPABotBase_PokkenController(
3636
ControllerType::NintendoSwitch_WiredProController,
3737
connection
3838
)
39-
, m_use_milliseconds(m_supported_features.contains(ControllerFeature::TimingFlexibleMilliseconds))
4039
, m_stopping(false)
4140
, m_status_thread(&SerialPABotBase_PokkenController::status_thread, this)
4241
{}
@@ -190,37 +189,19 @@ void SerialPABotBase_PokkenController::push_state(const Cancellable* cancellable
190189
// duration.
191190
Milliseconds time_left = std::chrono::duration_cast<Milliseconds>(duration);
192191

193-
if (m_use_milliseconds){
194-
while (time_left > Milliseconds::zero()){
195-
Milliseconds current = std::min(time_left, 65535ms);
196-
m_serial->issue_request(
197-
SerialPABotBase::DeviceRequest_NS_Generic_ControllerStateMs(
198-
(uint16_t)current.count(),
199-
buttons,
200-
dpad,
201-
left_x, left_y,
202-
right_x, right_y
203-
),
204-
cancellable
205-
);
206-
time_left -= current;
207-
}
208-
}else{
209-
while (time_left > Milliseconds::zero()){
210-
Milliseconds current_ms = std::min(time_left, 255 * 8ms);
211-
uint8_t current_ticks = (uint8_t)milliseconds_to_ticks_8ms(current_ms.count());
212-
m_serial->issue_request(
213-
SerialPABotBase::DeviceRequest_NS_Generic_ControllerStateTicks(
214-
buttons,
215-
dpad,
216-
left_x, left_y,
217-
right_x, right_y,
218-
current_ticks
219-
),
220-
cancellable
221-
);
222-
time_left -= current_ms;
223-
}
192+
while (time_left > Milliseconds::zero()){
193+
Milliseconds current = std::min(time_left, 65535ms);
194+
m_serial->issue_request(
195+
SerialPABotBase::DeviceRequest_NS_Generic_ControllerStateMs(
196+
(uint16_t)current.count(),
197+
buttons,
198+
dpad,
199+
left_x, left_y,
200+
right_x, right_y
201+
),
202+
cancellable
203+
);
204+
time_left -= current;
224205
}
225206
}
226207

SerialPrograms/Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_PokkenController.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class SerialPABotBase_PokkenController final :
5555
}
5656

5757
virtual Milliseconds ticksize() const override{
58-
return m_use_milliseconds ? Milliseconds(0) : Milliseconds(8);
58+
return Milliseconds(0);
5959
}
6060
virtual Milliseconds cooldown() const override{
6161
return Milliseconds(8);
@@ -228,7 +228,6 @@ class SerialPABotBase_PokkenController final :
228228

229229

230230
private:
231-
bool m_use_milliseconds;
232231
CancellableHolder<CancellableScope> m_scope;
233232
std::atomic<bool> m_stopping;
234233
std::mutex m_sleep_lock;

SerialPrograms/Source/NintendoSwitch/Controllers/SysbotBase/SysbotBase3_ProController.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ ProController_SysbotBase3::~ProController_SysbotBase3(){
4343
const ControllerFeatures& ProController_SysbotBase3::controller_features() const{
4444
static const ControllerFeatures features{
4545
ControllerFeature::TickPrecise,
46-
ControllerFeature::TimingFlexibleMilliseconds,
4746
ControllerFeature::NintendoSwitch_ProController,
4847
ControllerFeature::NintendoSwitch_DateSkip,
4948
};

0 commit comments

Comments
 (0)