2024-02-23 22:32:32 +01:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
2024-02-23 21:57:57 +01:00
|
|
|
#include "Emulator/Host/controller.h"
|
2024-02-27 23:10:34 +01:00
|
|
|
#include "common/logging/log.h"
|
2023-11-05 12:41:10 +01:00
|
|
|
#include "common/singleton.h"
|
2023-11-06 00:11:54 +01:00
|
|
|
#include "core/hle/error_codes.h"
|
2024-02-23 21:57:57 +01:00
|
|
|
#include "core/hle/libraries/libpad/pad.h"
|
2023-11-06 00:11:54 +01:00
|
|
|
#include "core/hle/libraries/libs.h"
|
2023-10-13 08:40:59 +02:00
|
|
|
|
2024-03-14 13:18:16 +01:00
|
|
|
namespace OldLibraries::LibPad {
|
2023-10-13 16:44:15 +02:00
|
|
|
|
2023-11-06 00:11:54 +01:00
|
|
|
int PS4_SYSV_ABI scePadInit() {
|
2024-02-27 23:10:34 +01:00
|
|
|
LOG_WARNING(Lib_Pad, "(STUBBED) called");
|
2023-11-06 00:11:54 +01:00
|
|
|
return SCE_OK;
|
|
|
|
}
|
2023-10-07 11:03:03 +02:00
|
|
|
|
2024-03-14 13:18:16 +01:00
|
|
|
int PS4_SYSV_ABI scePadOpen(Libraries::UserService::OrbisUserServiceUserId user_id, s32 type,
|
2024-02-23 21:57:57 +01:00
|
|
|
s32 index, const ScePadOpenParam* pParam) {
|
2024-02-27 23:10:34 +01:00
|
|
|
LOG_INFO(Lib_Pad, "(STUBBED) called user_id = {} type = {} index = {}", user_id, type, index);
|
2024-02-23 21:57:57 +01:00
|
|
|
return 1; // dummy
|
2023-10-07 11:03:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int PS4_SYSV_ABI scePadReadState(int32_t handle, ScePadData* pData) {
|
2023-11-05 15:56:28 +01:00
|
|
|
auto* controller = Common::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;
|
2024-02-23 21:57:57 +01:00
|
|
|
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
|
2023-10-13 08:40:59 +02:00
|
|
|
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;
|
2024-02-23 21:57:57 +01:00
|
|
|
pData->connected = true; // isConnected; //TODO fix me proper
|
|
|
|
pData->connectedCount = 1; // connectedCount;
|
2023-10-13 08:40:59 +02:00
|
|
|
pData->deviceUniqueDataLen = 0;
|
|
|
|
|
2023-10-07 11:03:03 +02:00
|
|
|
return SCE_OK;
|
|
|
|
}
|
|
|
|
|
2024-03-14 13:18:16 +01:00
|
|
|
void padSymbolsRegister(Core::Loader::SymbolsResolver* sym) {
|
2023-10-07 11:03:03 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2024-03-14 13:18:16 +01:00
|
|
|
} // namespace OldLibraries::LibPad
|