From 6d2b2779ea7ac02affc16c3a2414d05767aff883 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 24 Jun 2024 13:25:50 +0300 Subject: [PATCH 1/4] added sceKernelPwrite --- src/core/libraries/kernel/file_system.cpp | 32 +++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/core/libraries/kernel/file_system.cpp b/src/core/libraries/kernel/file_system.cpp index 2a874c63..b3449cfd 100644 --- a/src/core/libraries/kernel/file_system.cpp +++ b/src/core/libraries/kernel/file_system.cpp @@ -384,6 +384,37 @@ int PS4_SYSV_ABI sceKernelGetdirentries(int fd, char* buf, int nbytes, s64* base return GetDents(fd, buf, nbytes, basep); } +s64 PS4_SYSV_ABI sceKernelPwrite(int d, void* buf, size_t nbytes, s64 offset) { + if (d < 3) { + return ORBIS_KERNEL_ERROR_EPERM; + } + + if (buf == nullptr) { + return ORBIS_KERNEL_ERROR_EFAULT; + } + + if (offset < 0) { + return ORBIS_KERNEL_ERROR_EINVAL; + } + + auto* h = Common::Singleton::Instance(); + auto* file = h->GetFile(d); + + if (file == nullptr) { + return ORBIS_KERNEL_ERROR_EBADF; + } + + file->m_mutex.lock(); + + auto pos = file->f.Tell(); + file->f.Seek(offset); + u32 bytes_write = file->f.WriteRaw(buf, static_cast(nbytes)); + file->f.Seek(pos); + file->m_mutex.unlock(); + + return bytes_write; +} + void fileSystemSymbolsRegister(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("1G3lF1Gg1k8", "libkernel", 1, "libkernel", 1, 1, sceKernelOpen); LIB_FUNCTION("wuCroIGjt2g", "libScePosix", 1, "libkernel", 1, 1, posix_open); @@ -409,6 +440,7 @@ void fileSystemSymbolsRegister(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("fTx66l5iWIA", "libkernel", 1, "libkernel", 1, 1, sceKernelFsync); LIB_FUNCTION("j2AIqSqJP0w", "libkernel", 1, "libkernel", 1, 1, sceKernelGetdents); LIB_FUNCTION("taRWhTJFTgE", "libkernel", 1, "libkernel", 1, 1, sceKernelGetdirentries); + LIB_FUNCTION("nKWi-N2HBV4", "libkernel", 1, "libkernel", 1, 1, sceKernelPwrite); // openOrbis (to check if it is valid out of OpenOrbis LIB_FUNCTION("6c3rCVE-fTU", "libkernel", 1, "libkernel", 1, 1, From ad4db71e00c745b839aa80f90c806940594f98af Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 24 Jun 2024 13:26:18 +0300 Subject: [PATCH 2/4] missing touchpad reset in scePadReadState --- src/core/libraries/pad/pad.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/core/libraries/pad/pad.cpp b/src/core/libraries/pad/pad.cpp index 949b71be..e7644e9e 100644 --- a/src/core/libraries/pad/pad.cpp +++ b/src/core/libraries/pad/pad.cpp @@ -321,6 +321,19 @@ int PS4_SYSV_ABI scePadReadState(s32 handle, OrbisPadData* pData) { pData->orientation.y = 0; pData->orientation.z = 0; pData->orientation.w = 0; + pData->acceleration.x = 0.0f; + pData->acceleration.y = 0.0f; + pData->acceleration.z = 0.0f; + pData->angularVelocity.x = 0.0f; + pData->angularVelocity.y = 0.0f; + pData->angularVelocity.z = 0.0f; + pData->touchData.touchNum = 0; + pData->touchData.touch[0].x = 0; + pData->touchData.touch[0].y = 0; + pData->touchData.touch[0].id = 1; + pData->touchData.touch[1].x = 0; + pData->touchData.touch[1].y = 0; + pData->touchData.touch[1].id = 2; pData->timestamp = state.time; pData->connected = true; // isConnected; //TODO fix me proper pData->connectedCount = 1; // connectedCount; From 640354667ea3536c48130c59ae521229136214a1 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 24 Jun 2024 13:41:18 +0300 Subject: [PATCH 3/4] insure we reset padData --- src/core/libraries/pad/pad.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/libraries/pad/pad.cpp b/src/core/libraries/pad/pad.cpp index e7644e9e..3004c2f9 100644 --- a/src/core/libraries/pad/pad.cpp +++ b/src/core/libraries/pad/pad.cpp @@ -85,6 +85,7 @@ int PS4_SYSV_ABI scePadGetCapability() { int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerInformation* pInfo) { LOG_INFO(Lib_Pad, "called handle = {}", handle); + std::memset(&pInfo, 0, sizeof(OrbisPadControllerInformation)); pInfo->touchPadInfo.pixelDensity = 1; pInfo->touchPadInfo.resolution.x = 1920; pInfo->touchPadInfo.resolution.y = 950; @@ -238,6 +239,7 @@ int PS4_SYSV_ABI scePadOutputReport() { } int PS4_SYSV_ABI scePadRead(s32 handle, OrbisPadData* pData, s32 num) { + std::memset(&pData, 0, sizeof(OrbisPadData)); int connected_count = 0; bool connected = false; Input::State states[64]; @@ -308,7 +310,7 @@ int PS4_SYSV_ABI scePadReadState(s32 handle, OrbisPadData* pData) { int connectedCount = 0; bool isConnected = false; Input::State state; - + std::memset(&pData, 0, sizeof(OrbisPadData)); controller->ReadState(&state, &isConnected, &connectedCount); pData->buttons = state.buttonsState; pData->leftStick.x = state.axes[static_cast(Input::Axis::LeftX)]; From 1b6cb32b34e337f7629510678d9babcb01056a03 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 24 Jun 2024 13:46:45 +0300 Subject: [PATCH 4/4] re-fix --- src/core/libraries/pad/pad.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/libraries/pad/pad.cpp b/src/core/libraries/pad/pad.cpp index 3004c2f9..e318e152 100644 --- a/src/core/libraries/pad/pad.cpp +++ b/src/core/libraries/pad/pad.cpp @@ -85,7 +85,7 @@ int PS4_SYSV_ABI scePadGetCapability() { int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerInformation* pInfo) { LOG_INFO(Lib_Pad, "called handle = {}", handle); - std::memset(&pInfo, 0, sizeof(OrbisPadControllerInformation)); + std::memset(pInfo, 0, sizeof(OrbisPadControllerInformation)); pInfo->touchPadInfo.pixelDensity = 1; pInfo->touchPadInfo.resolution.x = 1920; pInfo->touchPadInfo.resolution.y = 950; @@ -239,7 +239,7 @@ int PS4_SYSV_ABI scePadOutputReport() { } int PS4_SYSV_ABI scePadRead(s32 handle, OrbisPadData* pData, s32 num) { - std::memset(&pData, 0, sizeof(OrbisPadData)); + std::memset(pData, 0, sizeof(OrbisPadData)); int connected_count = 0; bool connected = false; Input::State states[64]; @@ -310,7 +310,7 @@ int PS4_SYSV_ABI scePadReadState(s32 handle, OrbisPadData* pData) { int connectedCount = 0; bool isConnected = false; Input::State state; - std::memset(&pData, 0, sizeof(OrbisPadData)); + std::memset(pData, 0, sizeof(OrbisPadData)); controller->ReadState(&state, &isConnected, &connectedCount); pData->buttons = state.buttonsState; pData->leftStick.x = state.axes[static_cast(Input::Axis::LeftX)];