mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-24 12:25:00 +00:00
refactored libpad to new package
This commit is contained in:
parent
93e75481c7
commit
c488b7132d
5 changed files with 8 additions and 8 deletions
55
src/core/hle/libraries/libpad/pad.cpp
Normal file
55
src/core/hle/libraries/libpad/pad.cpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
#include "pad.h"
|
||||
|
||||
#include <core/PS4/HLE/ErrorCodes.h>
|
||||
#include <core/PS4/HLE/Libs.h>
|
||||
|
||||
#include "Emulator/Util/singleton.h"
|
||||
#include "Emulator/Host/controller.h"
|
||||
#include <debug.h>
|
||||
#include <Util/log.h>
|
||||
|
||||
namespace Core::Libraries::LibPad {
|
||||
|
||||
constexpr bool log_file_pad = true; // disable it to disable logging
|
||||
|
||||
int PS4_SYSV_ABI scePadInit() { return SCE_OK; }
|
||||
|
||||
int PS4_SYSV_ABI scePadOpen(Emulator::HLE::Libraries::LibUserService::SceUserServiceUserId userId, s32 type, s32 index,
|
||||
const ScePadOpenParam* pParam) {
|
||||
return 1; // dummy
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI scePadReadState(int32_t handle, ScePadData* pData) {
|
||||
auto* controller = singleton<Emulator::Host::Controller::GameController>::instance();
|
||||
|
||||
int connectedCount = 0;
|
||||
bool isConnected = false;
|
||||
Emulator::Host::Controller::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;
|
||||
}
|
||||
|
||||
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
|
98
src/core/hle/libraries/libpad/pad.h
Normal file
98
src/core/hle/libraries/libpad/pad.h
Normal file
|
@ -0,0 +1,98 @@
|
|||
#pragma once
|
||||
#include <Emulator/HLE/Libraries/LibUserService/user_service.h>
|
||||
#include <types.h>
|
||||
|
||||
#include "core/PS4/Loader/SymbolsResolver.h"
|
||||
|
||||
namespace Core::Libraries::LibPad {
|
||||
|
||||
typedef enum : u32 {
|
||||
SCE_PAD_BUTTON_L3 = 0x00000002,
|
||||
SCE_PAD_BUTTON_R3 = 0x00000004,
|
||||
SCE_PAD_BUTTON_OPTIONS = 0x00000008,
|
||||
SCE_PAD_BUTTON_UP = 0x00000010,
|
||||
SCE_PAD_BUTTON_RIGHT = 0x00000020,
|
||||
SCE_PAD_BUTTON_DOWN = 0x00000040,
|
||||
SCE_PAD_BUTTON_LEFT = 0x00000080,
|
||||
SCE_PAD_BUTTON_L2 = 0x00000100,
|
||||
SCE_PAD_BUTTON_R2 = 0x00000200,
|
||||
SCE_PAD_BUTTON_L1 = 0x00000400,
|
||||
SCE_PAD_BUTTON_R1 = 0x00000800,
|
||||
SCE_PAD_BUTTON_TRIANGLE = 0x00001000,
|
||||
SCE_PAD_BUTTON_CIRCLE = 0x00002000,
|
||||
SCE_PAD_BUTTON_CROSS = 0x00004000,
|
||||
SCE_PAD_BUTTON_SQUARE = 0x00008000,
|
||||
SCE_PAD_BUTTON_TOUCH_PAD = 0x00100000,
|
||||
SCE_PAD_BUTTON_INTERCEPTED = 0x80000000,
|
||||
} ScePadButton;
|
||||
|
||||
struct ScePadOpenParam {
|
||||
u08 reserve[8];
|
||||
};
|
||||
|
||||
struct ScePadAnalogStick {
|
||||
u08 x;
|
||||
u08 y;
|
||||
};
|
||||
struct ScePadAnalogButtons {
|
||||
u08 l2;
|
||||
u08 r2;
|
||||
u08 padding[2];
|
||||
};
|
||||
|
||||
struct SceFQuaternion {
|
||||
float x, y, z, w;
|
||||
};
|
||||
|
||||
struct SceFVector3 {
|
||||
float x, y, z;
|
||||
};
|
||||
|
||||
struct ScePadTouch {
|
||||
u16 x;
|
||||
u16 y;
|
||||
u08 id;
|
||||
u08 reserve[3];
|
||||
};
|
||||
|
||||
constexpr int SCE_PAD_MAX_TOUCH_NUM = 2;
|
||||
|
||||
typedef struct ScePadTouchData {
|
||||
u08 touchNum;
|
||||
u08 reserve[3];
|
||||
u32 reserve1;
|
||||
ScePadTouch touch[SCE_PAD_MAX_TOUCH_NUM];
|
||||
} ScePadTouchData;
|
||||
|
||||
struct ScePadExtensionUnitData {
|
||||
u32 extensionUnitId;
|
||||
u08 reserve[1];
|
||||
u08 dataLength;
|
||||
u08 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];
|
||||
};
|
||||
// hle functions
|
||||
int PS4_SYSV_ABI scePadInit();
|
||||
int PS4_SYSV_ABI scePadOpen(Emulator::HLE::Libraries::LibUserService::SceUserServiceUserId userId, s32 type, s32 index,
|
||||
const ScePadOpenParam* pParam);
|
||||
int PS4_SYSV_ABI scePadReadState(int32_t handle, ScePadData* pData);
|
||||
|
||||
void libPad_Register(SymbolsResolver* sym);
|
||||
}; // namespace Emulator::HLE::Libraries::LibPad
|
Loading…
Add table
Add a link
Reference in a new issue