forked from NaxdyOrg/NaxGCC-FW
feat: implement naxdy filter
This commit is contained in:
parent
aed495ae54
commit
8b4f0fe12a
2 changed files with 80 additions and 3 deletions
|
@ -22,7 +22,7 @@ use crate::{
|
||||||
filter::{run_waveshaping, FilterGains, KalmanState, WaveshapingValues, FILTER_GAINS},
|
filter::{run_waveshaping, FilterGains, KalmanState, WaveshapingValues, FILTER_GAINS},
|
||||||
gcc_hid::GcReport,
|
gcc_hid::GcReport,
|
||||||
helpers::XyValuePair,
|
helpers::XyValuePair,
|
||||||
input_filter::{DummyFilter, InputFilter},
|
input_filter::{InputFilter, NaxdyFilter},
|
||||||
stick::{linearize, notch_remap, StickParams},
|
stick::{linearize, notch_remap, StickParams},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ pub async fn update_button_state_task(
|
||||||
let mut override_stick_state: Option<OverrideStickState> = None;
|
let mut override_stick_state: Option<OverrideStickState> = None;
|
||||||
|
|
||||||
// replace this with the input filter of your choice, if you so desire.
|
// replace this with the input filter of your choice, if you so desire.
|
||||||
let mut input_filter = DummyFilter;
|
let mut input_filter = NaxdyFilter::new();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
update_button_states(
|
update_button_states(
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use defmt::warn;
|
use defmt::{warn, Format};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{is_awaitable_button_pressed, AwaitableButtons},
|
config::{is_awaitable_button_pressed, AwaitableButtons},
|
||||||
|
@ -107,3 +107,80 @@ pub struct DummyFilter;
|
||||||
impl InputFilter for DummyFilter {
|
impl InputFilter for DummyFilter {
|
||||||
fn apply_filter(&mut self, _gcc_state: &mut GcReport) {}
|
fn apply_filter(&mut self, _gcc_state: &mut GcReport) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Format, Clone, Copy, PartialEq, Eq)]
|
||||||
|
enum NaxdyFilterMode {
|
||||||
|
Steve,
|
||||||
|
Snake,
|
||||||
|
Inactive,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct NaxdyFilter {
|
||||||
|
mode: NaxdyFilterMode,
|
||||||
|
short_hop_filter: SingleButtonMacroFilter,
|
||||||
|
item_pickup_filter: SingleButtonMacroFilter,
|
||||||
|
cstick_up_tilt_filter: CStickUpTiltFilter,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NaxdyFilter {
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
mode: NaxdyFilterMode::Snake,
|
||||||
|
short_hop_filter: SingleButtonMacroFilter {
|
||||||
|
btn_instigator: AwaitableButtons::Y,
|
||||||
|
btn_to_press: AwaitableButtons::X,
|
||||||
|
},
|
||||||
|
item_pickup_filter: SingleButtonMacroFilter {
|
||||||
|
btn_instigator: AwaitableButtons::Y,
|
||||||
|
btn_to_press: AwaitableButtons::L,
|
||||||
|
},
|
||||||
|
cstick_up_tilt_filter: CStickUpTiltFilter,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl InputFilter for NaxdyFilter {
|
||||||
|
fn apply_filter(&mut self, gcc_state: &mut GcReport) {
|
||||||
|
if gcc_state.buttons_1.button_a
|
||||||
|
&& gcc_state.buttons_1.button_b
|
||||||
|
&& gcc_state.buttons_1.dpad_right
|
||||||
|
&& self.mode != NaxdyFilterMode::Inactive
|
||||||
|
{
|
||||||
|
self.mode = NaxdyFilterMode::Snake
|
||||||
|
}
|
||||||
|
|
||||||
|
if gcc_state.buttons_1.button_a
|
||||||
|
&& gcc_state.buttons_1.button_b
|
||||||
|
&& gcc_state.buttons_1.dpad_left
|
||||||
|
&& self.mode != NaxdyFilterMode::Inactive
|
||||||
|
{
|
||||||
|
self.mode = NaxdyFilterMode::Steve;
|
||||||
|
}
|
||||||
|
|
||||||
|
if gcc_state.buttons_1.button_a
|
||||||
|
&& gcc_state.buttons_1.button_b
|
||||||
|
&& gcc_state.buttons_1.dpad_up
|
||||||
|
&& self.mode == NaxdyFilterMode::Inactive
|
||||||
|
{
|
||||||
|
self.mode = NaxdyFilterMode::Snake;
|
||||||
|
} else if gcc_state.buttons_1.button_a
|
||||||
|
&& gcc_state.buttons_1.button_b
|
||||||
|
&& gcc_state.buttons_1.dpad_down
|
||||||
|
&& self.mode != NaxdyFilterMode::Inactive
|
||||||
|
{
|
||||||
|
self.mode = NaxdyFilterMode::Inactive;
|
||||||
|
}
|
||||||
|
|
||||||
|
match self.mode {
|
||||||
|
NaxdyFilterMode::Steve => {
|
||||||
|
self.short_hop_filter.apply_filter(gcc_state);
|
||||||
|
}
|
||||||
|
NaxdyFilterMode::Snake => {
|
||||||
|
self.cstick_up_tilt_filter.apply_filter(gcc_state);
|
||||||
|
self.item_pickup_filter.apply_filter(gcc_state);
|
||||||
|
}
|
||||||
|
NaxdyFilterMode::Inactive => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue