From 5cdd3348f4fcf8ef670219eda0e16e2d1abe27b8 Mon Sep 17 00:00:00 2001 From: Marcel Romagnuolo Date: Sat, 29 Jun 2024 12:58:01 +0000 Subject: [PATCH] implement filter for angled ftilts (#23) Reviewed-on: https://git.naxdy.org/NaxdyOrg/NaxGCC-FW/pulls/23 Reviewed-by: Naxdy Co-authored-by: Marcel Romagnuolo Co-committed-by: Marcel Romagnuolo --- src/input_filter.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/input_filter.rs b/src/input_filter.rs index 3a8c93b..3e000e8 100644 --- a/src/input_filter.rs +++ b/src/input_filter.rs @@ -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;