mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Created EventHandlerV2 and added client to DoFrame
As MemoryPeeker V1 is no longer in use, it is deleted and MemoryPeekerV2 is renamed in its place.
This commit is contained in:
parent
7497df99df
commit
c88d4cf040
@ -36,10 +36,11 @@ void AchievementManager::Init()
|
|||||||
{
|
{
|
||||||
if (!m_client && Config::Get(Config::RA_ENABLED))
|
if (!m_client && Config::Get(Config::RA_ENABLED))
|
||||||
{
|
{
|
||||||
m_client = rc_client_create(MemoryPeekerV2, RequestV2);
|
m_client = rc_client_create(MemoryPeeker, RequestV2);
|
||||||
std::string host_url = Config::Get(Config::RA_HOST_URL);
|
std::string host_url = Config::Get(Config::RA_HOST_URL);
|
||||||
if (!host_url.empty())
|
if (!host_url.empty())
|
||||||
rc_client_set_host(m_client, host_url.c_str());
|
rc_client_set_host(m_client, host_url.c_str());
|
||||||
|
rc_client_set_event_handler(m_client, EventHandlerV2);
|
||||||
rc_client_enable_logging(m_client, RC_CLIENT_LOG_LEVEL_VERBOSE,
|
rc_client_enable_logging(m_client, RC_CLIENT_LOG_LEVEL_VERBOSE,
|
||||||
[](const char* message, const rc_client_t* client) {
|
[](const char* message, const rc_client_t* client) {
|
||||||
INFO_LOG_FMT(ACHIEVEMENTS, "{}", message);
|
INFO_LOG_FMT(ACHIEVEMENTS, "{}", message);
|
||||||
@ -215,15 +216,7 @@ void AchievementManager::DoFrame()
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::lock_guard lg{m_lock};
|
std::lock_guard lg{m_lock};
|
||||||
rc_runtime_do_frame(
|
rc_client_do_frame(m_client);
|
||||||
&m_runtime,
|
|
||||||
[](const rc_runtime_event_t* runtime_event) {
|
|
||||||
GetInstance().AchievementEventHandler(runtime_event);
|
|
||||||
},
|
|
||||||
[](unsigned address, unsigned num_bytes, void* ud) {
|
|
||||||
return static_cast<AchievementManager*>(ud)->MemoryPeeker(address, num_bytes, ud);
|
|
||||||
},
|
|
||||||
this, nullptr);
|
|
||||||
}
|
}
|
||||||
if (!m_system)
|
if (!m_system)
|
||||||
return;
|
return;
|
||||||
@ -237,36 +230,6 @@ void AchievementManager::DoFrame()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 AchievementManager::MemoryPeeker(u32 address, u32 num_bytes, void* ud)
|
|
||||||
{
|
|
||||||
if (!m_system)
|
|
||||||
return 0u;
|
|
||||||
Core::CPUThreadGuard threadguard(*m_system);
|
|
||||||
switch (num_bytes)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
return m_system->GetMMU()
|
|
||||||
.HostTryReadU8(threadguard, address, PowerPC::RequestedAddressSpace::Physical)
|
|
||||||
.value_or(PowerPC::ReadResult<u8>(false, 0u))
|
|
||||||
.value;
|
|
||||||
case 2:
|
|
||||||
return Common::swap16(
|
|
||||||
m_system->GetMMU()
|
|
||||||
.HostTryReadU16(threadguard, address, PowerPC::RequestedAddressSpace::Physical)
|
|
||||||
.value_or(PowerPC::ReadResult<u16>(false, 0u))
|
|
||||||
.value);
|
|
||||||
case 4:
|
|
||||||
return Common::swap32(
|
|
||||||
m_system->GetMMU()
|
|
||||||
.HostTryReadU32(threadguard, address, PowerPC::RequestedAddressSpace::Physical)
|
|
||||||
.value_or(PowerPC::ReadResult<u32>(false, 0u))
|
|
||||||
.value);
|
|
||||||
default:
|
|
||||||
ASSERT(false);
|
|
||||||
return 0u;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AchievementManager::AchievementEventHandler(const rc_runtime_event_t* runtime_event)
|
void AchievementManager::AchievementEventHandler(const rc_runtime_event_t* runtime_event)
|
||||||
{
|
{
|
||||||
switch (runtime_event->type)
|
switch (runtime_event->type)
|
||||||
@ -757,10 +720,7 @@ void AchievementManager::GenerateRichPresence(const Core::CPUThreadGuard& guard)
|
|||||||
std::lock_guard lg{m_lock};
|
std::lock_guard lg{m_lock};
|
||||||
rc_runtime_get_richpresence(
|
rc_runtime_get_richpresence(
|
||||||
&m_runtime, m_rich_presence.data(), RP_SIZE,
|
&m_runtime, m_rich_presence.data(), RP_SIZE,
|
||||||
[](unsigned address, unsigned num_bytes, void* ud) {
|
[](unsigned address, unsigned num_bytes, void* ud) { return 0u; }, this, nullptr);
|
||||||
return static_cast<AchievementManager*>(ud)->MemoryPeeker(address, num_bytes, ud);
|
|
||||||
},
|
|
||||||
this, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AchievementManager::ResponseType AchievementManager::AwardAchievement(AchievementId achievement_id)
|
AchievementManager::ResponseType AchievementManager::AwardAchievement(AchievementId achievement_id)
|
||||||
@ -1168,7 +1128,7 @@ void AchievementManager::RequestV2(const rc_api_request_t* request,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 AchievementManager::MemoryPeekerV2(u32 address, u8* buffer, u32 num_bytes, rc_client_t* client)
|
u32 AchievementManager::MemoryPeeker(u32 address, u8* buffer, u32 num_bytes, rc_client_t* client)
|
||||||
{
|
{
|
||||||
if (buffer == nullptr)
|
if (buffer == nullptr)
|
||||||
return 0u;
|
return 0u;
|
||||||
@ -1239,4 +1199,8 @@ void AchievementManager::FetchBadge(AchievementManager::BadgeStatus* badge, u32
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AchievementManager::EventHandlerV2(const rc_client_event_t* event, rc_client_t* client)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#endif // USE_RETRO_ACHIEVEMENTS
|
#endif // USE_RETRO_ACHIEVEMENTS
|
||||||
|
@ -127,7 +127,6 @@ public:
|
|||||||
void FetchGameBadges();
|
void FetchGameBadges();
|
||||||
|
|
||||||
void DoFrame();
|
void DoFrame();
|
||||||
u32 MemoryPeeker(u32 address, u32 num_bytes, void* ud);
|
|
||||||
void AchievementEventHandler(const rc_runtime_event_t* runtime_event);
|
void AchievementEventHandler(const rc_runtime_event_t* runtime_event);
|
||||||
|
|
||||||
std::recursive_mutex& GetLock();
|
std::recursive_mutex& GetLock();
|
||||||
@ -201,8 +200,9 @@ private:
|
|||||||
|
|
||||||
static void RequestV2(const rc_api_request_t* request, rc_client_server_callback_t callback,
|
static void RequestV2(const rc_api_request_t* request, rc_client_server_callback_t callback,
|
||||||
void* callback_data, rc_client_t* client);
|
void* callback_data, rc_client_t* client);
|
||||||
static u32 MemoryPeekerV2(u32 address, u8* buffer, u32 num_bytes, rc_client_t* client);
|
static u32 MemoryPeeker(u32 address, u8* buffer, u32 num_bytes, rc_client_t* client);
|
||||||
void FetchBadge(BadgeStatus* badge, u32 badge_type, const BadgeNameFunction function);
|
void FetchBadge(BadgeStatus* badge, u32 badge_type, const BadgeNameFunction function);
|
||||||
|
static void EventHandlerV2(const rc_client_event_t* event, rc_client_t* client);
|
||||||
|
|
||||||
rc_runtime_t m_runtime{};
|
rc_runtime_t m_runtime{};
|
||||||
rc_client_t* m_client{};
|
rc_client_t* m_client{};
|
||||||
|
Loading…
Reference in New Issue
Block a user