diff --git a/game/kernel/common/kernel_types.h b/game/kernel/common/kernel_types.h index a75be55d03..8b7672e7e0 100644 --- a/game/kernel/common/kernel_types.h +++ b/game/kernel/common/kernel_types.h @@ -1,6 +1,9 @@ #pragma once +#include "common/common_types.h" + //! Mirror of cpad-info +#pragma pack(push, 4) struct CPadInfo { u8 valid; u8 status; @@ -23,12 +26,14 @@ struct CPadInfo { u8 align[6]; u8 direct[6]; u8 buzz_val[2]; - u8 __pad[2]; u64 buzz_time[2]; u32 buzz; s32 buzz_act; s32 change_time; // actually u64 in goal! }; +// static_assert(offsetof(CPadInfo, number) == 32, "CPadInfo number field is wrong"); +static_assert(sizeof(CPadInfo) == 128, "CPadInfo size is wrong"); +#pragma pack(pop) struct FileStream { u32 flags; diff --git a/game/kernel/common/kmachine.cpp b/game/kernel/common/kmachine.cpp index 4a13bc359a..f2cbdc0e14 100644 --- a/game/kernel/common/kmachine.cpp +++ b/game/kernel/common/kmachine.cpp @@ -113,8 +113,8 @@ u64 CPadGetData(u64 cpad_info) { // ps2 controllers would send an enabled bit if the button was NOT pressed, but we don't do // that here. removed code that flipped the bits. - if (cpad->buzz_act) { - scePadSetActDirect(cpad->number, 0, cpad); + if (cpad->change_time) { + scePadSetActDirect(cpad->number, 0, cpad->direct); } cpad->valid = pad_state; } @@ -143,7 +143,7 @@ u64 CPadGetData(u64 cpad_info) { break; case 40: // controller mode - check for extra modes // cpad->change_time = 0; - cpad->buzz_act = 0; + cpad->change_time = 0; if (scePadInfoMode(cpad->number, 0, InfoModeIdTable, -1) == 0) { // no controller modes cpad->state = 90; @@ -171,12 +171,12 @@ u64 CPadGetData(u64 cpad_info) { if (scePadInfoAct(cpad->number, 0, -1, 0) < 1) { // no actuators means no vibration. skip to end! // cpad->change_time = 0; - cpad->buzz_act = 0; + cpad->change_time = 0; cpad->state = 99; } else { // we have actuators to use. // cpad->change_time = 1; // remember to update pad times. - cpad->buzz_act = 1; + cpad->change_time = 1; cpad->state = 75; } break; diff --git a/game/sce/libpad.cpp b/game/sce/libpad.cpp index 54a8478c67..d92410a3c8 100644 --- a/game/sce/libpad.cpp +++ b/game/sce/libpad.cpp @@ -91,8 +91,11 @@ int scePadRead(int port, int /*slot*/, u8* rdata) { return 32; } -int scePadSetActDirect(int port, int /*slot*/, CPadInfo* cpad) { - return Pad::rumble(port, ((float)cpad->buzz_val[0]) / 255, ((float)cpad->buzz_val[1]) / 255); +int scePadSetActDirect(int port, int /*slot*/, const u8* data) { + // offsets are set by scePadSetActAlign, but we already know the game uses 0 for big motor and 1 + // for small motor + // also, the "slow" motor corresponds to the "large" motor on the PS2 + return Pad::rumble(port, ((float)data[1]) / 255, ((float)data[0])); } int scePadSetActAlign(int /*port*/, int /*slot*/, const u8* /*data*/) { diff --git a/game/sce/libpad.h b/game/sce/libpad.h index 79d85ea099..41f4cc7fdb 100644 --- a/game/sce/libpad.h +++ b/game/sce/libpad.h @@ -54,7 +54,7 @@ int scePadPortOpen(int port, int slot, void* data); int scePadGetState(int port, int slot); int scePadInfoMode(int port, int slot, int term, int offs); int scePadRead(int port, int slot, u8* rdata); -int scePadSetActDirect(int port, int slot, CPadInfo* cpad); +int scePadSetActDirect(int port, int slot, const u8* data); int scePadSetActAlign(int port, int slot, const u8* data); int scePadSetMainMode(int port, int slot, int offs, int lock); int scePadGetReqState(int port, int slot); diff --git a/goal_src/jak1/pc/hud-classes-pc.gc b/goal_src/jak1/pc/hud-classes-pc.gc index c7aba89fcf..2dbc1e48c8 100644 --- a/goal_src/jak1/pc/hud-classes-pc.gc +++ b/goal_src/jak1/pc/hud-classes-pc.gc @@ -507,7 +507,7 @@ ) (else ;; we have nothing. kill everything. - (unless (hidden? obj) + (unless (and (= (-> obj last-battle) INVALID_HANDLE) (hidden? obj)) (set! (-> obj last-battle) INVALID_HANDLE) (set! (-> obj last-task) #f) (false! (-> obj ready?))