Merge pull request #214 from shadps4-emu/miscFixes

Misc fixes
This commit is contained in:
georgemoralis 2024-06-25 17:55:57 +03:00 committed by GitHub
commit c8a149c983
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 48 additions and 1 deletions

View File

@ -384,6 +384,37 @@ int PS4_SYSV_ABI sceKernelGetdirentries(int fd, char* buf, int nbytes, s64* base
return GetDents(fd, buf, nbytes, basep); 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<Core::FileSys::HandleTable>::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<u8>(buf, static_cast<u32>(nbytes));
file->f.Seek(pos);
file->m_mutex.unlock();
return bytes_write;
}
void fileSystemSymbolsRegister(Core::Loader::SymbolsResolver* sym) { void fileSystemSymbolsRegister(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("1G3lF1Gg1k8", "libkernel", 1, "libkernel", 1, 1, sceKernelOpen); LIB_FUNCTION("1G3lF1Gg1k8", "libkernel", 1, "libkernel", 1, 1, sceKernelOpen);
LIB_FUNCTION("wuCroIGjt2g", "libScePosix", 1, "libkernel", 1, 1, posix_open); 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("fTx66l5iWIA", "libkernel", 1, "libkernel", 1, 1, sceKernelFsync);
LIB_FUNCTION("j2AIqSqJP0w", "libkernel", 1, "libkernel", 1, 1, sceKernelGetdents); LIB_FUNCTION("j2AIqSqJP0w", "libkernel", 1, "libkernel", 1, 1, sceKernelGetdents);
LIB_FUNCTION("taRWhTJFTgE", "libkernel", 1, "libkernel", 1, 1, sceKernelGetdirentries); 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 // openOrbis (to check if it is valid out of OpenOrbis
LIB_FUNCTION("6c3rCVE-fTU", "libkernel", 1, "libkernel", 1, 1, LIB_FUNCTION("6c3rCVE-fTU", "libkernel", 1, "libkernel", 1, 1,

View File

@ -85,6 +85,7 @@ int PS4_SYSV_ABI scePadGetCapability() {
int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerInformation* pInfo) { int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerInformation* pInfo) {
LOG_INFO(Lib_Pad, "called handle = {}", handle); LOG_INFO(Lib_Pad, "called handle = {}", handle);
std::memset(pInfo, 0, sizeof(OrbisPadControllerInformation));
pInfo->touchPadInfo.pixelDensity = 1; pInfo->touchPadInfo.pixelDensity = 1;
pInfo->touchPadInfo.resolution.x = 1920; pInfo->touchPadInfo.resolution.x = 1920;
pInfo->touchPadInfo.resolution.y = 950; 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) { int PS4_SYSV_ABI scePadRead(s32 handle, OrbisPadData* pData, s32 num) {
std::memset(pData, 0, sizeof(OrbisPadData));
int connected_count = 0; int connected_count = 0;
bool connected = false; bool connected = false;
Input::State states[64]; Input::State states[64];
@ -308,7 +310,7 @@ int PS4_SYSV_ABI scePadReadState(s32 handle, OrbisPadData* pData) {
int connectedCount = 0; int connectedCount = 0;
bool isConnected = false; bool isConnected = false;
Input::State state; Input::State state;
std::memset(pData, 0, sizeof(OrbisPadData));
controller->ReadState(&state, &isConnected, &connectedCount); controller->ReadState(&state, &isConnected, &connectedCount);
pData->buttons = state.buttonsState; pData->buttons = state.buttonsState;
pData->leftStick.x = state.axes[static_cast<int>(Input::Axis::LeftX)]; pData->leftStick.x = state.axes[static_cast<int>(Input::Axis::LeftX)];
@ -321,6 +323,19 @@ int PS4_SYSV_ABI scePadReadState(s32 handle, OrbisPadData* pData) {
pData->orientation.y = 0; pData->orientation.y = 0;
pData->orientation.z = 0; pData->orientation.z = 0;
pData->orientation.w = 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->timestamp = state.time;
pData->connected = true; // isConnected; //TODO fix me proper pData->connected = true; // isConnected; //TODO fix me proper
pData->connectedCount = 1; // connectedCount; pData->connectedCount = 1; // connectedCount;