mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-04 08:06:20 +00:00
fixes to the old pad code
This commit is contained in:
parent
9501bd77d4
commit
57c65cadb8
4 changed files with 86 additions and 264 deletions
|
@ -2,9 +2,11 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
// Generated By moduleGenerator
|
||||
#include <common/singleton.h>
|
||||
#include "common/logging/log.h"
|
||||
#include "core/libraries/error_codes.h"
|
||||
#include "core/libraries/libs.h"
|
||||
#include "input/controller.h"
|
||||
#include "pad.h"
|
||||
|
||||
namespace Libraries::Pad {
|
||||
|
@ -82,8 +84,17 @@ int PS4_SYSV_ABI scePadGetCapability() {
|
|||
}
|
||||
|
||||
int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerInformation* pInfo) {
|
||||
LOG_ERROR(Lib_Pad, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
LOG_INFO(Lib_Pad, "called handle = {}", handle);
|
||||
pInfo->touchPadInfo.pixelDensity = 1;
|
||||
pInfo->touchPadInfo.resolution.x = 1920;
|
||||
pInfo->touchPadInfo.resolution.y = 950;
|
||||
pInfo->stickInfo.deadZoneLeft = 2;
|
||||
pInfo->stickInfo.deadZoneRight = 2;
|
||||
pInfo->connectionType = ORBIS_PAD_PORT_TYPE_STANDARD;
|
||||
pInfo->connectedCount = 1;
|
||||
pInfo->connected = 1;
|
||||
pInfo->deviceClass = ORBIS_PAD_DEVICE_CLASS_STANDARD;
|
||||
return SCE_OK;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI scePadGetDataInternal() {
|
||||
|
@ -207,8 +218,8 @@ int PS4_SYSV_ABI scePadMbusTerm() {
|
|||
}
|
||||
|
||||
int PS4_SYSV_ABI scePadOpen(s32 userId, s32 type, s32 index, const OrbisPadOpenParam* pParam) {
|
||||
LOG_ERROR(Lib_Pad, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
LOG_INFO(Lib_Pad, "(DUMMY) called user_id = {} type = {} index = {}", userId, type, index);
|
||||
return 1; // dummy
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI scePadOpenExt() {
|
||||
|
@ -227,8 +238,48 @@ int PS4_SYSV_ABI scePadOutputReport() {
|
|||
}
|
||||
|
||||
int PS4_SYSV_ABI scePadRead(s32 handle, OrbisPadData* pData, s32 num) {
|
||||
LOG_ERROR(Lib_Pad, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
int connected_count = 0;
|
||||
bool connected = false;
|
||||
Input::State states[64];
|
||||
auto* controller = Common::Singleton<Input::GameController>::Instance();
|
||||
int ret_num = controller->ReadStates(states, num, &connected, &connected_count);
|
||||
|
||||
if (!connected) {
|
||||
ret_num = 1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < ret_num; i++) {
|
||||
pData[i].buttons = states[i].buttonsState;
|
||||
pData[i].leftStick.x = 128; // dummy
|
||||
pData[i].leftStick.y = 128; // dummy
|
||||
pData[i].rightStick.x = 0; // dummy
|
||||
pData[i].rightStick.y = 0; // dummy
|
||||
pData[i].analogButtons.l2 = 0; // dummy
|
||||
pData[i].analogButtons.r2 = 0; // dummy
|
||||
pData[i].orientation.x = 0.0f;
|
||||
pData[i].orientation.y = 0.0f;
|
||||
pData[i].orientation.z = 0.0f;
|
||||
pData[i].orientation.w = 1.0f;
|
||||
pData[i].acceleration.x = 0.0f;
|
||||
pData[i].acceleration.y = 0.0f;
|
||||
pData[i].acceleration.z = 0.0f;
|
||||
pData[i].angularVelocity.x = 0.0f;
|
||||
pData[i].angularVelocity.y = 0.0f;
|
||||
pData[i].angularVelocity.z = 0.0f;
|
||||
pData[i].touchData.touchNum = 0;
|
||||
pData[i].touchData.touch[0].x = 0;
|
||||
pData[i].touchData.touch[0].y = 0;
|
||||
pData[i].touchData.touch[0].id = 1;
|
||||
pData[i].touchData.touch[1].x = 0;
|
||||
pData[i].touchData.touch[1].y = 0;
|
||||
pData[i].touchData.touch[1].id = 2;
|
||||
pData[i].connected = connected;
|
||||
pData[i].timestamp = states[i].time;
|
||||
pData[i].connectedCount = connected_count;
|
||||
pData[i].deviceUniqueDataLen = 0;
|
||||
}
|
||||
|
||||
return ret_num;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI scePadReadBlasterForTracker() {
|
||||
|
@ -252,8 +303,30 @@ int PS4_SYSV_ABI scePadReadHistory() {
|
|||
}
|
||||
|
||||
int PS4_SYSV_ABI scePadReadState(s32 handle, OrbisPadData* pData) {
|
||||
LOG_ERROR(Lib_Pad, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
auto* controller = Common::Singleton<Input::GameController>::Instance();
|
||||
|
||||
int connectedCount = 0;
|
||||
bool isConnected = false;
|
||||
Input::State state;
|
||||
|
||||
controller->readState(&state, &isConnected, &connectedCount);
|
||||
pData->buttons = state.buttonsState;
|
||||
pData->leftStick.x = 128; // dummy
|
||||
pData->leftStick.y = 128; // dummy
|
||||
pData->rightStick.x = 0; // dummy
|
||||
pData->rightStick.y = 0; // dummy
|
||||
pData->analogButtons.r2 = 0; // dummy
|
||||
pData->analogButtons.l2 = 0; // dummy
|
||||
pData->orientation.x = 0;
|
||||
pData->orientation.y = 0;
|
||||
pData->orientation.z = 0;
|
||||
pData->orientation.w = 0;
|
||||
pData->timestamp = state.time;
|
||||
pData->connected = true; // isConnected; //TODO fix me proper
|
||||
pData->connectedCount = 1; // connectedCount;
|
||||
pData->deviceUniqueDataLen = 0;
|
||||
|
||||
return SCE_OK;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI scePadReadStateExt() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue