From e443e84d3c178b04d5ca7202355c985db297e2bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 26 Oct 2026 12:36:49 +0100 Subject: [PATCH] sceHprm: Write zeroes to the latch buffer in sceHprmPeekLatch too We don't support the headphone remote buttons, so we just leave the buffer all zeroes. Previously we didn't write, which could cause games to register a ghost "track forward" or the other buttons. Should fix the DJ Max 2 OST track-forwarding problem in #7468. --- Core/HLE/sceHprm.cpp | 18 ++++++++++++++---- Core/HLE/sceHprm.h | 4 +++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Core/HLE/sceHprm.cpp b/Core/HLE/sceHprm.cpp index 20b66bfff4..62a7b7a92a 100644 --- a/Core/HLE/sceHprm.cpp +++ b/Core/HLE/sceHprm.cpp @@ -48,14 +48,24 @@ static u32 sceHprmUnregisterCallback() { return hleLogError(Log::HLE, 0, "UNIMPL"); } +// The latch is 4 x u32 (make, break, press, release). We don't support the headphone remote +// buttons, so it's all zeroes. +static void WriteEmptyLatch(u32 latchAddr) { + if (!Memory::IsValid4AlignedRange(latchAddr, 16)) { + return; + } + for (int i = 0; i < 4; i++) { + Memory::WriteUnchecked_U32(0, latchAddr + i * 4); + } +} + static u32 sceHprmPeekLatch(u32 latchAddr) { - return hleLogDebug(Log::HLE,0, "latchAddr %08x", latchAddr); + WriteEmptyLatch(latchAddr); + return hleLogDebug(Log::HLE, 0, "latchAddr %08x", latchAddr); } static u32 sceHprmReadLatch(u32 latchAddr) { - // Real hardware/JPCSP: 4 x u32 output struct, dummied out to all-zero (nothing held/pressed). - for (int i = 0; i < 4; i++) - Memory::WriteOrException_U32(0, latchAddr + i * 4); + WriteEmptyLatch(latchAddr); return hleLogDebug(Log::HLE, 0, "latchAddr %08x", latchAddr); } diff --git a/Core/HLE/sceHprm.h b/Core/HLE/sceHprm.h index bcdaffb3d1..d864c7d07f 100644 --- a/Core/HLE/sceHprm.h +++ b/Core/HLE/sceHprm.h @@ -17,5 +17,7 @@ #pragma once +// HPRM - headphone remote. The PSP has a remote control for the headphones, which can be used to control music playback and volume. +// This module is used by the music player and some games, including DJ Max Portable games. void Register_sceHprm(); -void Register_sceHprm_driver(); \ No newline at end of file +void Register_sceHprm_driver();