Libraries: Better libSceMove stubs (#3433)

* Improved libSceMove stubs

These should more accurately represent how an actual PS4 behaves when a game calls libSceMove functions while no move controllers are connected.

* Clang

* Change sceMoveGetExtensionPortInfo stub

Not entirely sure the ExtensionPortData struct is for this one, but the struct itself isn't exactly important for now anyway.

* Fix sceMoveTerm

* Update move.cpp
This commit is contained in:
Stephen Miller
2025-08-18 19:41:50 -05:00
committed by GitHub
parent 0b02364f97
commit 68e35d57d2
4 changed files with 153 additions and 23 deletions

View File

@@ -4,47 +4,133 @@
#include "common/logging/log.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/libs.h"
#include "core/libraries/move/move.h"
#include "core/libraries/move/move_error.h"
#include "move.h"
namespace Libraries::Move {
int PS4_SYSV_ABI sceMoveOpen() {
LOG_TRACE(Lib_Move, "(STUBBED) called");
return ORBIS_FAIL;
}
static bool g_library_initialized = false;
int PS4_SYSV_ABI sceMoveGetDeviceInfo() {
LOG_ERROR(Lib_Move, "(STUBBED) called");
s32 PS4_SYSV_ABI sceMoveInit() {
if (g_library_initialized) {
return ORBIS_MOVE_ERROR_ALREADY_INIT;
}
LOG_WARNING(Lib_Move, "Move controllers are not supported yet");
g_library_initialized = true;
return ORBIS_OK;
}
int PS4_SYSV_ABI sceMoveReadStateLatest() {
LOG_TRACE(Lib_Move, "(STUBBED) called");
s32 PS4_SYSV_ABI sceMoveOpen(Libraries::UserService::OrbisUserServiceUserId user_id, s32 type,
s32 index) {
LOG_DEBUG(Lib_Move, "called");
if (!g_library_initialized) {
return ORBIS_MOVE_ERROR_NOT_INIT;
}
// Even when no controllers are connected, this returns a proper handle.
static s32 handle = 1;
return handle++;
}
s32 PS4_SYSV_ABI sceMoveGetDeviceInfo(s32 handle, OrbisMoveDeviceInfo* info) {
LOG_TRACE(Lib_Move, "called");
if (!g_library_initialized) {
return ORBIS_MOVE_ERROR_NOT_INIT;
}
if (info == nullptr) {
return ORBIS_MOVE_ERROR_INVALID_ARG;
}
return ORBIS_MOVE_ERROR_NO_CONTROLLER_CONNECTED;
}
s32 PS4_SYSV_ABI sceMoveReadStateLatest(s32 handle, OrbisMoveData* data) {
LOG_TRACE(Lib_Move, "(called");
if (!g_library_initialized) {
return ORBIS_MOVE_ERROR_NOT_INIT;
}
if (data == nullptr) {
return ORBIS_MOVE_ERROR_INVALID_ARG;
}
return ORBIS_MOVE_ERROR_NO_CONTROLLER_CONNECTED;
}
s32 PS4_SYSV_ABI sceMoveReadStateRecent(s32 handle, s64 timestamp, OrbisMoveData* data,
s32* out_count) {
LOG_TRACE(Lib_Move, "called");
if (!g_library_initialized) {
return ORBIS_MOVE_ERROR_NOT_INIT;
}
if (timestamp < 0 || data == nullptr || out_count == nullptr) {
return ORBIS_MOVE_ERROR_INVALID_ARG;
}
return ORBIS_MOVE_ERROR_NO_CONTROLLER_CONNECTED;
}
s32 PS4_SYSV_ABI sceMoveGetExtensionPortInfo(s32 handle, void* data) {
LOG_TRACE(Lib_Move, "called");
if (!g_library_initialized) {
return ORBIS_MOVE_ERROR_NOT_INIT;
}
if (data == nullptr) {
return ORBIS_MOVE_ERROR_INVALID_ARG;
}
return ORBIS_MOVE_ERROR_NO_CONTROLLER_CONNECTED;
}
s32 PS4_SYSV_ABI sceMoveSetVibration(s32 handle, u8 intensity) {
LOG_TRACE(Lib_Move, "called");
if (!g_library_initialized) {
return ORBIS_MOVE_ERROR_NOT_INIT;
}
return ORBIS_MOVE_ERROR_NO_CONTROLLER_CONNECTED;
}
s32 PS4_SYSV_ABI sceMoveSetLightSphere(s32 handle, u8 red, u8 green, u8 blue) {
LOG_TRACE(Lib_Move, "called");
if (!g_library_initialized) {
return ORBIS_MOVE_ERROR_NOT_INIT;
}
return ORBIS_MOVE_ERROR_NO_CONTROLLER_CONNECTED;
}
s32 PS4_SYSV_ABI sceMoveResetLightSphere(s32 handle) {
LOG_TRACE(Lib_Move, "called");
if (!g_library_initialized) {
return ORBIS_MOVE_ERROR_NOT_INIT;
}
// Returns success, even if no controllers are connected.
return ORBIS_OK;
}
int PS4_SYSV_ABI sceMoveReadStateRecent() {
LOG_TRACE(Lib_Move, "(STUBBED) called");
s32 PS4_SYSV_ABI sceMoveClose(s32 handle) {
LOG_DEBUG(Lib_Move, "called");
if (!g_library_initialized) {
return ORBIS_MOVE_ERROR_NOT_INIT;
}
return ORBIS_OK;
}
int PS4_SYSV_ABI sceMoveTerm() {
LOG_ERROR(Lib_Move, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceMoveInit() {
LOG_ERROR(Lib_Move, "(STUBBED) called");
s32 PS4_SYSV_ABI sceMoveTerm() {
LOG_DEBUG(Lib_Move, "called");
if (!g_library_initialized) {
return ORBIS_MOVE_ERROR_NOT_INIT;
}
g_library_initialized = false;
return ORBIS_OK;
}
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("j1ITE-EoJmE", "libSceMove", 1, "libSceMove", 1, 1, sceMoveInit);
LIB_FUNCTION("HzC60MfjJxU", "libSceMove", 1, "libSceMove", 1, 1, sceMoveOpen);
LIB_FUNCTION("GWXTyxs4QbE", "libSceMove", 1, "libSceMove", 1, 1, sceMoveGetDeviceInfo);
LIB_FUNCTION("ttU+JOhShl4", "libSceMove", 1, "libSceMove", 1, 1, sceMoveReadStateLatest);
LIB_FUNCTION("f2bcpK6kJfg", "libSceMove", 1, "libSceMove", 1, 1, sceMoveReadStateRecent);
LIB_FUNCTION("y5h7f8H1Jnk", "libSceMove", 1, "libSceMove", 1, 1, sceMoveGetExtensionPortInfo);
LIB_FUNCTION("IFQwtT2CeY0", "libSceMove", 1, "libSceMove", 1, 1, sceMoveSetVibration);
LIB_FUNCTION("T8KYHPs1JE8", "libSceMove", 1, "libSceMove", 1, 1, sceMoveSetLightSphere);
LIB_FUNCTION("zuxWAg3HAac", "libSceMove", 1, "libSceMove", 1, 1, sceMoveResetLightSphere);
LIB_FUNCTION("XX6wlxpHyeo", "libSceMove", 1, "libSceMove", 1, 1, sceMoveClose);
LIB_FUNCTION("tsZi60H4ypY", "libSceMove", 1, "libSceMove", 1, 1, sceMoveTerm);
LIB_FUNCTION("j1ITE-EoJmE", "libSceMove", 1, "libSceMove", 1, 1, sceMoveInit);
};
} // namespace Libraries::Move