5ms timing
This commit is contained in:
parent
b07801e11f
commit
db83646393
1 changed files with 11 additions and 6 deletions
|
|
@ -136,13 +136,18 @@ static SwitchInputState autopilot_state(const SwitchInputState& fallback) {
|
||||||
state.ry = SWITCH_PRO_JOYSTICK_MID;
|
state.ry = SWITCH_PRO_JOYSTICK_MID;
|
||||||
|
|
||||||
// Fire L+R twice then A twice, loop every ~300ms to keep trying.
|
// Fire L+R twice then A twice, loop every ~300ms to keep trying.
|
||||||
|
// Hold each press for a few ms so it survives the 5ms USB report throttle.
|
||||||
uint32_t step = g_autopilot_counter % 300;
|
uint32_t step = g_autopilot_counter % 300;
|
||||||
if (step == 25 || step == 50) {
|
constexpr uint32_t press_width = 50; // ~12ms
|
||||||
state.button_l = true;
|
auto in_window = [](uint32_t v, uint32_t start, uint32_t width) {
|
||||||
state.button_r = true;
|
return v >= start && v < start + width;
|
||||||
} else if (step == 75 || step == 100) {
|
};
|
||||||
state.button_a = true;
|
bool lr_down = in_window(step, 25, press_width) || in_window(step, 50, press_width);
|
||||||
}
|
bool a_down = in_window(step, 75, press_width) || in_window(step, 100, press_width);
|
||||||
|
|
||||||
|
state.button_r = lr_down;
|
||||||
|
state.button_l = lr_down;
|
||||||
|
state.button_a = a_down;
|
||||||
|
|
||||||
g_autopilot_counter++;
|
g_autopilot_counter++;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue