fix(config): analog scaling & stick combos

This commit is contained in:
Naxdy 2024-04-03 18:44:50 +02:00
parent a19cd9cd78
commit 45ef9ad494
Signed by: Naxdy
GPG key ID: CC15075846BCE91B

View file

@ -106,12 +106,12 @@ const LSTICK_SNAPBACK_X_INCREASE_COMBO: [AwaitableButtons; 4] = [
AwaitableButtons::A, AwaitableButtons::A,
AwaitableButtons::X, AwaitableButtons::X,
AwaitableButtons::Up, AwaitableButtons::Up,
AwaitableButtons::Wildcard, AwaitableButtons::NotZ,
]; ];
const LSTICK_SNAPBACK_Y_INCREASE_COMBO: [AwaitableButtons; 4] = [ const LSTICK_SNAPBACK_Y_INCREASE_COMBO: [AwaitableButtons; 4] = [
AwaitableButtons::A, AwaitableButtons::A,
AwaitableButtons::Wildcard, AwaitableButtons::NotZ,
AwaitableButtons::Up, AwaitableButtons::Up,
AwaitableButtons::Y, AwaitableButtons::Y,
]; ];
@ -120,14 +120,14 @@ const LSTICK_SNAPBACK_X_DECREASE_COMBO: [AwaitableButtons; 4] = [
AwaitableButtons::A, AwaitableButtons::A,
AwaitableButtons::X, AwaitableButtons::X,
AwaitableButtons::Down, AwaitableButtons::Down,
AwaitableButtons::Wildcard, AwaitableButtons::NotZ,
]; ];
const LSTICK_SNAPBACK_Y_DECREASE_COMBO: [AwaitableButtons; 4] = [ const LSTICK_SNAPBACK_Y_DECREASE_COMBO: [AwaitableButtons; 4] = [
AwaitableButtons::A, AwaitableButtons::A,
AwaitableButtons::Y, AwaitableButtons::Y,
AwaitableButtons::Down, AwaitableButtons::Down,
AwaitableButtons::Wildcard, AwaitableButtons::NotZ,
]; ];
const RSTICK_SNAPBACK_X_INCREASE_COMBO: [AwaitableButtons; 4] = [ 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] = [ const LSTICK_WAVESHAPING_X_INCREASE_COMBO: [AwaitableButtons; 4] = [
AwaitableButtons::X, AwaitableButtons::X,
AwaitableButtons::Up, AwaitableButtons::Up,
AwaitableButtons::Wildcard, AwaitableButtons::NotZ,
AwaitableButtons::L, AwaitableButtons::L,
]; ];
const LSTICK_WAVESHAPING_Y_INCREASE_COMBO: [AwaitableButtons; 4] = [ const LSTICK_WAVESHAPING_Y_INCREASE_COMBO: [AwaitableButtons; 4] = [
AwaitableButtons::Y, AwaitableButtons::Y,
AwaitableButtons::Up, AwaitableButtons::Up,
AwaitableButtons::Wildcard, AwaitableButtons::NotZ,
AwaitableButtons::L, AwaitableButtons::L,
]; ];
const LSTICK_WAVESHAPING_X_DECREASE_COMBO: [AwaitableButtons; 4] = [ const LSTICK_WAVESHAPING_X_DECREASE_COMBO: [AwaitableButtons; 4] = [
AwaitableButtons::X, AwaitableButtons::X,
AwaitableButtons::Down, AwaitableButtons::Down,
AwaitableButtons::Wildcard, AwaitableButtons::NotZ,
AwaitableButtons::L, AwaitableButtons::L,
]; ];
const LSTICK_WAVESHAPING_Y_DECREASE_COMBO: [AwaitableButtons; 4] = [ const LSTICK_WAVESHAPING_Y_DECREASE_COMBO: [AwaitableButtons; 4] = [
AwaitableButtons::Y, AwaitableButtons::Y,
AwaitableButtons::Down, AwaitableButtons::Down,
AwaitableButtons::Wildcard, AwaitableButtons::NotZ,
AwaitableButtons::L, AwaitableButtons::L,
]; ];
@ -218,28 +218,28 @@ const LSTICK_SMOOTH_X_INCREASE_COMBO: [AwaitableButtons; 4] = [
AwaitableButtons::R, AwaitableButtons::R,
AwaitableButtons::X, AwaitableButtons::X,
AwaitableButtons::Up, AwaitableButtons::Up,
AwaitableButtons::Wildcard, AwaitableButtons::NotZ,
]; ];
const LSTICK_SMOOTH_Y_INCREASE_COMBO: [AwaitableButtons; 4] = [ const LSTICK_SMOOTH_Y_INCREASE_COMBO: [AwaitableButtons; 4] = [
AwaitableButtons::R, AwaitableButtons::R,
AwaitableButtons::Y, AwaitableButtons::Y,
AwaitableButtons::Up, AwaitableButtons::Up,
AwaitableButtons::Wildcard, AwaitableButtons::NotZ,
]; ];
const LSTICK_SMOOTH_X_DECREASE_COMBO: [AwaitableButtons; 4] = [ const LSTICK_SMOOTH_X_DECREASE_COMBO: [AwaitableButtons; 4] = [
AwaitableButtons::R, AwaitableButtons::R,
AwaitableButtons::X, AwaitableButtons::X,
AwaitableButtons::Down, AwaitableButtons::Down,
AwaitableButtons::Wildcard, AwaitableButtons::NotZ,
]; ];
const LSTICK_SMOOTH_Y_DECREASE_COMBO: [AwaitableButtons; 4] = [ const LSTICK_SMOOTH_Y_DECREASE_COMBO: [AwaitableButtons; 4] = [
AwaitableButtons::R, AwaitableButtons::R,
AwaitableButtons::Y, AwaitableButtons::Y,
AwaitableButtons::Down, AwaitableButtons::Down,
AwaitableButtons::Wildcard, AwaitableButtons::NotZ,
]; ];
const RSTICK_SMOOTH_X_INCREASE_COMBO: [AwaitableButtons; 4] = [ const RSTICK_SMOOTH_X_INCREASE_COMBO: [AwaitableButtons; 4] = [
@ -274,14 +274,14 @@ const LSTICK_CARDINALSNAP_INCREASE_COMBO: [AwaitableButtons; 4] = [
AwaitableButtons::R, AwaitableButtons::R,
AwaitableButtons::A, AwaitableButtons::A,
AwaitableButtons::Up, AwaitableButtons::Up,
AwaitableButtons::Wildcard, AwaitableButtons::NotZ,
]; ];
const LSTICK_CARDINALSNAP_DECREASE_COMBO: [AwaitableButtons; 4] = [ const LSTICK_CARDINALSNAP_DECREASE_COMBO: [AwaitableButtons; 4] = [
AwaitableButtons::R, AwaitableButtons::R,
AwaitableButtons::A, AwaitableButtons::A,
AwaitableButtons::Down, AwaitableButtons::Down,
AwaitableButtons::Wildcard, AwaitableButtons::NotZ,
]; ];
const RSTICK_CARDINALSNAP_INCREASE_COMBO: [AwaitableButtons; 4] = [ const RSTICK_CARDINALSNAP_INCREASE_COMBO: [AwaitableButtons; 4] = [
@ -302,14 +302,14 @@ const LSTICK_SCALING_INCREASE_COMBO: [AwaitableButtons; 4] = [
AwaitableButtons::L, AwaitableButtons::L,
AwaitableButtons::A, AwaitableButtons::A,
AwaitableButtons::Up, AwaitableButtons::Up,
AwaitableButtons::Wildcard, AwaitableButtons::NotZ,
]; ];
const LSTICK_SCALING_DECREASE_COMBO: [AwaitableButtons; 4] = [ const LSTICK_SCALING_DECREASE_COMBO: [AwaitableButtons; 4] = [
AwaitableButtons::L, AwaitableButtons::L,
AwaitableButtons::A, AwaitableButtons::A,
AwaitableButtons::Down, AwaitableButtons::Down,
AwaitableButtons::Wildcard, AwaitableButtons::NotZ,
]; ];
const RSTICK_SCALING_INCREASE_COMBO: [AwaitableButtons; 4] = [ const RSTICK_SCALING_INCREASE_COMBO: [AwaitableButtons; 4] = [
@ -458,6 +458,8 @@ enum AwaitableButtons {
L, L,
R, R,
Z, Z,
// special, because Z is used for cstick calibration
NotZ,
/// Used for padding arrays to the correct length. /// Used for padding arrays to the correct length.
Wildcard, Wildcard,
/// Used for disabling certain button combinations.\ /// 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::Z => report.buttons_2.button_z,
AwaitableButtons::Wildcard => true, AwaitableButtons::Wildcard => true,
AwaitableButtons::Impossible => false, AwaitableButtons::Impossible => false,
AwaitableButtons::NotZ => !report.buttons_2.button_z,
} }
} }
@ -1469,10 +1472,9 @@ async fn configuration_main_loop<
_ => unreachable!(), _ => unreachable!(),
}; };
let to_adjust = match i { let to_adjust = match stick {
27 | 29 => &mut final_config.astick_config.cardinal_snapping, Stick::ControlStick => &mut final_config.astick_config.cardinal_snapping,
28 | 30 => &mut final_config.cstick_config.cardinal_snapping, Stick::CStick => &mut final_config.cstick_config.cardinal_snapping,
_ => unreachable!(),
}; };
*to_adjust = (*to_adjust *to_adjust = (*to_adjust
@ -1525,19 +1527,19 @@ async fn configuration_main_loop<
_ => unreachable!(), _ => unreachable!(),
}; };
let to_adjust = match i { let to_adjust = match stick {
31 | 33 => &mut final_config.astick_config.analog_scaler, Stick::ControlStick => &mut final_config.astick_config.analog_scaler,
32 | 34 => &mut final_config.cstick_config.analog_scaler, Stick::CStick => &mut final_config.cstick_config.analog_scaler,
_ => unreachable!(),
}; };
*to_adjust = ((*to_adjust as i8 *to_adjust = (*to_adjust as i8
+ match i { + match i {
31 | 33 => 1, 31 | 33 => 1,
32 | 34 => -1, 32 | 34 => -1,
_ => unreachable!(), _ => 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 { override_gcc_state_and_wait(&OverrideGcReportInstruction {
report: GcReport { report: GcReport {