From 45ef9ad4945ebb7248248800952636d58f3a58ce Mon Sep 17 00:00:00 2001 From: Naxdy Date: Wed, 3 Apr 2024 18:44:50 +0200 Subject: [PATCH] fix(config): analog scaling & stick combos --- src/config.rs | 56 ++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/src/config.rs b/src/config.rs index 9e4808c..b1514b6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -106,12 +106,12 @@ const LSTICK_SNAPBACK_X_INCREASE_COMBO: [AwaitableButtons; 4] = [ AwaitableButtons::A, AwaitableButtons::X, AwaitableButtons::Up, - AwaitableButtons::Wildcard, + AwaitableButtons::NotZ, ]; const LSTICK_SNAPBACK_Y_INCREASE_COMBO: [AwaitableButtons; 4] = [ AwaitableButtons::A, - AwaitableButtons::Wildcard, + AwaitableButtons::NotZ, AwaitableButtons::Up, AwaitableButtons::Y, ]; @@ -120,14 +120,14 @@ const LSTICK_SNAPBACK_X_DECREASE_COMBO: [AwaitableButtons; 4] = [ AwaitableButtons::A, AwaitableButtons::X, AwaitableButtons::Down, - AwaitableButtons::Wildcard, + AwaitableButtons::NotZ, ]; const LSTICK_SNAPBACK_Y_DECREASE_COMBO: [AwaitableButtons; 4] = [ AwaitableButtons::A, AwaitableButtons::Y, AwaitableButtons::Down, - AwaitableButtons::Wildcard, + AwaitableButtons::NotZ, ]; const RSTICK_SNAPBACK_X_INCREASE_COMBO: [AwaitableButtons; 4] = [ @@ -161,28 +161,28 @@ const RSTICK_SNAPBACK_Y_DECREASE_COMBO: [AwaitableButtons; 4] = [ const LSTICK_WAVESHAPING_X_INCREASE_COMBO: [AwaitableButtons; 4] = [ AwaitableButtons::X, AwaitableButtons::Up, - AwaitableButtons::Wildcard, + AwaitableButtons::NotZ, AwaitableButtons::L, ]; const LSTICK_WAVESHAPING_Y_INCREASE_COMBO: [AwaitableButtons; 4] = [ AwaitableButtons::Y, AwaitableButtons::Up, - AwaitableButtons::Wildcard, + AwaitableButtons::NotZ, AwaitableButtons::L, ]; const LSTICK_WAVESHAPING_X_DECREASE_COMBO: [AwaitableButtons; 4] = [ AwaitableButtons::X, AwaitableButtons::Down, - AwaitableButtons::Wildcard, + AwaitableButtons::NotZ, AwaitableButtons::L, ]; const LSTICK_WAVESHAPING_Y_DECREASE_COMBO: [AwaitableButtons; 4] = [ AwaitableButtons::Y, AwaitableButtons::Down, - AwaitableButtons::Wildcard, + AwaitableButtons::NotZ, AwaitableButtons::L, ]; @@ -218,28 +218,28 @@ const LSTICK_SMOOTH_X_INCREASE_COMBO: [AwaitableButtons; 4] = [ AwaitableButtons::R, AwaitableButtons::X, AwaitableButtons::Up, - AwaitableButtons::Wildcard, + AwaitableButtons::NotZ, ]; const LSTICK_SMOOTH_Y_INCREASE_COMBO: [AwaitableButtons; 4] = [ AwaitableButtons::R, AwaitableButtons::Y, AwaitableButtons::Up, - AwaitableButtons::Wildcard, + AwaitableButtons::NotZ, ]; const LSTICK_SMOOTH_X_DECREASE_COMBO: [AwaitableButtons; 4] = [ AwaitableButtons::R, AwaitableButtons::X, AwaitableButtons::Down, - AwaitableButtons::Wildcard, + AwaitableButtons::NotZ, ]; const LSTICK_SMOOTH_Y_DECREASE_COMBO: [AwaitableButtons; 4] = [ AwaitableButtons::R, AwaitableButtons::Y, AwaitableButtons::Down, - AwaitableButtons::Wildcard, + AwaitableButtons::NotZ, ]; const RSTICK_SMOOTH_X_INCREASE_COMBO: [AwaitableButtons; 4] = [ @@ -274,14 +274,14 @@ const LSTICK_CARDINALSNAP_INCREASE_COMBO: [AwaitableButtons; 4] = [ AwaitableButtons::R, AwaitableButtons::A, AwaitableButtons::Up, - AwaitableButtons::Wildcard, + AwaitableButtons::NotZ, ]; const LSTICK_CARDINALSNAP_DECREASE_COMBO: [AwaitableButtons; 4] = [ AwaitableButtons::R, AwaitableButtons::A, AwaitableButtons::Down, - AwaitableButtons::Wildcard, + AwaitableButtons::NotZ, ]; const RSTICK_CARDINALSNAP_INCREASE_COMBO: [AwaitableButtons; 4] = [ @@ -302,14 +302,14 @@ const LSTICK_SCALING_INCREASE_COMBO: [AwaitableButtons; 4] = [ AwaitableButtons::L, AwaitableButtons::A, AwaitableButtons::Up, - AwaitableButtons::Wildcard, + AwaitableButtons::NotZ, ]; const LSTICK_SCALING_DECREASE_COMBO: [AwaitableButtons; 4] = [ AwaitableButtons::L, AwaitableButtons::A, AwaitableButtons::Down, - AwaitableButtons::Wildcard, + AwaitableButtons::NotZ, ]; const RSTICK_SCALING_INCREASE_COMBO: [AwaitableButtons; 4] = [ @@ -458,6 +458,8 @@ enum AwaitableButtons { L, R, Z, + // special, because Z is used for cstick calibration + NotZ, /// Used for padding arrays to the correct length. Wildcard, /// Used for disabling certain button combinations.\ @@ -745,6 +747,7 @@ fn is_awaitable_button_pressed(report: &GcReport, button_to_wait_for: &Awaitable AwaitableButtons::Z => report.buttons_2.button_z, AwaitableButtons::Wildcard => true, AwaitableButtons::Impossible => false, + AwaitableButtons::NotZ => !report.buttons_2.button_z, } } @@ -1469,10 +1472,9 @@ async fn configuration_main_loop< _ => unreachable!(), }; - let to_adjust = match i { - 27 | 29 => &mut final_config.astick_config.cardinal_snapping, - 28 | 30 => &mut final_config.cstick_config.cardinal_snapping, - _ => unreachable!(), + let to_adjust = match stick { + Stick::ControlStick => &mut final_config.astick_config.cardinal_snapping, + Stick::CStick => &mut final_config.cstick_config.cardinal_snapping, }; *to_adjust = (*to_adjust @@ -1525,19 +1527,19 @@ async fn configuration_main_loop< _ => unreachable!(), }; - let to_adjust = match i { - 31 | 33 => &mut final_config.astick_config.analog_scaler, - 32 | 34 => &mut final_config.cstick_config.analog_scaler, - _ => unreachable!(), + let to_adjust = match stick { + Stick::ControlStick => &mut final_config.astick_config.analog_scaler, + Stick::CStick => &mut final_config.cstick_config.analog_scaler, }; - *to_adjust = ((*to_adjust as i8 + *to_adjust = (*to_adjust as i8 + match i { 31 | 33 => 1, 32 | 34 => -1, _ => unreachable!(), - }) as u8) - .clamp(MIN_ANALOG_SCALER, MAX_ANALOG_SCALER); + }) + .clamp(MIN_ANALOG_SCALER as i8, MAX_ANALOG_SCALER as i8) + as u8; override_gcc_state_and_wait(&OverrideGcReportInstruction { report: GcReport {