From 340f733488b6ce38371d83d8e52a58783334ba77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20S=C3=A1=20Menezes?= Date: Sun, 14 Jan 2024 02:47:28 +0000 Subject: [PATCH] Enable cheevos for Wii builds (#16116) * Fixed libogc error codes interpretation for sockets * Added thread code for libogc rc_compat * Enabled cheevos for Wii --- Makefile.wii | 4 +++- deps/rcheevos/src/rc_compat.c | 25 +++++++++++++++++++++++- libretro-common/include/net/net_compat.h | 4 ++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Makefile.wii b/Makefile.wii index cd81625a07..3f702da3df 100644 --- a/Makefile.wii +++ b/Makefile.wii @@ -162,8 +162,9 @@ HAVE_XMB := 0 HAVE_OZONE := 0 HAVE_RGUI := 1 HAVE_MATERIALUI := 0 +HAVE_CHEEVOS := 1 -CFLAGS += -DHAVE_SOCKET_LEGACY +CFLAGS += -DHAVE_SOCKET_LEGACY -DHAVE_CHEEVOS APP_BOOTER_DIR = wii/app_booter PLATOBJS := $(APP_BOOTER_DIR)/app_booter.binobj @@ -174,6 +175,7 @@ endif INCLUDE += -I./libretro-common/include \ -Ideps \ + -Ideps/rcheevos/include \ -Ideps/stb CFLAGS += -Wall -std=gnu99 $(MACHDEP) $(PLATCFLAGS) $(INCLUDE) diff --git a/deps/rcheevos/src/rc_compat.c b/deps/rcheevos/src/rc_compat.c index 0ba7601ad2..72819cf214 100644 --- a/deps/rcheevos/src/rc_compat.c +++ b/deps/rcheevos/src/rc_compat.c @@ -85,7 +85,8 @@ struct tm* rc_gmtime_s(struct tm* buf, const time_t* timer) #endif #ifndef RC_NO_THREADS -#ifdef _WIN32 + +#if defined(_WIN32) /* https://gist.github.com/roxlu/1c1af99f92bafff9d8d9 */ @@ -113,6 +114,28 @@ void rc_mutex_unlock(rc_mutex_t* mutex) ReleaseMutex(mutex->handle); } +#elif defined(GEKKO) + +void rc_mutex_init(rc_mutex_t *mutex) +{ + LWP_MutexInit(mutex, NULL); +} + +void rc_mutex_destroy(rc_mutex_t* mutex) +{ + LWP_MutexDestroy(mutex); +} + +void rc_mutex_lock(rc_mutex_t* mutex) +{ + LWP_MutexLock(mutex); +} + +void rc_mutex_unlock(rc_mutex_t* mutex) +{ + LWP_MutexUnlock(mutex); +} + #else void rc_mutex_init(rc_mutex_t* mutex) diff --git a/libretro-common/include/net/net_compat.h b/libretro-common/include/net/net_compat.h index 3408b47672..05970a79d1 100644 --- a/libretro-common/include/net/net_compat.h +++ b/libretro-common/include/net/net_compat.h @@ -352,6 +352,8 @@ static INLINE bool isagain(int val) return (val == SCE_NET_ERROR_EAGAIN) || (val == SCE_NET_ERROR_EWOULDBLOCK); #elif defined(WIIU) return (val == -1) && (socketlasterr() == SO_SUCCESS || socketlasterr() == SO_EWOULDBLOCK); +#elif defined(GEKKO) + return (-val == EAGAIN); #else return (val < 0) && (errno == EAGAIN || errno == EWOULDBLOCK); #endif @@ -367,6 +369,8 @@ static INLINE bool isinprogress(int val) return (val == SCE_NET_ERROR_EINPROGRESS); #elif defined(WIIU) return (val == -1) && (socketlasterr() == SO_EINPROGRESS); +#elif defined(GEKKO) + return (-val == EINPROGRESS); #else return (val < 0) && (errno == EINPROGRESS); #endif