Skip to content

Commit 1175535

Browse files
committed
Refactor date spam to reuse code. Add some work on ESP32 joycon date spam for Switch 2.
1 parent 8bdac05 commit 1175535

File tree

10 files changed

+297
-254
lines changed

10 files changed

+297
-254
lines changed

SerialPrograms/Source/NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,46 @@ void ssf_press_joystick(
171171
void ssf_mash1_button(JoyconContext& context, Button button, Milliseconds duration){
172172
context->issue_mash_button(&context, button, duration);
173173
}
174+
void ssf_issue_scroll(
175+
JoyconContext& context,
176+
DpadPosition direction,
177+
Milliseconds delay
178+
){
179+
ssf_issue_scroll(context, direction, delay, 2*delay, delay);
180+
}
181+
void ssf_issue_scroll(
182+
JoyconContext& context,
183+
DpadPosition direction,
184+
Milliseconds delay, Milliseconds hold, Milliseconds cool
185+
){
186+
switch (direction){
187+
case DpadPosition::DPAD_UP:
188+
ssf_press_joystick(context, 128, 0, delay, hold, cool);
189+
break;
190+
case DpadPosition::DPAD_UP_RIGHT:
191+
ssf_press_joystick(context, 255, 0, delay, hold, cool);
192+
break;
193+
case DpadPosition::DPAD_RIGHT:
194+
ssf_press_joystick(context, 255, 128, delay, hold, cool);
195+
break;
196+
case DpadPosition::DPAD_DOWN_RIGHT:
197+
ssf_press_joystick(context, 255, 255, delay, hold, cool);
198+
break;
199+
case DpadPosition::DPAD_DOWN:
200+
ssf_press_joystick(context, 128, 255, delay, hold, cool);
201+
break;
202+
case DpadPosition::DPAD_DOWN_LEFT:
203+
ssf_press_joystick(context, 0, 255, delay, hold, cool);
204+
break;
205+
case DpadPosition::DPAD_LEFT:
206+
ssf_press_joystick(context, 0, 128, delay, hold, cool);
207+
break;
208+
case DpadPosition::DPAD_UP_LEFT:
209+
ssf_press_joystick(context, 0, 0, delay, hold, cool);
210+
break;
211+
default:;
212+
}
213+
}
174214

175215

176216

SerialPrograms/Source/NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,16 @@ void ssf_press_joystick(
185185
Milliseconds delay, Milliseconds hold, Milliseconds cool = 0ms
186186
);
187187
void ssf_mash1_button (JoyconContext& context, Button button, Milliseconds duration);
188+
void ssf_issue_scroll(
189+
JoyconContext& context,
190+
DpadPosition direction,
191+
Milliseconds delay
192+
);
193+
void ssf_issue_scroll(
194+
JoyconContext& context,
195+
DpadPosition direction,
196+
Milliseconds delay, Milliseconds hold, Milliseconds cool
197+
);
188198

189199

190200

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ void SerialPABotBase_WirelessJoycon::push_state_right_joycon(const Cancellable*
175175
);
176176
}
177177

178+
// cout << (int)m_right_joystick.x << " - " << (int)m_right_joystick.y << ": " << std::chrono::duration_cast<Milliseconds>(duration).count() << endl;
179+
178180
PABB_NintendoSwitch_GyroState gyro{};
179181
bool gyro_active = populate_report_gyro(gyro);
180182

SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch1_HomeToDateTime.cpp

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,6 @@ void home_to_date_time_Switch1_sbb_blind(
206206
}
207207

208208

209-
210-
211-
212209
void home_to_date_time_Switch1_wired_feedback(
213210
VideoStream& stream, ProControllerContext& context, bool to_date_change
214211
){
@@ -333,5 +330,69 @@ void home_to_date_time_Switch1_wired_feedback(
333330

334331

335332

333+
334+
335+
336+
void home_to_date_time_Switch1_joycon_blind(JoyconContext& context, bool to_date_change){
337+
Milliseconds tv = context->timing_variation();
338+
Milliseconds unit = 100ms + tv;
339+
340+
//From ControllerPerformanceClass::SerialPABotBase_Wireless
341+
//as Joycon will only have that controller type
342+
343+
pbf_move_joystick(context, 255, 128, 2*unit, unit);
344+
pbf_move_joystick(context, 255, 128, 2*unit, unit);
345+
pbf_move_joystick(context, 255, 128, 2*unit, unit);
346+
347+
// Down twice in case we drop one.
348+
pbf_move_joystick(context, 128, 255, 2*unit, unit);
349+
pbf_move_joystick(context, 128, 255, 2*unit, unit);
350+
351+
pbf_move_joystick(context, 0, 128, 2*unit, unit);
352+
353+
// Press A multiple times to make sure one goes through.
354+
pbf_press_button(context, BUTTON_A, 2*unit, unit);
355+
pbf_press_button(context, BUTTON_A, 2*unit, unit);
356+
pbf_press_button(context, BUTTON_A, 2*unit, unit);
357+
358+
// Scroll to System, move right to top option (update)
359+
pbf_move_joystick(context, 128, 255, 2500ms, unit);
360+
pbf_move_joystick(context, 255, 128, 500ms, unit);
361+
362+
// To date/time
363+
pbf_move_joystick(context, 128, 255, 2*unit, unit);
364+
pbf_move_joystick(context, 128, 255, 2*unit, unit);
365+
context.wait_for_all_requests();
366+
pbf_move_joystick(context, 128, 255, 525ms, unit);
367+
//pbf_move_joystick(context, 128, 255, 365ms, 305ms);
368+
pbf_move_joystick(context, 128, 255, 2*unit, unit);
369+
//pbf_move_joystick(context, 128, 255, 2*unit, unit);
370+
context.wait_for_all_requests();
371+
372+
if (!to_date_change){
373+
ssf_press_button(context, BUTTON_A, 360ms, 2*unit, unit);
374+
return;
375+
}
376+
377+
//ssf_press_button(context, BUTTON_A, unit);
378+
pbf_press_button(context, BUTTON_A, 2*unit, unit);
379+
context.wait_for_all_requests();
380+
{
381+
auto iterations = Milliseconds(216) / unit + 1;
382+
do{
383+
pbf_move_joystick(context, 128, 255, 2*unit, unit);
384+
}while (--iterations);
385+
}
386+
pbf_move_joystick(context, 128, 255, 2*unit, 0ms);
387+
}
388+
389+
390+
391+
392+
393+
394+
395+
396+
336397
}
337398
}

0 commit comments

Comments
 (0)