From 6599eb1c91b3070f446cdf6e1c863b0a4e61aa15 Mon Sep 17 00:00:00 2001 From: ManDude <7569514+ManDude@users.noreply.github.com> Date: Thu, 27 Jul 2023 10:46:40 +0100 Subject: [PATCH] Fix small buzz motor not vibrating correctly (#2846) --- game/kernel/common/kernel_types.h | 8 +++++--- game/sce/libpad.cpp | 3 ++- goal_src/jak2/engine/ps2/pad.gc | 1 - 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/game/kernel/common/kernel_types.h b/game/kernel/common/kernel_types.h index 8b7672e7e0..36ecac4cc6 100644 --- a/game/kernel/common/kernel_types.h +++ b/game/kernel/common/kernel_types.h @@ -3,7 +3,7 @@ #include "common/common_types.h" //! Mirror of cpad-info -#pragma pack(push, 4) +#pragma pack(push, 1) struct CPadInfo { u8 valid; u8 status; @@ -26,13 +26,15 @@ struct CPadInfo { u8 align[6]; u8 direct[6]; u8 buzz_val[2]; + u8 buzz_pause_val[1]; + u8 buzz_pause_time; u64 buzz_time[2]; u32 buzz; s32 buzz_act; - s32 change_time; // actually u64 in goal! + s64 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"); +static_assert(sizeof(CPadInfo) == 132, "CPadInfo size is wrong"); #pragma pack(pop) struct FileStream { diff --git a/game/sce/libpad.cpp b/game/sce/libpad.cpp index 72adb34674..e5799c096e 100644 --- a/game/sce/libpad.cpp +++ b/game/sce/libpad.cpp @@ -98,7 +98,8 @@ int scePadSetActDirect(int port, int /*slot*/, const u8* data) { if (!Display::GetMainDisplay()->get_input_manager()->controller_has_rumble(port)) { return 0; } - Display::GetMainDisplay()->get_input_manager()->enqueue_update_rumble(port, data[1], data[0]); + Display::GetMainDisplay()->get_input_manager()->enqueue_update_rumble(port, data[1], + data[0] * 255); return 1; // TODO - assuming 1 means rumble is supported, and 0 is no? } return 0; diff --git a/goal_src/jak2/engine/ps2/pad.gc b/goal_src/jak2/engine/ps2/pad.gc index bde0f29c44..f640af84b7 100644 --- a/goal_src/jak2/engine/ps2/pad.gc +++ b/goal_src/jak2/engine/ps2/pad.gc @@ -319,7 +319,6 @@ The cpad-set-buzz! function can be used for vibration. ) (when (< (the-as uint 192) (-> pad direct 1)) (set! (-> pad direct 0) (the-as uint 0)) - 0 ) (set! (-> pad button0-abs 2) (-> pad button0-abs 1)) (set! (-> pad button0-abs 1) (-> pad button0-shadow-abs 0))