1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-27 20:34:03 +00:00

GC Digital Triggers Menu Fix (#497)

* Check for digital triggers

* Update menu.rs

* Special case digital triggers

* JK

* Update rust.yml

* Update menu.rs
This commit is contained in:
jugeeya 2023-02-26 23:44:12 -08:00 committed by GitHub
parent c3a36e78e5
commit 0395bbe8ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 167 additions and 152 deletions

View file

@ -24,7 +24,7 @@ jobs:
- uses: Swatinem/rust-cache@v2
name: Rust Cache
with:
prefix-key: "checker"
prefix-key: "checker-2"
- name: Clippy
uses: actions-rs/cargo@v1
continue-on-error: false

View file

@ -181,7 +181,7 @@ pub static mut BUTTON_PRESSES: ButtonPresses = ButtonPresses {
},
};
pub fn handle_get_npad_state(state: *mut NpadGcState, _controller_id: *const u32) {
pub fn handle_get_npad_state(state: *mut NpadGcState, controller_id: *const u32) {
unsafe {
let update_count = (*state).updateCount;
let flags = (*state).Flags;
@ -227,6 +227,17 @@ pub fn handle_get_npad_state(state: *mut NpadGcState, _controller_id: *const u32
BUTTON_PRESSES.up.is_pressed = true;
}
// For digital triggers: these at TRIGGER_MAX means we should consider a press
if controller_is_gcc(*controller_id) {
if (*state).LTrigger == 0x7FFF {
BUTTON_PRESSES.l.is_pressed = true;
}
if (*state).RTrigger == 0x7FFF {
BUTTON_PRESSES.r.is_pressed = true;
}
}
// If we're here, remove all other Npad presses...
// Should we exclude the home button?
(*state) = NpadGcState::default();
@ -247,10 +258,14 @@ lazy_static! {
);
}
pub unsafe fn controller_is_gcc(controller_id: u32) -> bool {
let style_set = GetNpadStyleSet(&controller_id as *const _);
(style_set.flags & (1 << 5)) > 0
}
pub unsafe fn p1_controller_is_gcc() -> bool {
let p1_controller_id = crate::training::input_delay::p1_controller_id();
let p1_style_set = GetNpadStyleSet(&p1_controller_id as *const _);
(p1_style_set.flags & (1 << 5)) > 0
controller_is_gcc(p1_controller_id)
}
pub unsafe fn quick_menu_loop() {