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, diff --git a/src/core/libraries/pad/pad.cpp b/src/core/libraries/pad/pad.cpp index 949b71be..e318e152 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)]; @@ -321,6 +323,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;