Fix VideoOut events (#2330)

* Fix event data for VideoOut events

Fix is based on some decompilation work shared by red_prig.

* Cleanup

* Oops

* Style fixes

* Clang

* Fix libSceVideoOut event idents

Based on some decompilation work, events coming from libSceVideoOut use a separate set of values for identifiers. These values are only converted to OrbisVideoOutEventId values during calls to sceVideoOutGetEventId.
For convenience, I've placed all relevant identifiers into a enum called OrbisVideoOutInternalEventId.
Thanks to @red_prig for the tips.

* Fix?

Seems like `static_cast<u32>(hint) & 0xFF == event.ident` here, and doing those right shifts on the event.ident winds up breaking stuff.
Without this change, the if always fails because event_id was getting set to 0 instead.

* Clang
This commit is contained in:
Stephen Miller 2025-02-03 09:37:28 -06:00 committed by GitHub
parent 02ad2b78fa
commit 8ad650582a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 69 additions and 10 deletions

View file

@ -84,7 +84,11 @@ bool EqueueInternal::TriggerEvent(u64 ident, s16 filter, void* trigger_data) {
std::scoped_lock lock{m_mutex};
for (auto& event : m_events) {
if (event.event.ident == ident && event.event.filter == filter) {
event.Trigger(trigger_data);
if (filter == SceKernelEvent::Filter::VideoOut) {
event.TriggerDisplay(trigger_data);
} else {
event.Trigger(trigger_data);
}
has_found = true;
}
}

View file

@ -9,6 +9,7 @@
#include <vector>
#include <boost/asio/steady_timer.hpp>
#include "common/rdtsc.h"
#include "common/types.h"
namespace Core::Loader {
@ -81,6 +82,25 @@ struct EqueueEvent {
event.data = reinterpret_cast<uintptr_t>(data);
}
void TriggerDisplay(void* data) {
is_triggered = true;
auto hint = reinterpret_cast<u64>(data);
if (hint != 0) {
auto hint_h = static_cast<u32>(hint >> 8) & 0xFFFFFF;
auto ident_h = static_cast<u32>(event.ident >> 40);
if ((static_cast<u32>(hint) & 0xFF) == event.ident && event.ident != 0xFE &&
((hint_h ^ ident_h) & 0xFF) == 0) {
auto time = Common::FencedRDTSC();
auto mask = 0xF000;
if ((static_cast<u32>(event.data) & 0xF000) != 0xF000) {
mask = (static_cast<u32>(event.data) + 0x1000) & 0xF000;
}
event.data = (mask | static_cast<u64>(static_cast<u32>(time) & 0xFFF) |
(hint & 0xFFFFFFFFFFFF0000));
}
}
}
bool IsTriggered() const {
return is_triggered;
}