Skip to content

Commit 385b3e1

Browse files
committed
Calibrate joysticks to real controller SPI.
1 parent 881ce19 commit 385b3e1

File tree

7 files changed

+60
-35
lines changed

7 files changed

+60
-35
lines changed

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase.cpp

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -86,28 +86,6 @@ const std::map<
8686
>
8787
> SUPPORTED_VERSIONS{
8888
{2025040500, {
89-
{PABB_PID_PABOTBASE_ESP32, {
90-
{ControllerType::NintendoSwitch_WirelessProController, {
91-
ControllerFeature::TickPrecise,
92-
ControllerFeature::TimingFlexibleMilliseconds,
93-
ControllerFeature::QueryCommandQueueSize,
94-
ControllerFeature::NintendoSwitch_ProController,
95-
}},
96-
{ControllerType::NintendoSwitch_LeftJoycon, {
97-
ControllerFeature::TickPrecise,
98-
ControllerFeature::TimingFlexibleMilliseconds,
99-
ControllerFeature::QueryCommandQueueSize,
100-
ControllerFeature::NintendoSwitch_LeftJoycon,
101-
}},
102-
{ControllerType::NintendoSwitch_RightJoycon, {
103-
ControllerFeature::TickPrecise,
104-
ControllerFeature::TimingFlexibleMilliseconds,
105-
ControllerFeature::QueryCommandQueueSize,
106-
ControllerFeature::NintendoSwitch_RightJoycon,
107-
}},
108-
}},
109-
// }},
110-
// {2025040500, {
11189
{PABB_PID_PABOTBASE_ArduinoUnoR3, {
11290
{ControllerType::NintendoSwitch_WiredProController, {
11391
ControllerFeature::TickPrecise,
@@ -160,6 +138,7 @@ const std::map<
160138
}},
161139
}},
162140
}},
141+
#if 0
163142
{2025042000, {
164143
{PABB_PID_PABOTBASE_CH552, {
165144
{ControllerType::NintendoSwitch_WiredProController, {
@@ -170,6 +149,29 @@ const std::map<
170149
}},
171150
}},
172151
}},
152+
#endif
153+
{2025042600, {
154+
{PABB_PID_PABOTBASE_ESP32, {
155+
{ControllerType::NintendoSwitch_WirelessProController, {
156+
ControllerFeature::TickPrecise,
157+
ControllerFeature::TimingFlexibleMilliseconds,
158+
ControllerFeature::QueryCommandQueueSize,
159+
ControllerFeature::NintendoSwitch_ProController,
160+
}},
161+
{ControllerType::NintendoSwitch_LeftJoycon, {
162+
ControllerFeature::TickPrecise,
163+
ControllerFeature::TimingFlexibleMilliseconds,
164+
ControllerFeature::QueryCommandQueueSize,
165+
ControllerFeature::NintendoSwitch_LeftJoycon,
166+
}},
167+
{ControllerType::NintendoSwitch_RightJoycon, {
168+
ControllerFeature::TickPrecise,
169+
ControllerFeature::TimingFlexibleMilliseconds,
170+
ControllerFeature::QueryCommandQueueSize,
171+
ControllerFeature::NintendoSwitch_RightJoycon,
172+
}},
173+
}},
174+
}},
173175
};
174176

