fixes to the old pad code
This commit is contained in:
parent
9501bd77d4
commit
57c65cadb8
|
@ -1,126 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#include "common/logging/log.h"
|
|
||||||
#include "common/singleton.h"
|
|
||||||
#include "core/libraries/error_codes.h"
|
|
||||||
#include "core/libraries/libs.h"
|
|
||||||
#include "core/libraries/pad/pad.h"
|
|
||||||
#include "input/controller.h"
|
|
||||||
|
|
||||||
namespace Libraries::LibPad {
|
|
||||||
|
|
||||||
int PS4_SYSV_ABI scePadInit() {
|
|
||||||
LOG_WARNING(Lib_Pad, "(DUMMY) called");
|
|
||||||
return SCE_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int PS4_SYSV_ABI scePadOpen(Libraries::UserService::OrbisUserServiceUserId user_id, s32 type,
|
|
||||||
s32 index, const ScePadOpenParam* pParam) {
|
|
||||||
LOG_INFO(Lib_Pad, "(DUMMY) called user_id = {} type = {} index = {}", user_id, type, index);
|
|
||||||
return 1; // dummy
|
|
||||||
}
|
|
||||||
|
|
||||||
int PS4_SYSV_ABI scePadReadState(int32_t handle, ScePadData* pData) {
|
|
||||||
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 scePadRead(int handle, ScePadData* pData, int num) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadInformation* info) {
|
|
||||||
LOG_INFO(Lib_Pad, "called handle = {}", handle);
|
|
||||||
info->touchpadDensity = 1;
|
|
||||||
info->touchResolutionX = 1920;
|
|
||||||
info->touchResolutionY = 950;
|
|
||||||
info->stickDeadzoneL = 2;
|
|
||||||
info->stickDeadzoneR = 2;
|
|
||||||
info->connectionType = ORBIS_PAD_CONNECTION_TYPE_STANDARD;
|
|
||||||
info->count = 1;
|
|
||||||
info->connected = 1;
|
|
||||||
info->deviceClass = ORBIS_PAD_PORT_TYPE_STANDARD;
|
|
||||||
return SCE_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI scePadSetMotionSensorState(s32 handle, bool enable) {
|
|
||||||
LOG_INFO(Lib_Pad, "(DUMMY) called handle = {} enabled = {}", handle,
|
|
||||||
(enable ? "true" : "false"));
|
|
||||||
return SCE_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void padSymbolsRegister(Core::Loader::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);
|
|
||||||
LIB_FUNCTION("q1cHNfGycLI", "libScePad", 1, "libScePad", 1, 1, scePadRead);
|
|
||||||
|
|
||||||
LIB_FUNCTION("gjP9-KQzoUk", "libScePad", 1, "libScePad", 1, 1, scePadGetControllerInformation);
|
|
||||||
LIB_FUNCTION("clVvL4ZDntw", "libScePad", 1, "libScePad", 1, 1, scePadSetMotionSensorState);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Libraries::LibPad
|
|
|
@ -1,128 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "common/types.h"
|
|
||||||
#include "src/core/libraries/system/userservice.h"
|
|
||||||
|
|
||||||
namespace Core::Loader {
|
|
||||||
class SymbolsResolver;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Libraries::LibPad {
|
|
||||||
|
|
||||||
constexpr s8 ORBIS_PAD_PORT_TYPE_STANDARD = 0;
|
|
||||||
constexpr s8 ORBIS_PAD_PORT_TYPE_SPECIAL = 2;
|
|
||||||
|
|
||||||
constexpr s8 ORBIS_PAD_DEVICE_CLASS_PAD = 0;
|
|
||||||
constexpr s8 ORBIS_PAD_DEVICE_CLASS_GUITAR = 1;
|
|
||||||
constexpr s8 ORBIS_PAD_DEVICE_CLASS_DRUMS = 2;
|
|
||||||
|
|
||||||
constexpr s8 ORBIS_PAD_CONNECTION_TYPE_STANDARD = 0;
|
|
||||||
constexpr s8 ORBIS_PAD_CONNECTION_TYPE_REMOTE = 2;
|
|
||||||
|
|
||||||
enum ScePadButton : u32 {
|
|
||||||
L3 = 0x00000002,
|
|
||||||
R3 = 0x00000004,
|
|
||||||
OPTIONS = 0x00000008,
|
|
||||||
UP = 0x00000010,
|
|
||||||
RIGHT = 0x00000020,
|
|
||||||
DOWN = 0x00000040,
|
|
||||||
LEFT = 0x00000080,
|
|
||||||
L2 = 0x00000100,
|
|
||||||
R2 = 0x00000200,
|
|
||||||
L1 = 0x00000400,
|
|
||||||
R1 = 0x00000800,
|
|
||||||
TRIANGLE = 0x00001000,
|
|
||||||
CIRCLE = 0x00002000,
|
|
||||||
CROSS = 0x00004000,
|
|
||||||
SQUARE = 0x00008000,
|
|
||||||
TOUCH_PAD = 0x00100000,
|
|
||||||
INTERCEPTED = 0x80000000,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ScePadOpenParam {
|
|
||||||
u8 reserve[8];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ScePadAnalogStick {
|
|
||||||
u8 x;
|
|
||||||
u8 y;
|
|
||||||
};
|
|
||||||
struct ScePadAnalogButtons {
|
|
||||||
u8 l2;
|
|
||||||
u8 r2;
|
|
||||||
u8 padding[2];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SceFQuaternion {
|
|
||||||
float x, y, z, w;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SceFVector3 {
|
|
||||||
float x, y, z;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ScePadTouch {
|
|
||||||
u16 x;
|
|
||||||
u16 y;
|
|
||||||
u8 id;
|
|
||||||
u8 reserve[3];
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr int SCE_PAD_MAX_TOUCH_NUM = 2;
|
|
||||||
|
|
||||||
typedef struct ScePadTouchData {
|
|
||||||
u8 touchNum;
|
|
||||||
u8 reserve[3];
|
|
||||||
u32 reserve1;
|
|
||||||
ScePadTouch touch[SCE_PAD_MAX_TOUCH_NUM];
|
|
||||||
} ScePadTouchData;
|
|
||||||
|
|
||||||
struct ScePadExtensionUnitData {
|
|
||||||
u32 extensionUnitId;
|
|
||||||
u8 reserve[1];
|
|
||||||
u8 dataLength;
|
|
||||||
u8 data[10];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ScePadData {
|
|
||||||
u32 buttons;
|
|
||||||
ScePadAnalogStick leftStick;
|
|
||||||
ScePadAnalogStick rightStick;
|
|
||||||
ScePadAnalogButtons analogButtons;
|
|
||||||
SceFQuaternion orientation;
|
|
||||||
SceFVector3 acceleration;
|
|
||||||
SceFVector3 angularVelocity;
|
|
||||||
ScePadTouchData touchData;
|
|
||||||
bool connected;
|
|
||||||
u64 timestamp;
|
|
||||||
ScePadExtensionUnitData extensionUnitData;
|
|
||||||
uint8_t connectedCount;
|
|
||||||
uint8_t reserve[2];
|
|
||||||
uint8_t deviceUniqueDataLen;
|
|
||||||
uint8_t deviceUniqueData[12];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct OrbisPadInformation {
|
|
||||||
float touchpadDensity;
|
|
||||||
u16 touchResolutionX;
|
|
||||||
u16 touchResolutionY;
|
|
||||||
u8 stickDeadzoneL;
|
|
||||||
u8 stickDeadzoneR;
|
|
||||||
u8 connectionType;
|
|
||||||
u8 count;
|
|
||||||
s8 connected;
|
|
||||||
s8 deviceClass;
|
|
||||||
u8 unknown[8];
|
|
||||||
};
|
|
||||||
|
|
||||||
int PS4_SYSV_ABI scePadInit();
|
|
||||||
int PS4_SYSV_ABI scePadOpen(Libraries::UserService::OrbisUserServiceUserId userId, s32 type,
|
|
||||||
s32 index, const ScePadOpenParam* pParam);
|
|
||||||
int PS4_SYSV_ABI scePadReadState(int32_t handle, ScePadData* pData);
|
|
||||||
|
|
||||||
void padSymbolsRegister(Core::Loader::SymbolsResolver* sym);
|
|
||||||
|
|
||||||
}; // namespace Libraries::LibPad
|
|
|
@ -2,9 +2,11 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
// Generated By moduleGenerator
|
// Generated By moduleGenerator
|
||||||
|
#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"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
|
#include "input/controller.h"
|
||||||
#include "pad.h"
|
#include "pad.h"
|
||||||
|
|
||||||
namespace Libraries::Pad {
|
namespace Libraries::Pad {
|
||||||
|
@ -82,8 +84,17 @@ int PS4_SYSV_ABI scePadGetCapability() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerInformation* pInfo) {
|
int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerInformation* pInfo) {
|
||||||
LOG_ERROR(Lib_Pad, "(STUBBED) called");
|
LOG_INFO(Lib_Pad, "called handle = {}", handle);
|
||||||
return ORBIS_OK;
|
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() {
|
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) {
|
int PS4_SYSV_ABI scePadOpen(s32 userId, s32 type, s32 index, const OrbisPadOpenParam* pParam) {
|
||||||
LOG_ERROR(Lib_Pad, "(STUBBED) called");
|
LOG_INFO(Lib_Pad, "(DUMMY) called user_id = {} type = {} index = {}", userId, type, index);
|
||||||
return ORBIS_OK;
|
return 1; // dummy
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI scePadOpenExt() {
|
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) {
|
int PS4_SYSV_ABI scePadRead(s32 handle, OrbisPadData* pData, s32 num) {
|
||||||
LOG_ERROR(Lib_Pad, "(STUBBED) called");
|
int connected_count = 0;
|
||||||
return ORBIS_OK;
|
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() {
|
int PS4_SYSV_ABI scePadReadBlasterForTracker() {
|
||||||
|
@ -252,8 +303,30 @@ int PS4_SYSV_ABI scePadReadHistory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI scePadReadState(s32 handle, OrbisPadData* pData) {
|
int PS4_SYSV_ABI scePadReadState(s32 handle, OrbisPadData* pData) {
|
||||||
LOG_ERROR(Lib_Pad, "(STUBBED) called");
|
auto* controller = Common::Singleton<Input::GameController>::Instance();
|
||||||
return ORBIS_OK;
|
|
||||||
|
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() {
|
int PS4_SYSV_ABI scePadReadStateExt() {
|
||||||
|
|
|
@ -14,6 +14,9 @@ namespace Libraries::Pad {
|
||||||
constexpr int ORBIS_PAD_MAX_TOUCH_NUM = 2;
|
constexpr int ORBIS_PAD_MAX_TOUCH_NUM = 2;
|
||||||
constexpr int ORBIS_PAD_MAX_DEVICE_UNIQUE_DATA_SIZE = 12;
|
constexpr int ORBIS_PAD_MAX_DEVICE_UNIQUE_DATA_SIZE = 12;
|
||||||
|
|
||||||
|
constexpr int ORBIS_PAD_PORT_TYPE_STANDARD = 0;
|
||||||
|
constexpr int ORBIS_PAD_PORT_TYPE_SPECIAL = 2;
|
||||||
|
|
||||||
enum OrbisPadDeviceClass {
|
enum OrbisPadDeviceClass {
|
||||||
ORBIS_PAD_DEVICE_CLASS_INVALID = -1,
|
ORBIS_PAD_DEVICE_CLASS_INVALID = -1,
|
||||||
ORBIS_PAD_DEVICE_CLASS_STANDARD = 0,
|
ORBIS_PAD_DEVICE_CLASS_STANDARD = 0,
|
||||||
|
@ -189,8 +192,8 @@ struct OrbisPadData {
|
||||||
struct OrbisPadTouchPadInformation {
|
struct OrbisPadTouchPadInformation {
|
||||||
float pixelDensity;
|
float pixelDensity;
|
||||||
struct {
|
struct {
|
||||||
u8 x;
|
u16 x;
|
||||||
u8 y;
|
u16 y;
|
||||||
} resolution;
|
} resolution;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue