Skip to content

Commit 17b646a

Browse files
committed
Reorder some parameters.
1 parent 8bf10ae commit 17b646a

11 files changed

+178
-160
lines changed

SerialPrograms/Source/Integrations/ProgramTracker.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ std::string ProgramTracker::nsw_press_button(uint64_t console_id, NintendoSwitch
125125
try{
126126
err = iter->second.first->controller().try_run<ProController>(
127127
[=](ProController& controller){
128-
controller.issue_buttons(nullptr, button, duration, duration, 0ms);
128+
controller.issue_buttons(nullptr, duration, duration, 0ms, button);
129129
}
130130
);
131131
}catch (Exception& e){
@@ -155,7 +155,7 @@ std::string ProgramTracker::nsw_press_dpad(uint64_t console_id, NintendoSwitch::
155155
try{
156156
err = iter->second.first->controller().try_run<ProController>(
157157
[=](ProController& controller){
158-
controller.issue_dpad(nullptr, position, duration, duration, 0ms);
158+
controller.issue_dpad(nullptr, duration, duration, 0ms, position);
159159
}
160160
);
161161
}catch (Exception& e){
@@ -185,7 +185,7 @@ std::string ProgramTracker::nsw_press_left_joystick(uint64_t console_id, uint8_t
185185
try{
186186
err = iter->second.first->controller().try_run<ProController>(
187187
[=](ProController& controller){
188-
controller.issue_left_joystick(nullptr, x, y, duration, duration, 0ms);
188+
controller.issue_left_joystick(nullptr, duration, duration, 0ms, x, y);
189189
}
190190
);
191191
}catch (Exception& e){
@@ -215,7 +215,7 @@ std::string ProgramTracker::nsw_press_right_joystick(uint64_t console_id, uint8_
215215
try{
216216
err = iter->second.first->controller().try_run<ProController>(
217217
[=](ProController& controller){
218-
controller.issue_right_joystick(nullptr, x, y, duration, duration, 0ms);
218+
controller.issue_right_joystick(nullptr, duration, duration, 0ms, x, y);
219219
}
220220
);
221221
}catch (Exception& e){

SerialPrograms/Source/NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ void pbf_controller_state(
9191
){
9292
context->issue_full_controller_state(
9393
&context,
94+
ticks*8ms,
9495
button, position,
9596
left_x, left_y,
96-
right_x, right_y,
97-
ticks*8ms
97+
right_x, right_y
9898
);
9999
}
100100
void pbf_controller_state(
@@ -107,10 +107,10 @@ void pbf_controller_state(
107107
){
108108
context->issue_full_controller_state(
109109
&context,
110+
duration,
110111
button, position,
111112
left_x, left_y,
112-
right_x, right_y,
113-
duration
113+
right_x, right_y
114114
);
115115
}
116116

SerialPrograms/Source/NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.cpp

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,17 @@ void ssf_press_button(
3030
uint16_t delay, uint16_t hold, uint8_t cool
3131
){
3232
context->issue_buttons(
33-
&context, button,
34-
delay*8ms, hold*8ms, cool*8ms
33+
&context,
34+
delay*8ms, hold*8ms, cool*8ms,
35+
button
3536
);
3637
}
3738
void ssf_press_button(
3839
ProControllerContext& context,
3940
Button button,
4041
Milliseconds delay, Milliseconds hold, Milliseconds cool
4142
){
42-
context->issue_buttons(&context, button, delay, hold, cool);
43+
context->issue_buttons(&context, delay, hold, cool, button);
4344
}
4445

4546
void ssf_press_dpad(
@@ -48,16 +49,17 @@ void ssf_press_dpad(
4849
uint16_t delay, uint16_t hold, uint8_t cool
4950
){
5051
context->issue_dpad(
51-
&context, position,
52-
delay*8ms, hold*8ms, cool*8ms
52+
&context,
53+
delay*8ms, hold*8ms, cool*8ms,
54+
position
5355
);
5456
}
5557
void ssf_press_dpad(
5658
ProControllerContext& context,
5759
DpadPosition position,
5860
Milliseconds delay, Milliseconds hold, Milliseconds cool
5961
){
60-
context->issue_dpad(&context, position, delay, hold, cool);
62+
context->issue_dpad(&context, delay, hold, cool, position);
6163
}
6264

6365
void ssf_press_left_joystick(
@@ -66,48 +68,50 @@ void ssf_press_left_joystick(
6668
uint16_t delay, uint16_t hold, uint8_t cool
6769
){
6870
context->issue_left_joystick(
69-
&context, x, y,
70-
delay*8ms, hold*8ms, cool*8ms
71+
&context,
72+
delay*8ms, hold*8ms, cool*8ms,
73+
x, y
7174
);
7275
}
7376
void ssf_press_left_joystick(
7477
ProControllerContext& context,
7578
uint8_t x, uint8_t y,
7679
Milliseconds delay, Milliseconds hold, Milliseconds cool
7780
){
78-
context->issue_left_joystick(&context, x, y, delay, hold, cool);
81+
context->issue_left_joystick(&context, delay, hold, cool, x, y);
7982
}
8083
void ssf_press_right_joystick(
8184
ProControllerContext& context,
8285
uint8_t x, uint8_t y,
8386
uint16_t delay, uint16_t hold, uint8_t cool
8487
){
8588
context->issue_right_joystick(
86-
&context, x, y,
87-
delay*8ms, hold*8ms, cool*8ms
89+
&context,
90+
delay*8ms, hold*8ms, cool*8ms,
91+
x, y
8892
);
8993
}
9094
void ssf_press_right_joystick(
9195
ProControllerContext& context,
9296
uint8_t x, uint8_t y,
9397
Milliseconds delay, Milliseconds hold, Milliseconds cool
9498
){
95-
context->issue_right_joystick(&context, x, y, delay, hold, cool);
99+
context->issue_right_joystick(&context, delay, hold, cool, x, y);
96100
}
97101

98102

99103

100104
void ssf_mash1_button(ProControllerContext& context, Button button, uint16_t ticks){
101-
context->issue_mash_button(&context, button, ticks*8ms);
105+
context->issue_mash_button(&context, ticks*8ms, button);
102106
}
103107
void ssf_mash1_button(ProControllerContext& context, Button button, Milliseconds duration){
104-
context->issue_mash_button(&context, button, duration);
108+
context->issue_mash_button(&context, duration, button);
105109
}
106110
void ssf_mash2_button(ProControllerContext& context, Button button0, Button button1, uint16_t ticks){
107-
context->issue_mash_button(&context, button0, button1, ticks*8ms);
111+
context->issue_mash_button(&context, ticks*8ms, button0, button1);
108112
}
109113
void ssf_mash2_button(ProControllerContext& context, Button button0, Button button1, Milliseconds duration){
110-
context->issue_mash_button(&context, button0, button1, duration);
114+
context->issue_mash_button(&context, duration, button0, button1);
111115
}
112116
void ssf_mash_AZs(ProControllerContext& context, uint16_t ticks){
113117
context->issue_mash_AZs(&context, ticks*8ms);
@@ -121,23 +125,24 @@ void ssf_issue_scroll(
121125
uint16_t delay, uint16_t hold, uint8_t cool
122126
){
123127
context->issue_system_scroll(
124-
&context, direction,
125-
delay*8ms, hold*8ms, cool*8ms
128+
&context,
129+
delay*8ms, hold*8ms, cool*8ms,
130+
direction
126131
);
127132
}
128133
void ssf_issue_scroll(
129134
ProControllerContext& context,
130135
DpadPosition direction,
131136
Milliseconds delay
132137
){
133-
context->issue_system_scroll(&context, direction, delay, 2*delay, delay);
138+
context->issue_system_scroll(&context, delay, 2*delay, delay, direction);
134139
}
135140
void ssf_issue_scroll(
136141
ProControllerContext& context,
137142
DpadPosition direction,
138143
Milliseconds delay, Milliseconds hold, Milliseconds cool
139144
){
140-
context->issue_system_scroll(&context, direction, delay, hold, cool);
145+
context->issue_system_scroll(&context, delay, hold, cool, direction);
141146
}
142147

143148

SerialPrograms/Source/NintendoSwitch/Controllers/NintendoSwitch_ControllerWithScheduler.cpp

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ void ControllerWithScheduler::issue_nop(const Cancellable* cancellable, Millisec
5252
}
5353
void ControllerWithScheduler::issue_buttons(
5454
const Cancellable* cancellable,
55-
Button button,
56-
Milliseconds delay, Milliseconds hold, Milliseconds cooldown
55+
Milliseconds delay, Milliseconds hold, Milliseconds cooldown,
56+
Button button
5757
){
5858
std::lock_guard<std::mutex> lg0(m_issue_lock);
5959
std::lock_guard<std::mutex> lg1(m_state_lock);
@@ -90,8 +90,8 @@ void ControllerWithScheduler::issue_buttons(
9090
}
9191
void ControllerWithScheduler::issue_dpad(
9292
const Cancellable* cancellable,
93-
DpadPosition position,
94-
Milliseconds delay, Milliseconds hold, Milliseconds cooldown
93+
Milliseconds delay, Milliseconds hold, Milliseconds cooldown,
94+
DpadPosition position
9595
){
9696
std::lock_guard<std::mutex> lg0(m_issue_lock);
9797
std::lock_guard<std::mutex> lg1(m_state_lock);
@@ -115,8 +115,8 @@ void ControllerWithScheduler::issue_dpad(
115115
}
116116
void ControllerWithScheduler::issue_left_joystick(
117117
const Cancellable* cancellable,
118-
uint8_t x, uint8_t y,
119-
Milliseconds delay, Milliseconds hold, Milliseconds cooldown
118+
Milliseconds delay, Milliseconds hold, Milliseconds cooldown,
119+
uint8_t x, uint8_t y
120120
){
121121
std::lock_guard<std::mutex> lg0(m_issue_lock);
122122
std::lock_guard<std::mutex> lg1(m_state_lock);
@@ -142,8 +142,8 @@ void ControllerWithScheduler::issue_left_joystick(
142142
}
143143
void ControllerWithScheduler::issue_right_joystick(
144144
const Cancellable* cancellable,
145-
uint8_t x, uint8_t y,
146-
Milliseconds delay, Milliseconds hold, Milliseconds cooldown
145+
Milliseconds delay, Milliseconds hold, Milliseconds cooldown,
146+
uint8_t x, uint8_t y
147147
){
148148
std::lock_guard<std::mutex> lg0(m_issue_lock);
149149
std::lock_guard<std::mutex> lg1(m_state_lock);
@@ -168,11 +168,11 @@ void ControllerWithScheduler::issue_right_joystick(
168168
}
169169
void ControllerWithScheduler::issue_full_controller_state(
170170
const Cancellable* cancellable,
171+
Milliseconds hold,
171172
Button button,
172173
DpadPosition position,
173174
uint8_t left_x, uint8_t left_y,
174-
uint8_t right_x, uint8_t right_y,
175-
Milliseconds hold
175+
uint8_t right_x, uint8_t right_y
176176
){
177177
std::lock_guard<std::mutex> lg0(m_issue_lock);
178178
std::lock_guard<std::mutex> lg1(m_state_lock);
@@ -233,15 +233,16 @@ void ControllerWithScheduler::issue_full_controller_state(
233233

234234
void ControllerWithScheduler::issue_mash_button(
235235
const Cancellable* cancellable,
236-
Button button, Milliseconds duration
236+
Milliseconds duration,
237+
Button button
237238
){
238239
if (cancellable){
239240
cancellable->throw_if_cancelled();
240241
}
241242
ThrottleScope scope(m_logging_throttler);
242243
bool log = true;
243244
while (duration > Milliseconds::zero()){
244-
issue_buttons(cancellable, button, 8*8ms, 5*8ms, 3*8ms);
245+
issue_buttons(cancellable, 8*8ms, 5*8ms, 3*8ms, button);
245246

246247
// We never log before the first issue to avoid delaying the critical path.
247248
// But we do want to log before the mash spam. So we log after the first
@@ -262,16 +263,17 @@ void ControllerWithScheduler::issue_mash_button(
262263
}
263264
void ControllerWithScheduler::issue_mash_button(
264265
const Cancellable* cancellable,
265-
Button button0, Button button1, Milliseconds duration
266+
Milliseconds duration,
267+
Button button0, Button button1
266268
){
267269
if (cancellable){
268270
cancellable->throw_if_cancelled();
269271
}
270272
ThrottleScope scope(m_logging_throttler);
271273
bool log = true;
272274
while (duration > Milliseconds::zero()){
273-
issue_buttons(cancellable, button0, Milliseconds(4*8), 5*8ms, 3*8ms);
274-
issue_buttons(cancellable, button1, Milliseconds(4*8), 5*8ms, 3*8ms);
275+
issue_buttons(cancellable, 4*8ms, 5*8ms, 3*8ms, button0);
276+
issue_buttons(cancellable, 4*8ms, 5*8ms, 3*8ms, button1);
275277

276278
// We never log before the first issue to avoid delaying the critical path.
277279
// But we do want to log before the mash spam. So we log after the first
@@ -302,7 +304,7 @@ void ControllerWithScheduler::issue_mash_AZs(
302304
if (duration <= Milliseconds::zero()){
303305
break;
304306
}
305-
issue_buttons(cancellable, BUTTON_A, 3*8ms, 6*8ms, 3*8ms);
307+
issue_buttons(cancellable, 3*8ms, 6*8ms, 3*8ms, BUTTON_A);
306308

307309
// We never log before the first issue to avoid delaying the critical path.
308310
// But we do want to log before the mash spam. So we log after the first
@@ -319,20 +321,20 @@ void ControllerWithScheduler::issue_mash_AZs(
319321
if (duration <= Milliseconds::zero()){
320322
break;
321323
}
322-
issue_buttons(cancellable, BUTTON_ZL, 3*8ms, 6*8ms, 3*8ms);
324+
issue_buttons(cancellable, 3*8ms, 6*8ms, 3*8ms, BUTTON_ZL);
323325
duration -= std::min(3*8ms, duration);
324326

325327
if (duration <= Milliseconds::zero()){
326328
break;
327329
}
328-
issue_buttons(cancellable, BUTTON_ZR, 3*8ms, 6*8ms, 3*8ms);
330+
issue_buttons(cancellable, 3*8ms, 6*8ms, 3*8ms, BUTTON_ZR);
329331
duration -= std::min(3*8ms, duration);
330332
}
331333
}
332334
void ControllerWithScheduler::issue_system_scroll(
333335
const Cancellable* cancellable,
334-
DpadPosition direction, // Diagonals not allowed.
335-
Milliseconds delay, Milliseconds hold, Milliseconds cooldown
336+
Milliseconds delay, Milliseconds hold, Milliseconds cooldown,
337+
DpadPosition direction // Diagonals not allowed.
336338
){
337339
if (cancellable){
338340
cancellable->throw_if_cancelled();
@@ -347,8 +349,9 @@ void ControllerWithScheduler::issue_system_scroll(
347349
do{
348350
if (dpad <= left_joystick && dpad <= right_joystick){
349351
issue_dpad(
350-
cancellable, direction,
351-
delay, hold, cooldown
352+
cancellable,
353+
delay, hold, cooldown,
354+
direction
352355
);
353356
break;
354357
}
@@ -397,9 +400,9 @@ void ControllerWithScheduler::issue_system_scroll(
397400
}
398401

399402
if (left_joystick <= dpad && left_joystick <= right_joystick){
400-
issue_left_joystick(cancellable, x, y, delay, hold, cooldown);
403+
issue_left_joystick(cancellable, delay, hold, cooldown, x, y);
401404
}else{
402-
issue_right_joystick(cancellable, x, y, delay, hold, cooldown);
405+
issue_right_joystick(cancellable, delay, hold, cooldown, x, y);
403406
}
404407
}while (false);
405408

0 commit comments

Comments
 (0)