175177

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ class SerialPABotBase_WirelessController : public SerialPABotBase_Controller{
9090

9191
// cout << "wx = " << wx << ", wy = " << wy << endl;
9292
// wy = 2048;
93-
// wx = 260;
93+
// wx = 1874;
94+
// wx = 320;
9495

9596
data[0] = (uint8_t)wx;
9697
data[1] = (uint8_t)(wx >> 8 | wy << 4);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class SerialPABotBase_WirelessJoycon final :
1919
public JoyconController,
2020
public SerialPABotBase_WirelessController
2121
{
22-
static constexpr uint16_t JOYSTICK_MIN_THRESHOLD = 1873;
22+
static constexpr uint16_t JOYSTICK_MIN_THRESHOLD = 1874;
2323
static constexpr uint16_t JOYSTICK_MAX_THRESHOLD = 260;
2424

2525
public:

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ void SerialPABotBase_WirelessProController::push_state(const Cancellable* cancel
7272
);
7373
}
7474

75-
PABB_NintendoSwitch_GyroState gyro{};
75+
PABB_NintendoSwitch_GyroState gyro{
76+
0x0000,
77+
0x0000,
78+
0x0000,
79+
0x0000,
80+
0x0000,
81+
0x0000,
82+
};
7683
bool gyro_active = populate_report_gyro(gyro);
7784

7885
// gyro_active = true;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class SerialPABotBase_WirelessProController final :
1919
public ProController,
2020
public SerialPABotBase_WirelessController
2121
{
22-
static constexpr uint16_t JOYSTICK_MIN_THRESHOLD = 1897;
22+
static constexpr uint16_t JOYSTICK_MIN_THRESHOLD = 1874;
2323
static constexpr uint16_t JOYSTICK_MAX_THRESHOLD = 320;
2424

2525
public:

SerialPrograms/Source/NintendoSwitch/DevPrograms/JoyconProgram.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ void JoyconProgram::program(SingleSwitchProgramEnvironment& env, CancellableScop
4545
// No support for gyro yet. That's coming later.
4646
//
4747

48-
// pbf_move_joystick(context, 64, 64, 10000ms, 0ms);
48+
pbf_move_joystick(context, 64, 64, 10000ms, 0ms);
4949

50-
#if 1
50+
#if 0
5151
pbf_press_button(context, BUTTON_A, 200ms, 2000ms);
5252
pbf_press_button(context, BUTTON_HOME, 200ms, 2000ms);
5353
pbf_move_joystick(context, 128, 0, 100ms, 100ms);

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,15 +319,30 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
319319
// std::terminate();
320320

321321

322-
ssf_press_button(context, Button::BUTTON_ZR, 1s, 60s, 0ms);
322+
#if 1
323+
ssf_press_button(context, Button::BUTTON_ZR, 1s, 60h, 0ms);
324+
// context->issue_gyro_rotate_x(&scope, 0s, 60h, 0ms, 0x1000);
325+
// context->issue_gyro_rotate_y(&scope, 0s, 60h, 0ms, 0x0000);
326+
// context->issue_gyro_rotate_z(&scope, 0s, 60h, 0ms, 0x1000);
323327

324-
while (true){
325-
context->issue_gyro_rotate_z(&scope, 1s, 1s, 0s, +1);
326-
context->issue_gyro_rotate_z(&scope, 1s, 1s, 0s, 0x0000);
327-
context->issue_gyro_rotate_z(&scope, 1s, 1s, 0s, -1);
328-
context->issue_gyro_rotate_z(&scope, 1s, 1s, 0s, 0x0000);
329-
}
328+
// auto duration = 10s;
329+
330+
// context->issue_gyro_rotate_x(&scope, duration, duration, 0s, 0x1000);
331+
// context->issue_nop(&scope, 60h);
330332

333+
#if 1
334+
auto duration = 15ms;
335+
for (size_t c = 0; c < 65536; c += 1){
336+
context->issue_gyro_accel_x(&scope, 0s, duration, 0s, 688 + 0*c % 2);
337+
context->issue_gyro_accel_y(&scope, 0s, duration, 0s, 1*c % 2);
338+
context->issue_gyro_accel_z(&scope, 0s, duration, 0s, -4038 + 0*c % 2);
339+
context->issue_gyro_rotate_x(&scope, 0s, duration, 0s, (uint16_t)(0x0000 + 1*c));
340+
context->issue_gyro_rotate_y(&scope, 0s, duration, 0s, (uint16_t)(0x0000 + 1*c));
341+
context->issue_gyro_rotate_z(&scope, 0s, duration, 0s, (uint16_t)(0x0000 + 0*c));
342+
context->issue_nop(&scope, duration);
343+
}
344+
#endif
345+
#endif
331346

332347

333348
#if 0

0 commit comments

Comments
 (0)