2023-10-07 11:03:03 +02:00
|
|
|
#include "pad.h"
|
|
|
|
|
2023-10-31 07:47:58 +01:00
|
|
|
#include <core/PS4/HLE/ErrorCodes.h>
|
|
|
|
#include <core/PS4/HLE/Libs.h>
|
2023-10-07 11:03:03 +02:00
|
|
|
|
2023-10-15 09:03:26 +02:00
|
|
|
#include "Emulator/Util/singleton.h"
|
2023-10-20 06:25:52 +02:00
|
|
|
#include "Emulator/Host/controller.h"
|
2023-10-13 16:44:15 +02:00
|
|
|
#include <debug.h>
|
|
|
|
#include <Util/log.h>
|
2023-10-13 08:40:59 +02:00
|
|
|
|
2023-10-31 08:01:20 +01:00
|
|
|
namespace Core::Libraries::LibPad {
|
2023-10-13 16:44:15 +02:00
|
|
|
|
|
|
|
constexpr bool log_file_pad = true; // disable it to disable logging
|
|
|
|
|
2023-10-07 11:03:03 +02:00
|
|
|
int PS4_SYSV_ABI scePadInit() { return SCE_OK; }
|
|
|
|
|
2023-10-09 19:39:12 +02:00
|
|
|
int PS4_SYSV_ABI scePadOpen(Emulator::HLE::Libraries::LibUserService::SceUserServiceUserId userId, s32 type, s32 index,
|
|
|
|
const ScePadOpenParam* pParam) {
|
2023-10-31 08:04:08 +01:00
|
|
|
LOG_INFO_IF(log_file_pad, "scePadOpen userid = {} type = {} index = {}\n", userId, type, index);
|
2023-10-07 11:03:03 +02:00
|
|
|
return 1; // dummy
|
|
|
|
}
|
|
|
|
|
|
|
|
int PS4_SYSV_ABI scePadReadState(int32_t handle, ScePadData* pData) {
|
2023-10-15 09:03:26 +02:00
|
|
|
auto* controller = singleton<Emulator::Host::Controller::GameController>::instance();
|
2023-10-13 08:40:59 +02:00
|
|
|
|
|
|
|
int connectedCount = 0;
|
|
|
|
bool isConnected = false;
|
|
|
|
Emulator::Host::Controller::State state;
|
|
|
|
|
|
|
|
controller->readState(&state, &isConnected, &connectedCount);
|
|
|
|
pData->buttons = state.buttonsState;
|
2023-10-13 16:44:15 +02:00
|
|
|
pData->leftStick.x = 128; // dummy
|
|
|
|
pData->leftStick.y = 128; // dummy
|
2023-10-13 08:40:59 +02:00
|
|
|
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;
|
2023-10-30 07:57:43 +01:00
|
|
|
pData->timestamp = state.time;
|
2023-10-13 08:40:59 +02:00
|
|
|
pData->connected = true; // isConnected; //TODO fix me proper
|
|
|
|
pData->connectedCount = 1;//connectedCount;
|
|
|
|
pData->deviceUniqueDataLen = 0;
|
|
|
|
|
2023-10-07 11:03:03 +02:00
|
|
|
return SCE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void libPad_Register(SymbolsResolver* sym) {
|
|
|
|
LIB_FUNCTION("hv1luiJrqQM", "libScePad", 1, "libScePad", 1, 1, scePadInit);
|
|
|
|
LIB_FUNCTION("xk0AcarP3V4", "libScePad", 1, "libScePad", 1, 1, scePadOpen);
|
|
|
|
LIB_FUNCTION("YndgXqQVV7c", "libScePad", 1, "libScePad", 1, 1, scePadReadState);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Emulator::HLE::Libraries::LibPad
|