some pad fixes (fixing metal slug 3 and risk of rain)

This commit is contained in:
georgemoralis 2024-08-07 21:39:17 +03:00
parent 7b7d1cb26f
commit 3ef69cae5e
1 changed files with 8 additions and 5 deletions

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
// Generated By moduleGenerator // Generated By moduleGenerator
#include <common/assert.h>
#include <common/singleton.h> #include <common/singleton.h>
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/libraries/error_codes.h" #include "core/libraries/error_codes.h"
@ -85,7 +86,6 @@ 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));
if (handle < 0) { if (handle < 0) {
pInfo->touchPadInfo.pixelDensity = 1; pInfo->touchPadInfo.pixelDensity = 1;
pInfo->touchPadInfo.resolution.x = 1920; pInfo->touchPadInfo.resolution.x = 1920;
@ -251,7 +251,9 @@ 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)); if (handle != 1) {
UNREACHABLE_MSG("unknown handle");
}
int connected_count = 0; int connected_count = 0;
bool connected = false; bool connected = false;
Input::State states[64]; Input::State states[64];
@ -318,11 +320,12 @@ int PS4_SYSV_ABI scePadReadHistory() {
int PS4_SYSV_ABI scePadReadState(s32 handle, OrbisPadData* pData) { int PS4_SYSV_ABI scePadReadState(s32 handle, OrbisPadData* pData) {
auto* controller = Common::Singleton<Input::GameController>::Instance(); auto* controller = Common::Singleton<Input::GameController>::Instance();
if (handle != 1) {
UNREACHABLE_MSG("unknown handle");
}
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)];
@ -334,7 +337,7 @@ int PS4_SYSV_ABI scePadReadState(s32 handle, OrbisPadData* pData) {
pData->orientation.x = 0; pData->orientation.x = 0;
pData->orientation.y = 0; pData->orientation.y = 0;
pData->orientation.z = 0; pData->orientation.z = 0;
pData->orientation.w = 0; pData->orientation.w = 1;
pData->acceleration.x = 0.0f; pData->acceleration.x = 0.0f;
pData->acceleration.y = 0.0f; pData->acceleration.y = 0.0f;
pData->acceleration.z = 0.0f; pData->acceleration.z = 0.0f;