mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-03-23 06:46:11 +00:00
use nn_hid hook for compatibility with results screen skip
This commit is contained in:
parent
7a3df98df7
commit
345fd619a1
4 changed files with 28 additions and 60 deletions
|
@ -1,2 +0,0 @@
|
||||||
[build]
|
|
||||||
target = "aarch64-skyline-switch"
|
|
|
@ -25,6 +25,7 @@ num-traits = "0.2"
|
||||||
wsl = "0.1.0"
|
wsl = "0.1.0"
|
||||||
strum = "0.21.0"
|
strum = "0.21.0"
|
||||||
strum_macros = "0.21.0"
|
strum_macros = "0.21.0"
|
||||||
|
rand = { git = "https://github.com/skyline-rs/rand" }
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
@ -38,6 +39,7 @@ titleid = "01006A800016E000"
|
||||||
plugin-dependencies = [
|
plugin-dependencies = [
|
||||||
{ name = "libnro_hook.nro", url = "https://github.com/ultimate-research/nro-hook-plugin/releases/download/v0.1.1/libnro_hook.nro" },
|
{ name = "libnro_hook.nro", url = "https://github.com/ultimate-research/nro-hook-plugin/releases/download/v0.1.1/libnro_hook.nro" },
|
||||||
{ name = "libparam_hook.nro", url = "https://github.com/ultimate-research/params-hook-plugin/releases/download/v0.1.1/libparam_hook.nro" },
|
{ name = "libparam_hook.nro", url = "https://github.com/ultimate-research/params-hook-plugin/releases/download/v0.1.1/libparam_hook.nro" },
|
||||||
|
{ name = "libnn_hid_hook.nro", url = "https://github.com/jugeeya/nn-hid-hook/releases/download/beta/libnn_hid_hook.nro" }
|
||||||
]
|
]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|
|
@ -23,25 +23,29 @@ pub unsafe fn p1_controller_id() -> u32 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn handle_get_npad_state(
|
pub fn handle_get_npad_state(
|
||||||
state: *mut NpadHandheldState,
|
state: *mut NpadHandheldState,
|
||||||
controller_id: *const u32,
|
controller_id: *const u32,
|
||||||
) {
|
) {
|
||||||
if *controller_id == p1_controller_id() {
|
unsafe {
|
||||||
let mut delayed_states = P1_DELAYED_NPAD_STATES.lock();
|
if crate::common::is_training_mode() {
|
||||||
let actual_state = *state;
|
if *controller_id == p1_controller_id() {
|
||||||
|
let mut delayed_states = P1_DELAYED_NPAD_STATES.lock();
|
||||||
|
let actual_state = *state;
|
||||||
|
|
||||||
if delayed_states.len() < MENU.input_delay as usize {
|
if delayed_states.len() < MENU.input_delay as usize {
|
||||||
let update_count = (*state).updateCount;
|
let update_count = (*state).updateCount;
|
||||||
*state = NpadHandheldState::default();
|
*state = NpadHandheldState::default();
|
||||||
(*state).updateCount = update_count;
|
(*state).updateCount = update_count;
|
||||||
} else if let Some(delayed_state) = delayed_states.back() {
|
} else if let Some(delayed_state) = delayed_states.back() {
|
||||||
let update_count = (*state).updateCount;
|
let update_count = (*state).updateCount;
|
||||||
*state = *delayed_state;
|
*state = *delayed_state;
|
||||||
(*state).updateCount = update_count;
|
(*state).updateCount = update_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
delayed_states.push_front(actual_state);
|
||||||
|
delayed_states.truncate(MENU.input_delay as usize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delayed_states.push_front(actual_state);
|
|
||||||
delayed_states.truncate(MENU.input_delay as usize);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -289,52 +289,16 @@ fn params_main(params_info: &ParamsInfo<'_>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! create_nn_hid_hooks {
|
|
||||||
(
|
|
||||||
$(
|
|
||||||
($func:ident, $hook:ident)
|
|
||||||
),*
|
|
||||||
) => {
|
|
||||||
$(
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
#[skyline::hook(replace = $func)]
|
|
||||||
pub unsafe fn $hook(
|
|
||||||
state: *mut skyline::nn::hid::NpadHandheldState,
|
|
||||||
controller_id: *const u32,
|
|
||||||
) {
|
|
||||||
original!()(state, controller_id);
|
|
||||||
if is_training_mode() {
|
|
||||||
input_delay::handle_get_npad_state(state, controller_id);
|
|
||||||
/* TODO:
|
|
||||||
1) make number of frames configurable
|
|
||||||
2) make possible without a second controller plugged in
|
|
||||||
**/
|
|
||||||
// input_record::handle_get_npad_state(state, controller_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)*
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
create_nn_hid_hooks!(
|
|
||||||
(GetNpadHandheldState, handle_get_npad_handheld_state),
|
|
||||||
(GetNpadFullKeyState, handle_get_npad_full_key_state),
|
|
||||||
(GetNpadGcState, handle_get_npad_gc_state),
|
|
||||||
(GetNpadJoyDualState, handle_get_joy_dual_state),
|
|
||||||
(GetNpadJoyLeftState, handle_get_joy_left_state),
|
|
||||||
(GetNpadJoyRightState, handle_get_joy_right_state));
|
|
||||||
|
|
||||||
pub fn training_mods() {
|
pub fn training_mods() {
|
||||||
println!("[Training Modpack] Applying training mods.");
|
println!("[Training Modpack] Applying training mods.");
|
||||||
|
|
||||||
// Input Recording/Delay
|
// Input Recording/Delay
|
||||||
skyline::install_hooks!(
|
unsafe {
|
||||||
handle_get_npad_handheld_state,
|
if (add_nn_hid_hook as *const ()).is_null() {
|
||||||
handle_get_npad_full_key_state,
|
panic!("The NN-HID hook plugin could not be found and is required to add NRO hooks. Make sure libnn_hid_hook.nro is installed.");
|
||||||
handle_get_npad_gc_state,
|
}
|
||||||
handle_get_joy_dual_state,
|
add_nn_hid_hook(input_delay::handle_get_npad_state);
|
||||||
handle_get_joy_left_state,
|
}
|
||||||
handle_get_joy_right_state);
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
LookupSymbol(
|
LookupSymbol(
|
||||||
|
|
Loading…
Add table
Reference in a new issue