feat(hid): improve rate limiting in SuperHack mode
Some checks failed
Code quality / check (pull_request) Failing after 1m39s
Some checks failed
Code quality / check (pull_request) Failing after 1m39s
This commit is contained in:
parent
3f47f5bdb0
commit
0c53e49a50
1 changed files with 4 additions and 7 deletions
|
@ -361,7 +361,6 @@ pub async fn usb_transfer_task(raw_serial: [u8; 8], driver: Driver<'static, USB>
|
||||||
let mut gcc_subscriber = CHANNEL_GCC_STATE.subscriber().unwrap();
|
let mut gcc_subscriber = CHANNEL_GCC_STATE.subscriber().unwrap();
|
||||||
|
|
||||||
let mut last_report_time = Instant::now();
|
let mut last_report_time = Instant::now();
|
||||||
let mut last_loop_time = Instant::now();
|
|
||||||
let mut ticker = Ticker::every(Duration::from_micros(8333));
|
let mut ticker = Ticker::every(Duration::from_micros(8333));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
@ -378,12 +377,10 @@ pub async fn usb_transfer_task(raw_serial: [u8; 8], driver: Driver<'static, USB>
|
||||||
InputConsistencyMode::SuperHack => {
|
InputConsistencyMode::SuperHack => {
|
||||||
// In SuperHack mode, we send reports only if the state changes, but
|
// In SuperHack mode, we send reports only if the state changes, but
|
||||||
// in order to not mess up very fast inputs (like sticks travelling, for example),
|
// in order to not mess up very fast inputs (like sticks travelling, for example),
|
||||||
// we still need a delay that is higher than the polling rate, but ideally also
|
// we still need to "rate limit" the reports to every 8.33ms at most.
|
||||||
// a multiple/divisor of the game's frame rate.
|
// This does rate limit it to ~8.33ms fairly well, my only
|
||||||
// This doesn't quite hit the 8.33ms every time though, so inputs during lots of
|
// gripe with it is that I hate it :)
|
||||||
// stick movement might still be a bit off.
|
Timer::at(last_report_time + Duration::from_micros(8100)).await;
|
||||||
Timer::at(last_loop_time + Duration::from_micros(8333)).await;
|
|
||||||
last_loop_time = Instant::now();
|
|
||||||
}
|
}
|
||||||
InputConsistencyMode::ConsistencyHack => {
|
InputConsistencyMode::ConsistencyHack => {
|
||||||
// Ticker better maintains a consistent interval than Timer, so
|
// Ticker better maintains a consistent interval than Timer, so
|
||||||
|
|
Loading…
Reference in a new issue