1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-30 22:00:16 +00:00
UltimateTrainingModpack/src/training/input_delay.rs
jugeeya 77f527c99a
Use Native Smash Input for All Input Processing (#581)
* Initial

* Finishing up with button config

* Formatting, some clippy

* Move button config to menu

* Consts formatting

* Fix input_record_press (thanks test!)

* Properly migrate menu button inputs

* Updates to triggers, including text

* Convert to multi-select
2023-08-10 07:28:13 -07:00

30 lines
917 B
Rust

use std::collections::VecDeque;
use crate::common::input::*;
use lazy_static::lazy_static;
use parking_lot::Mutex;
use crate::common::MENU;
lazy_static! {
static ref P1_DELAYED_INPUT_MAPPINGS: Mutex<VecDeque<MappedInputs>> =
Mutex::new(VecDeque::new());
}
pub fn handle_final_input_mapping(player_idx: i32, out: *mut MappedInputs) {
unsafe {
if player_idx == 0 {
let mut delayed_mappings = P1_DELAYED_INPUT_MAPPINGS.lock();
let actual_mapping = *out;
if delayed_mappings.len() < MENU.input_delay.into_delay() as usize {
*out = MappedInputs::empty();
} else if let Some(delayed_mapping) = delayed_mappings.back() {
*out = *delayed_mapping;
}
delayed_mappings.push_front(actual_mapping);
delayed_mappings.truncate(MENU.input_delay.into_delay() as usize);
}
}
}