implement filter for angled ftilts (#23)
All checks were successful
Publish nightly release / build (push) Successful in 1m31s

Reviewed-on: #23
Reviewed-by: Naxdy <naxdy@naxdy.org>
Co-authored-by: Marcel Romagnuolo <marcello.r@gmx.net>
Co-committed-by: Marcel Romagnuolo <marcello.r@gmx.net>
This commit is contained in:
Marcel Romagnuolo 2024-06-29 12:58:01 +00:00 committed by Naxdy
parent b6b5bb25a7
commit 5cdd3348f4

View file

@ -7,6 +7,10 @@ use crate::{
/**
* Houses functionality for modifying GCC state before it is sent to the console.
*
* General info for implementing filters on the sticks:
* X and Y values of a stick go each from 0 to 255.
* 127.5 is the middle value and when both X and Y are 127.5 the stick is in neutral position.
*/
pub trait InputFilter: Sized {
@ -100,6 +104,33 @@ impl InputFilter for CStickUpTiltFilter {
}
}
/// Improves hitting up/down angled forward tilt at the cost
/// of making it impossible to hit turnaround up & down tilt
/// and making it slightly harder to hit regular forward tilt.
pub struct CStickAngledFTiltFilter;
impl InputFilter for CStickAngledFTiltFilter {
fn apply_filter(&mut self, gcc_state: &mut GcReport) {
if gcc_state.cstick_y > 147 {
if (147..=225).contains(&gcc_state.cstick_x) {
gcc_state.cstick_x = 205;
gcc_state.cstick_y = 205;
} else if (30..=107).contains(&gcc_state.cstick_x) {
gcc_state.cstick_x = 50;
gcc_state.cstick_y = 205;
}
} else if gcc_state.cstick_y < 107 {
if (147..=225).contains(&gcc_state.cstick_x) {
gcc_state.cstick_x = 205;
gcc_state.cstick_y = 50;
} else if (30..=107).contains(&gcc_state.cstick_x) {
gcc_state.cstick_x = 50;
gcc_state.cstick_y = 50;
}
}
}
}
/// Does nothing.
#[derive(Default)]
pub struct DummyFilter;