change(input): always yield at least once per stick update
This commit is contained in:
parent
755e49180c
commit
7ef15c0e7b
1 changed files with 5 additions and 15 deletions
18
src/input.rs
18
src/input.rs
|
@ -551,6 +551,10 @@ pub async fn update_stick_states_task(
|
||||||
|
|
||||||
if let Some(new_calibrating) = SIGNAL_IS_CALIBRATING.try_take() {
|
if let Some(new_calibrating) = SIGNAL_IS_CALIBRATING.try_take() {
|
||||||
is_calibrating = new_calibrating;
|
is_calibrating = new_calibrating;
|
||||||
|
if !is_calibrating {
|
||||||
|
debug!("Reset the ticker.");
|
||||||
|
ticker.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match Instant::now() {
|
match Instant::now() {
|
||||||
|
@ -566,12 +570,7 @@ pub async fn update_stick_states_task(
|
||||||
SIGNAL_STICK_STATE.signal(current_stick_state.clone());
|
SIGNAL_STICK_STATE.signal(current_stick_state.clone());
|
||||||
|
|
||||||
ticker.next().await;
|
ticker.next().await;
|
||||||
|
|
||||||
// we need this because during calibration, we might
|
|
||||||
// not run at the desired interval
|
|
||||||
if is_calibrating {
|
|
||||||
yield_now().await;
|
yield_now().await;
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(new_config) = SIGNAL_CONFIG_CHANGE.try_take() {
|
if let Some(new_config) = SIGNAL_CONFIG_CHANGE.try_take() {
|
||||||
controller_config = new_config;
|
controller_config = new_config;
|
||||||
|
@ -579,14 +578,5 @@ pub async fn update_stick_states_task(
|
||||||
cstick_params = StickParams::from_stick_config(&controller_config.cstick_config);
|
cstick_params = StickParams::from_stick_config(&controller_config.cstick_config);
|
||||||
filter_gains = FILTER_GAINS.get_normalized_gains(&controller_config);
|
filter_gains = FILTER_GAINS.get_normalized_gains(&controller_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
|
||||||
{
|
|
||||||
// give other tasks a chance to do something
|
|
||||||
// in debug, this loop runs noticeably slower, so this is necessary
|
|
||||||
// prefer running with `cargo run --release` for this reason, when
|
|
||||||
// developing stick related features
|
|
||||||
yield_now().await;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue