Skip to content

Commit a82c1f0

Browse files
committed
Move the no-parameter ssf functions to own section.
1 parent c90e04c commit a82c1f0

File tree

2 files changed

+23
-157
lines changed

2 files changed

+23
-157
lines changed

SerialPrograms/Source/NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.cpp

Lines changed: 16 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@ void ssf_do_nothing(ProControllerContext& context, Milliseconds duration){
2424
}
2525

2626

27-
void ssf_press_button(ProControllerContext& context, Button button){
28-
Milliseconds delay = 3 * 8ms;
29-
Milliseconds hold = 5 * 8ms;
30-
Milliseconds cool = 3 * 8ms;
31-
Milliseconds timing_variation = context->timing_variation();
32-
delay += 2 * timing_variation;
33-
hold += timing_variation;
34-
cool += timing_variation;
35-
ssf_press_button(context, button, delay, hold, cool);
36-
}
3727
void ssf_press_button(
3828
ProControllerContext& context,
3929
Button button,
@@ -142,6 +132,21 @@ void ssf_issue_scroll(
142132
){
143133
context->issue_system_scroll(&context, direction, delay, hold, cool);
144134
}
135+
136+
137+
138+
139+
140+
void ssf_press_button(ProControllerContext& context, Button button){
141+
Milliseconds delay = 3 * 8ms;
142+
Milliseconds hold = 5 * 8ms;
143+
Milliseconds cool = 3 * 8ms;
144+
Milliseconds timing_variation = context->timing_variation();
145+
delay += 2 * timing_variation;
146+
hold += timing_variation;
147+
cool += timing_variation;
148+
ssf_press_button(context, button, delay, hold, cool);
149+
}
145150
void ssf_issue_scroll(ProControllerContext& context, DpadPosition direction){
146151
Milliseconds delay = 3 * 8ms;
147152
Milliseconds hold = 5 * 8ms;
@@ -155,150 +160,7 @@ void ssf_issue_scroll(ProControllerContext& context, DpadPosition direction){
155160

156161

157162

158-
#if 0
159-
int register_message_converters_ssf(){
160-
register_message_converter(
161-
PABB_MSG_COMMAND_SSF_FLUSH_PIPELINE,
162-
[](const std::string& body){
163-
std::ostringstream ss;
164-
ss << "ssf_flush_pipeline() - ";
165-
if (body.size() != sizeof(pabb_ssf_flush_pipeline)){ ss << "(invalid size)" << std::endl; return ss.str(); }
166-
const auto* params = (const pabb_ssf_flush_pipeline*)body.c_str();
167-
ss << "seqnum = " << (uint64_t)params->seqnum;
168-
return ss.str();
169-
}
170-
);
171-
register_message_converter(
172-
PABB_MSG_COMMAND_SSF_DO_NOTHING,
173-
[](const std::string& body){
174-
std::ostringstream ss;
175-
ss << "ssf_do_nothing() - ";
176-
if (body.size() != sizeof(pabb_ssf_do_nothing)){ ss << "(invalid size)" << std::endl; return ss.str(); }
177-
const auto* params = (const pabb_ssf_do_nothing*)body.c_str();
178-
ss << "seqnum = " << (uint64_t)params->seqnum;
179-
ss << ", ticks = " << params->ticks;
180-
return ss.str();
181-
}
182-
);
183-
register_message_converter(
184-
PABB_MSG_COMMAND_SSF_PRESS_BUTTON,
185-
[](const std::string& body){
186-
std::ostringstream ss;
187-
ss << "ssf_press_button() - ";
188-
if (body.size() != sizeof(pabb_ssf_press_button)){ ss << "(invalid size)" << std::endl; return ss.str(); }
189-
const auto* params = (const pabb_ssf_press_button*)body.c_str();
190-
ss << "seqnum = " << (uint64_t)params->seqnum;
191-
ss << ", button = " << params->button << "(" << button_to_string(params->button) << ")";
192-
ss << ", delay = " << params->delay;
193-
ss << ", hold = " << params->hold;
194-
ss << ", cool = " << (int)params->cool;
195-
return ss.str();
196-
}
197-
);
198-
register_message_converter(
199-
PABB_MSG_COMMAND_SSF_PRESS_DPAD,
200-
[](const std::string& body){
201-
std::ostringstream ss;
202-
ss << "ssf_press_dpad() - ";
203-
if (body.size() != sizeof(pabb_ssf_press_dpad)){ ss << "(invalid size)" << std::endl; return ss.str(); }
204-
const auto* params = (const pabb_ssf_press_dpad*)body.c_str();
205-
ss << "seqnum = " << (uint64_t)params->seqnum;
206-
ss << ", dpad = " << (unsigned)params->position << "(" << dpad_to_string(params->position) << ")";
207-
ss << ", delay = " << params->delay;
208-
ss << ", hold = " << params->hold;
209-
ss << ", cool = " << (int)params->cool;
210-
return ss.str();
211-
}
212-
);
213-
register_message_converter(
214-
PABB_MSG_COMMAND_SSF_PRESS_JOYSTICK_L,
215-
[](const std::string& body){
216-
std::ostringstream ss;
217-
ss << "ssf_press_joystick(left) - ";
218-
if (body.size() != sizeof(pabb_ssf_press_joystick)){ ss << "(invalid size)" << std::endl; return ss.str(); }
219-
const auto* params = (const pabb_ssf_press_joystick*)body.c_str();
220-
ss << "seqnum = " << (uint64_t)params->seqnum;
221-
ss << ", x = " << (int)params->x;
222-
ss << ", y = " << (int)params->y;
223-
ss << ", delay = " << params->delay;
224-
ss << ", hold = " << params->hold;
225-
ss << ", cool = " << (int)params->cool;
226-
return ss.str();
227-
}
228-
);
229-
register_message_converter(
230-
PABB_MSG_COMMAND_SSF_PRESS_JOYSTICK_R,
231-
[](const std::string& body){
232-
std::ostringstream ss;
233-
ss << "ssf_press_joystick(right) - ";
234-
if (body.size() != sizeof(pabb_ssf_press_joystick)){ ss << "(invalid size)" << std::endl; return ss.str(); }
235-
const auto* params = (const pabb_ssf_press_joystick*)body.c_str();
236-
ss << "seqnum = " << (uint64_t)params->seqnum;
237-
ss << ", x = " << (int)params->x;
238-
ss << ", y = " << (int)params->y;
239-
ss << ", delay = " << params->delay;
240-
ss << ", hold = " << params->hold;
241-
ss << ", cool = " << (int)params->cool;
242-
return ss.str();
243-
}
244-
);
245-
register_message_converter(
246-
PABB_MSG_COMMAND_SSF_MASH1_BUTTON,
247-
[](const std::string& body){
248-
std::ostringstream ss;
249-
ss << "ssf_mash1_button() - ";
250-
if (body.size() != sizeof(pabb_ssf_mash1_button)){ ss << "(invalid size)" << std::endl; return ss.str(); }
251-
const auto* params = (const pabb_ssf_mash1_button*)body.c_str();
252-
ss << "seqnum = " << (uint64_t)params->seqnum;
253-
ss << ", button = " << params->button << "(" << button_to_string(params->button) << ")";
254-
ss << ", ticks = " << params->ticks;
255-
return ss.str();
256-
}
257-
);
258-
register_message_converter(
259-
PABB_MSG_COMMAND_SSF_MASH2_BUTTON,
260-
[](const std::string& body){
261-
std::ostringstream ss;
262-
ss << "ssf_mash2_button() - ";
263-
if (body.size() != sizeof(pabb_ssf_mash2_button)){ ss << "(invalid size)" << std::endl; return ss.str(); }
264-
const auto* params = (const pabb_ssf_mash2_button*)body.c_str();
265-
ss << "seqnum = " << (uint64_t)params->seqnum;
266-
ss << ", button = " << params->button0 << "(" << button_to_string(params->button0) << ")";
267-
ss << ", button = " << params->button1 << "(" << button_to_string(params->button1) << ")";
268-
ss << ", ticks = " << params->ticks;
269-
return ss.str();
270-
}
271-
);
272-
register_message_converter(
273-
PABB_MSG_COMMAND_SSF_MASH_AZS,
274-
[](const std::string& body){
275-
std::ostringstream ss;
276-
ss << "ssf_mash_AZs() - ";
277-
if (body.size() != sizeof(pabb_ssf_mash_AZs)){ ss << "(invalid size)" << std::endl; return ss.str(); }
278-
const auto* params = (const pabb_ssf_mash_AZs*)body.c_str();
279-
ss << "seqnum = " << (uint64_t)params->seqnum;
280-
ss << ", ticks = " << params->ticks;
281-
return ss.str();
282-
}
283-
);
284-
register_message_converter(
285-
PABB_MSG_COMMAND_SSF_SCROLL,
286-
[](const std::string& body){
287-
std::ostringstream ss;
288-
ss << "ssf_issue_scroll() - ";
289-
if (body.size() != sizeof(pabb_ssf_issue_scroll)){ ss << "(invalid size)" << std::endl; return ss.str(); }
290-
const auto* params = (const pabb_ssf_issue_scroll*)body.c_str();
291-
ss << "seqnum = " << (uint64_t)params->seqnum;
292-
ss << ", delay = " << params->delay;
293-
ss << ", hold = " << params->hold;
294-
ss << ", cool = " << (int)params->cool;
295-
return ss.str();
296-
}
297-
);
298-
return 0;
299-
}
300-
int init_ssf = register_message_converters_ssf();
301-
#endif
163+
302164

303165

304166

SerialPrograms/Source/NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ void ssf_do_nothing (ProControllerContext& context, Milliseconds duration);
3131

3232

3333

34-
void ssf_press_button(ProControllerContext& context, Button button);
3534
void ssf_press_button(
3635
ProControllerContext& context,
3736
Button button,
@@ -93,7 +92,6 @@ void ssf_mash_AZs (ProControllerContext& context, Milliseconds duration);
9392
#define SSF_SCROLL_RIGHT DPAD_RIGHT
9493
#define SSF_SCROLL_DOWN DPAD_DOWN
9594
#define SSF_SCROLL_LEFT DPAD_LEFT
96-
void ssf_issue_scroll(ProControllerContext& context, DpadPosition direction);
9795
void ssf_issue_scroll(
9896
ProControllerContext& context,
9997
DpadPosition direction,
@@ -109,7 +107,13 @@ void ssf_issue_scroll(
109107

110108

111109

112-
110+
//
111+
// These overloads without timing parameters are intended for navigation within
112+
// the Switch settings. They will use "context->timing_variation()" to
113+
// determine the fastest/safest timings to use.
114+
//
115+
void ssf_press_button(ProControllerContext& context, Button button);
116+
void ssf_issue_scroll(ProControllerContext& context, DpadPosition direction);
113117

114118

115119

0 commit comments

Comments
 (0)