Skip to content

Commit 165322f

Browse files
committed
My fucking god... ESP32 wireless is tick-precise. Also fix dpad incorrectly sticking.
1 parent 7b89758 commit 165322f

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,16 @@ const std::map<
7777
}},
7878
{PABB_PID_PABOTBASE_ESP32, {
7979
{ControllerType::NintendoSwitch_WirelessProController, {
80+
ControllerFeature::TickPrecise,
8081
ControllerFeature::QueryCommandQueueSize,
8182
ControllerFeature::NintendoSwitch_ProController,
8283
}},
8384
{ControllerType::NintendoSwitch_LeftJoycon, {
85+
ControllerFeature::TickPrecise,
8486
ControllerFeature::QueryCommandQueueSize,
8587
}},
8688
{ControllerType::NintendoSwitch_RightJoycon, {
89+
ControllerFeature::TickPrecise,
8790
ControllerFeature::QueryCommandQueueSize,
8891
}},
8992
}},

SerialPrograms/Source/NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <sstream>
88
#include "ClientSource/Libraries/MessageConverter.h"
9+
#include "CommonFramework/GlobalSettingsPanel.h"
910
#include "NintendoSwitch/NintendoSwitch_Settings.h"
1011
#include "NintendoSwitch_Commands_PushButtons.h"
1112
#include "NintendoSwitch_Commands_Superscalar.h"
@@ -155,6 +156,10 @@ int register_message_converters_push_button_framework(){
155156
register_message_converter(
156157
PABB_MSG_CONTROLLER_STATE,
157158
[](const std::string& body){
159+
// Disable this by default since it's very spammy.
160+
if (!GlobalSettings::instance().LOG_EVERYTHING){
161+
return std::string();
162+
}
158163
std::ostringstream ss;
159164
ss << "controller_state() - ";
160165
if (body.size() != sizeof(pabb_controller_state)){ ss << "(invalid size)" << std::endl; return ss.str(); }

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ void SerialPABotBase_PokkenController::status_thread(){
171171
error = e.message();
172172
}catch (ConnectionException& e){
173173
error = e.message();
174+
}catch (...){
175+
error = "Unknown error.";
174176
}
175177
if (!error.empty()){
176178
m_handle.set_status_line1(error, COLOR_RED);

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ SerialPABotBase_WirelessProController::SerialPABotBase_WirelessProController(
3434
: SerialPABotBase_ProController(
3535
logger,
3636
ControllerType::NintendoSwitch_WirelessProController,
37-
14ms,
37+
0ms,
3838
connection,
3939
requirements
4040
)
@@ -105,6 +105,10 @@ int register_message_converters_ESP32(){
105105
register_message_converter(
106106
PABB_MSG_ESP32_REPORT,
107107
[](const std::string& body){
108+
// Disable this by default since it's very spammy.
109+
if (!GlobalSettings::instance().LOG_EVERYTHING){
110+
return std::string();
111+
}
108112
std::ostringstream ss;
109113
ss << "ESP32_controller_state() - ";
110114
if (body.size() != sizeof(pabb_esp32_report30)){ ss << "(invalid size)" << std::endl; return ss.str(); }
@@ -164,11 +168,13 @@ void SerialPABotBase_WirelessProController::push_state(const Cancellable* cancel
164168
// 7 = Charging Grip
165169

166170
// Left
167-
SplitDpad dpad = convert_unified_to_split_dpad(m_dpad.position);
168-
report.button5 |= (dpad.down ? 1 : 0) << 0;
169-
report.button5 |= (dpad.up ? 1 : 0) << 1;
170-
report.button5 |= (dpad.right ? 1 : 0) << 2;
171-
report.button5 |= (dpad.left ? 1 : 0) << 3;
171+
if (m_dpad.is_busy()){
172+
SplitDpad dpad = convert_unified_to_split_dpad(m_dpad.position);
173+
report.button5 |= (dpad.down ? 1 : 0) << 0;
174+
report.button5 |= (dpad.up ? 1 : 0) << 1;
175+
report.button5 |= (dpad.right ? 1 : 0) << 2;
176+
report.button5 |= (dpad.left ? 1 : 0) << 3;
177+
}
172178
// 4 = Left Joycon: SR
173179
// 5 = Left Joycon: SL
174180
report.button5 |= (m_buttons[4].is_busy() ? 1 : 0) << 6; // L
@@ -265,18 +271,22 @@ void SerialPABotBase_WirelessProController::status_thread(){
265271
? html_color_text("Yes", theme_friendly_darkblue())
266272
: html_color_text("No", COLOR_RED)
267273
);
268-
str += ", Paired: " + (status_paired
274+
str += " - Paired: " + (status_paired
269275
? html_color_text("Yes", theme_friendly_darkblue())
270276
: html_color_text("No", COLOR_RED)
271277
);
272278

273279
m_handle.set_status_line1(str);
280+
}catch (OperationCancelledException&){
281+
break;
274282
}catch (InvalidConnectionStateException&){
275283
break;
276284
}catch (SerialProtocolException& e){
277285
error = e.message();
278286
}catch (ConnectionException& e){
279287
error = e.message();
288+
}catch (...){
289+
error = "Unknown error.";
280290
}
281291
if (!error.empty()){
282292
m_handle.set_status_line1(error, COLOR_RED);

0 commit comments

Comments
 (0)