Merge pull request #200 from shadps4-emu/padrewrite

scePad library rewrite
This commit is contained in:
georgemoralis 2024-06-22 18:04:15 +03:00 committed by GitHub
commit ce31fad222
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 1157 additions and 176 deletions

View File

@ -28,15 +28,13 @@ void MntPoints::UnmountAll() {
std::string MntPoints::GetHostDirectory(const std::string& guest_directory) { std::string MntPoints::GetHostDirectory(const std::string& guest_directory) {
std::scoped_lock lock{m_mutex}; std::scoped_lock lock{m_mutex};
for (auto& pair : m_mnt_pairs) { for (auto& pair : m_mnt_pairs) {
if (pair.guest_path.starts_with(guest_directory)) { // horrible code but it works :D
return pair.host_path + guest_directory; int find = guest_directory.find(pair.guest_path);
} if (find == 0) {
} std::string npath =
// hack for relative path , get app0 and assuming it goes from there guest_directory.substr(pair.guest_path.size(), guest_directory.size() - 1);
for (auto& pair : m_mnt_pairs) {
if (pair.guest_path.starts_with("/app0")) {
std::replace(pair.host_path.begin(), pair.host_path.end(), '\\', '/'); std::replace(pair.host_path.begin(), pair.host_path.end(), '\\', '/');
return pair.host_path + guest_directory; return pair.host_path + npath;
} }
} }
return ""; return "";

View File

@ -32,13 +32,18 @@ private:
std::mutex m_mutex; std::mutex m_mutex;
}; };
struct DirEntry {
std::string name;
bool isFile;
};
struct File { struct File {
std::atomic_bool is_opened{}; std::atomic_bool is_opened{};
std::atomic_bool is_directory{}; std::atomic_bool is_directory{};
std::string m_host_name; std::string m_host_name;
std::string m_guest_name; std::string m_guest_name;
Common::FS::IOFile f; Common::FS::IOFile f;
// std::vector<Common::FS::DirEntry> dirents; std::vector<DirEntry> dirents;
u32 dirents_index; u32 dirents_index;
std::mutex m_mutex; std::mutex m_mutex;
}; };

View File

@ -11,6 +11,27 @@
namespace Libraries::Kernel { namespace Libraries::Kernel {
std::vector<Core::FileSys::DirEntry> GetDirectoryEntries(const std::string& path) {
std::string curpath = path;
if (!curpath.ends_with("/")) {
curpath = std::string(curpath + "/");
}
std::vector<Core::FileSys::DirEntry> files;
for (const auto& entry : std::filesystem::directory_iterator(curpath)) {
Core::FileSys::DirEntry e = {};
if (std::filesystem::is_directory(entry.path().string())) {
e.name = entry.path().filename().string();
e.isFile = false;
} else {
e.name = entry.path().filename().string();
e.isFile = true;
}
files.push_back(e);
}
return files;
}
int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) { int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) {
LOG_INFO(Kernel_Fs, "path = {} flags = {:#x} mode = {}", path, flags, mode); LOG_INFO(Kernel_Fs, "path = {} flags = {:#x} mode = {}", path, flags, mode);
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance(); auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
@ -31,15 +52,32 @@ int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) {
bool direct = (flags & ORBIS_KERNEL_O_DIRECT) != 0; bool direct = (flags & ORBIS_KERNEL_O_DIRECT) != 0;
bool directory = (flags & ORBIS_KERNEL_O_DIRECTORY) != 0; bool directory = (flags & ORBIS_KERNEL_O_DIRECTORY) != 0;
if (std::string_view{path} == "/dev/console" || std::string_view{path} == "/dev/deci_tty6") { if (std::string_view{path} == "/dev/console") {
return ORBIS_OK; return 2000;
}
if (std::string_view{path} == "/dev/deci_tty6") {
return 2001;
}
if (std::string_view{path} == "/dev/stdout") {
return 2002;
} }
if (directory) {
LOG_ERROR(Kernel_Fs, "called on directory");
} else {
u32 handle = h->CreateHandle(); u32 handle = h->CreateHandle();
auto* file = h->GetFile(handle); auto* file = h->GetFile(handle);
if (directory) {
file->is_directory = true;
file->m_guest_name = path;
file->m_host_name = mnt->GetHostDirectory(file->m_guest_name);
if (!std::filesystem::is_directory(file->m_host_name)) { // directory doesn't exist
UNREACHABLE(); // not supported yet
} else {
if (create) {
return handle; // dir already exists
} else {
file->dirents = GetDirectoryEntries(file->m_host_name);
file->dirents_index = 0;
}
}
} else {
file->m_guest_name = path; file->m_guest_name = path;
file->m_host_name = mnt->GetHostFile(file->m_guest_name); file->m_host_name = mnt->GetHostFile(file->m_guest_name);
if (read) { if (read) {
@ -61,11 +99,10 @@ int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) {
h->DeleteHandle(handle); h->DeleteHandle(handle);
return SCE_KERNEL_ERROR_EACCES; return SCE_KERNEL_ERROR_EACCES;
} }
}
file->is_opened = true; file->is_opened = true;
return handle; return handle;
} }
return -1; // dummy
}
int PS4_SYSV_ABI posix_open(const char* path, int flags, /* SceKernelMode*/ u16 mode) { int PS4_SYSV_ABI posix_open(const char* path, int flags, /* SceKernelMode*/ u16 mode) {
LOG_INFO(Kernel_Fs, "posix open redirect to sceKernelOpen\n"); LOG_INFO(Kernel_Fs, "posix open redirect to sceKernelOpen\n");
@ -310,6 +347,43 @@ s32 PS4_SYSV_ABI sceKernelFsync(int fd) {
return ORBIS_OK; return ORBIS_OK;
} }
int GetDents(int fd, char* buf, int nbytes, s64* basep) {
// TODO error codes
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
auto* file = h->GetFile(fd);
if (file->dirents_index == file->dirents.size()) {
return 0;
}
const auto& entry = file->dirents.at(file->dirents_index++);
auto str = entry.name;
auto str_size = str.size() - 1;
static int fileno = 1000; // random
OrbisKernelDirent* sce_ent = (OrbisKernelDirent*)buf;
sce_ent->d_fileno = fileno++; // TODO this should be unique but atm it changes maybe switch to a
// hash or something?
sce_ent->d_reclen = sizeof(OrbisKernelDirent);
sce_ent->d_type = (entry.isFile ? 8 : 4);
sce_ent->d_namlen = str_size;
strncpy(sce_ent->d_name, str.c_str(), ORBIS_MAX_PATH);
sce_ent->d_name[ORBIS_MAX_PATH] = '\0';
if (basep != nullptr) {
*basep = file->dirents_index;
}
return sizeof(OrbisKernelDirent);
}
int PS4_SYSV_ABI sceKernelGetdents(int fd, char* buf, int nbytes) {
return GetDents(fd, buf, nbytes, nullptr);
}
int PS4_SYSV_ABI sceKernelGetdirentries(int fd, char* buf, int nbytes, s64* basep) {
return GetDents(fd, buf, nbytes, basep);
}
void fileSystemSymbolsRegister(Core::Loader::SymbolsResolver* sym) { void fileSystemSymbolsRegister(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("1G3lF1Gg1k8", "libkernel", 1, "libkernel", 1, 1, sceKernelOpen); LIB_FUNCTION("1G3lF1Gg1k8", "libkernel", 1, "libkernel", 1, 1, sceKernelOpen);
LIB_FUNCTION("wuCroIGjt2g", "libScePosix", 1, "libkernel", 1, 1, posix_open); LIB_FUNCTION("wuCroIGjt2g", "libScePosix", 1, "libkernel", 1, 1, posix_open);
@ -333,6 +407,8 @@ void fileSystemSymbolsRegister(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("+r3rMFwItV4", "libkernel", 1, "libkernel", 1, 1, sceKernelPread); LIB_FUNCTION("+r3rMFwItV4", "libkernel", 1, "libkernel", 1, 1, sceKernelPread);
LIB_FUNCTION("uWyW3v98sU4", "libkernel", 1, "libkernel", 1, 1, sceKernelCheckReachability); LIB_FUNCTION("uWyW3v98sU4", "libkernel", 1, "libkernel", 1, 1, sceKernelCheckReachability);
LIB_FUNCTION("fTx66l5iWIA", "libkernel", 1, "libkernel", 1, 1, sceKernelFsync); LIB_FUNCTION("fTx66l5iWIA", "libkernel", 1, "libkernel", 1, 1, sceKernelFsync);
LIB_FUNCTION("j2AIqSqJP0w", "libkernel", 1, "libkernel", 1, 1, sceKernelGetdents);
LIB_FUNCTION("taRWhTJFTgE", "libkernel", 1, "libkernel", 1, 1, sceKernelGetdirentries);
// openOrbis (to check if it is valid out of OpenOrbis // openOrbis (to check if it is valid out of OpenOrbis
LIB_FUNCTION("6c3rCVE-fTU", "libkernel", 1, "libkernel", 1, 1, LIB_FUNCTION("6c3rCVE-fTU", "libkernel", 1, "libkernel", 1, 1,

View File

@ -12,6 +12,8 @@ class SymbolsResolver;
namespace Libraries::Kernel { namespace Libraries::Kernel {
constexpr int ORBIS_MAX_PATH = 255;
struct SceKernelIovec { struct SceKernelIovec {
void* iov_base; void* iov_base;
std::size_t iov_len; std::size_t iov_len;
@ -39,6 +41,14 @@ struct OrbisKernelStat {
unsigned int : (8 / 2) * (16 - static_cast<int>(sizeof(OrbisKernelTimespec))); unsigned int : (8 / 2) * (16 - static_cast<int>(sizeof(OrbisKernelTimespec)));
}; };
struct OrbisKernelDirent {
u32 d_fileno; /* file number of entry */
u16 d_reclen; /* length of this record */
u8 d_type; /* file type, see below */
u8 d_namlen; /* length of string in d_name */
char d_name[ORBIS_MAX_PATH + 1]; /* name must be no longer than this */
};
// flags for Open // flags for Open
constexpr int ORBIS_KERNEL_O_RDONLY = 0x0000; constexpr int ORBIS_KERNEL_O_RDONLY = 0x0000;
constexpr int ORBIS_KERNEL_O_WRONLY = 0x0001; constexpr int ORBIS_KERNEL_O_WRONLY = 0x0001;

View File

@ -995,6 +995,10 @@ void PS4_SYSV_ABI scePthreadYield() {
sched_yield(); sched_yield();
} }
void PS4_SYSV_ABI posix_pthread_yield() {
sched_yield();
}
int PS4_SYSV_ABI scePthreadAttrGetstack(ScePthreadAttr* attr, void** addr, size_t* size) { int PS4_SYSV_ABI scePthreadAttrGetstack(ScePthreadAttr* attr, void** addr, size_t* size) {
int result = pthread_attr_getstack(&(*attr)->pth_attr, addr, size); int result = pthread_attr_getstack(&(*attr)->pth_attr, addr, size);
@ -1308,6 +1312,8 @@ void pthreadSymbolsRegister(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("bt3CTBKmGyI", "libkernel", 1, "libkernel", 1, 1, scePthreadSetaffinity); LIB_FUNCTION("bt3CTBKmGyI", "libkernel", 1, "libkernel", 1, 1, scePthreadSetaffinity);
LIB_FUNCTION("6UgtwV+0zb4", "libkernel", 1, "libkernel", 1, 1, scePthreadCreate); LIB_FUNCTION("6UgtwV+0zb4", "libkernel", 1, "libkernel", 1, 1, scePthreadCreate);
LIB_FUNCTION("T72hz6ffq08", "libkernel", 1, "libkernel", 1, 1, scePthreadYield); LIB_FUNCTION("T72hz6ffq08", "libkernel", 1, "libkernel", 1, 1, scePthreadYield);
LIB_FUNCTION("B5GmVDKwpn0", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_yield);
LIB_FUNCTION("-quPa4SEJUw", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrGetstack); LIB_FUNCTION("-quPa4SEJUw", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrGetstack);
LIB_FUNCTION("Ru36fiTtJzA", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrGetstackaddr); LIB_FUNCTION("Ru36fiTtJzA", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrGetstackaddr);
LIB_FUNCTION("-fA+7ZlGDQs", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrGetstacksize); LIB_FUNCTION("-fA+7ZlGDQs", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrGetstacksize);

View File

@ -40,7 +40,6 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) {
Libraries::Kernel::LibKernel_Register(sym); Libraries::Kernel::LibKernel_Register(sym);
Libraries::VideoOut::RegisterLib(sym); Libraries::VideoOut::RegisterLib(sym);
Libraries::GnmDriver::RegisterlibSceGnmDriver(sym); Libraries::GnmDriver::RegisterlibSceGnmDriver(sym);
Libraries::LibPad::padSymbolsRegister(sym);
if (!Config::isLleLibc()) { if (!Config::isLleLibc()) {
Libraries::LibC::libcSymbolsRegister(sym); Libraries::LibC::libcSymbolsRegister(sym);
} }
@ -71,6 +70,7 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) {
Libraries::PngDec::RegisterlibScePngDec(sym); Libraries::PngDec::RegisterlibScePngDec(sym);
Libraries::PlayGo::RegisterlibScePlayGo(sym); Libraries::PlayGo::RegisterlibScePlayGo(sym);
Libraries::Usbd::RegisterlibSceUsbd(sym); Libraries::Usbd::RegisterlibSceUsbd(sym);
Libraries::Pad::RegisterlibScePad(sym);
} }
} // namespace Libraries } // namespace Libraries

View File

@ -1,54 +1,243 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
// Generated By moduleGenerator
#include <common/singleton.h>
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/singleton.h"
#include "core/libraries/error_codes.h" #include "core/libraries/error_codes.h"
#include "core/libraries/libs.h" #include "core/libraries/libs.h"
#include "core/libraries/pad/pad.h"
#include "input/controller.h" #include "input/controller.h"
#include "pad.h"
namespace Libraries::LibPad { namespace Libraries::Pad {
int PS4_SYSV_ABI scePadInit() { int PS4_SYSV_ABI scePadClose(s32 handle) {
LOG_WARNING(Lib_Pad, "(DUMMY) called"); LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadConnectPort() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadDeviceClassGetExtendedInformation(
s32 handle, OrbisPadDeviceClassExtendedInformation* pExtInfo) {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadDeviceClassParseData(s32 handle, const OrbisPadData* pData,
OrbisPadDeviceClassData* pDeviceClassData) {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadDeviceOpen() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadDisableVibration() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadDisconnectDevice() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadDisconnectPort() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadEnableAutoDetect() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadEnableExtensionPort() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadEnableSpecificDeviceClass() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadEnableUsbConnection() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadGetBluetoothAddress() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadGetCapability() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerInformation* pInfo) {
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; return SCE_OK;
} }
int PS4_SYSV_ABI scePadOpen(Libraries::UserService::OrbisUserServiceUserId user_id, s32 type, int PS4_SYSV_ABI scePadGetDataInternal() {
s32 index, const ScePadOpenParam* pParam) { LOG_ERROR(Lib_Pad, "(STUBBED) called");
LOG_INFO(Lib_Pad, "(DUMMY) called user_id = {} type = {} index = {}", user_id, type, index); return ORBIS_OK;
}
int PS4_SYSV_ABI scePadGetDeviceId() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadGetDeviceInfo() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadGetExtControllerInformation() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadGetExtensionUnitInfo() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadGetFeatureReport() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadGetHandle(s32 userId, s32 type, s32 index) {
LOG_DEBUG(Lib_Pad, "(DUMMY) called");
return 1;
}
int PS4_SYSV_ABI scePadGetIdleCount() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadGetInfo() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadGetInfoByPortType() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadGetLicenseControllerInformation() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadGetMotionSensorPosition() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadGetMotionTimerUnit() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadGetSphereRadius() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadGetVersionInfo() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadInit() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadIsBlasterConnected() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadIsDS4Connected() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadIsLightBarBaseBrightnessControllable() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadIsMoveConnected() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadIsMoveReproductionModel() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadIsValidHandle() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadMbusInit() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadMbusTerm() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadOpen(s32 userId, s32 type, s32 index, const OrbisPadOpenParam* pParam) {
LOG_INFO(Lib_Pad, "(DUMMY) called user_id = {} type = {} index = {}", userId, type, index);
return 1; // dummy return 1; // dummy
} }
int PS4_SYSV_ABI scePadReadState(int32_t handle, ScePadData* pData) { int PS4_SYSV_ABI scePadOpenExt() {
auto* controller = Common::Singleton<Input::GameController>::Instance(); LOG_ERROR(Lib_Pad, "(STUBBED) called");
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 scePadRead(int handle, ScePadData* pData, int num) { int PS4_SYSV_ABI scePadOpenExt2() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadOutputReport() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadRead(s32 handle, OrbisPadData* pData, s32 num) {
int connected_count = 0; int connected_count = 0;
bool connected = false; bool connected = false;
Input::State states[64]; Input::State states[64];
@ -61,12 +250,12 @@ int PS4_SYSV_ABI scePadRead(int handle, ScePadData* pData, int num) {
for (int i = 0; i < ret_num; i++) { for (int i = 0; i < ret_num; i++) {
pData[i].buttons = states[i].buttonsState; pData[i].buttons = states[i].buttonsState;
pData[i].leftStick.x = 128; // dummy pData[i].leftStick.x = states[i].axes[static_cast<int>(Input::Axis::LeftX)];
pData[i].leftStick.y = 128; // dummy pData[i].leftStick.y = states[i].axes[static_cast<int>(Input::Axis::LeftY)];
pData[i].rightStick.x = 0; // dummy pData[i].rightStick.x = states[i].axes[static_cast<int>(Input::Axis::RightX)];
pData[i].rightStick.y = 0; // dummy pData[i].rightStick.y = states[i].axes[static_cast<int>(Input::Axis::RightY)];
pData[i].analogButtons.l2 = 0; // dummy pData[i].analogButtons.l2 = states[i].axes[static_cast<int>(Input::Axis::TriggerLeft)];
pData[i].analogButtons.r2 = 0; // dummy pData[i].analogButtons.r2 = states[i].axes[static_cast<int>(Input::Axis::TriggerRight)];
pData[i].orientation.x = 0.0f; pData[i].orientation.x = 0.0f;
pData[i].orientation.y = 0.0f; pData[i].orientation.y = 0.0f;
pData[i].orientation.z = 0.0f; pData[i].orientation.z = 0.0f;
@ -93,34 +282,372 @@ int PS4_SYSV_ABI scePadRead(int handle, ScePadData* pData, int num) {
return ret_num; return ret_num;
} }
s32 PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadInformation* info) { int PS4_SYSV_ABI scePadReadBlasterForTracker() {
LOG_INFO(Lib_Pad, "called handle = {}", handle); LOG_ERROR(Lib_Pad, "(STUBBED) called");
info->touchpadDensity = 1; return ORBIS_OK;
info->touchResolutionX = 1920; }
info->touchResolutionY = 950;
info->stickDeadzoneL = 2; int PS4_SYSV_ABI scePadReadExt() {
info->stickDeadzoneR = 2; LOG_ERROR(Lib_Pad, "(STUBBED) called");
info->connectionType = ORBIS_PAD_CONNECTION_TYPE_STANDARD; return ORBIS_OK;
info->count = 1; }
info->connected = 1;
info->deviceClass = ORBIS_PAD_PORT_TYPE_STANDARD; int PS4_SYSV_ABI scePadReadForTracker() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadReadHistory() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadReadState(s32 handle, OrbisPadData* 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 = state.axes[static_cast<int>(Input::Axis::LeftX)];
pData->leftStick.y = state.axes[static_cast<int>(Input::Axis::LeftY)];
pData->rightStick.x = state.axes[static_cast<int>(Input::Axis::RightX)];
pData->rightStick.y = state.axes[static_cast<int>(Input::Axis::RightY)];
pData->analogButtons.l2 = state.axes[static_cast<int>(Input::Axis::TriggerLeft)];
pData->analogButtons.r2 = state.axes[static_cast<int>(Input::Axis::TriggerRight)];
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; return SCE_OK;
} }
s32 PS4_SYSV_ABI scePadSetMotionSensorState(s32 handle, bool enable) { int PS4_SYSV_ABI scePadReadStateExt() {
LOG_INFO(Lib_Pad, "(DUMMY) called handle = {} enabled = {}", handle, LOG_ERROR(Lib_Pad, "(STUBBED) called");
(enable ? "true" : "false")); return ORBIS_OK;
return SCE_OK;
} }
void padSymbolsRegister(Core::Loader::SymbolsResolver* sym) { int PS4_SYSV_ABI scePadResetLightBar(s32 handle) {
LIB_FUNCTION("hv1luiJrqQM", "libScePad", 1, "libScePad", 1, 1, scePadInit); LOG_ERROR(Lib_Pad, "(STUBBED) called");
LIB_FUNCTION("xk0AcarP3V4", "libScePad", 1, "libScePad", 1, 1, scePadOpen); return ORBIS_OK;
LIB_FUNCTION("YndgXqQVV7c", "libScePad", 1, "libScePad", 1, 1, scePadReadState); }
LIB_FUNCTION("q1cHNfGycLI", "libScePad", 1, "libScePad", 1, 1, scePadRead);
int PS4_SYSV_ABI scePadResetLightBarAll() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadResetLightBarAllByPortType() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadResetOrientation(s32 handle) {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadResetOrientationForTracker() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetAngularVelocityDeadbandState(s32 handle, bool bEnable) {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetAutoPowerOffCount() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetButtonRemappingInfo() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetConnection() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetExtensionReport() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetFeatureReport() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetForceIntercepted() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetLightBar(s32 handle, const OrbisPadLightBarParam* pParam) {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetLightBarBaseBrightness() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetLightBarBlinking() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetLightBarForTracker() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetLoginUserNumber() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetMotionSensorState(s32 handle, bool bEnable) {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetProcessFocus() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetProcessPrivilege() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetProcessPrivilegeOfButtonRemapping() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetShareButtonMaskForRemotePlay() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetTiltCorrectionState(s32 handle, bool bEnable) {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetUserColor() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetVibration(s32 handle, const OrbisPadVibrationParam* pParam) {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetVibrationForce() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSetVrTrackingMode() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadShareOutputData() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadStartRecording() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadStopRecording() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadSwitchConnection() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadVertualDeviceAddDevice() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadVirtualDeviceAddDevice() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadVirtualDeviceDeleteDevice() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadVirtualDeviceDisableButtonRemapping() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadVirtualDeviceGetRemoteSetting() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI scePadVirtualDeviceInsertData() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI Func_28B998C7D8A3DA1D() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI Func_298D21481F94C9FA() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI Func_51E514BCD3A05CA5() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI Func_89C9237E393DA243() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI Func_EF103E845B6F0420() {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
return ORBIS_OK;
}
void RegisterlibScePad(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("6ncge5+l5Qs", "libScePad", 1, "libScePad", 1, 1, scePadClose);
LIB_FUNCTION("kazv1NzSB8c", "libScePad", 1, "libScePad", 1, 1, scePadConnectPort);
LIB_FUNCTION("AcslpN1jHR8", "libScePad", 1, "libScePad", 1, 1,
scePadDeviceClassGetExtendedInformation);
LIB_FUNCTION("IHPqcbc0zCA", "libScePad", 1, "libScePad", 1, 1, scePadDeviceClassParseData);
LIB_FUNCTION("d7bXuEBycDI", "libScePad", 1, "libScePad", 1, 1, scePadDeviceOpen);
LIB_FUNCTION("0aziJjRZxqQ", "libScePad", 1, "libScePad", 1, 1, scePadDisableVibration);
LIB_FUNCTION("pnZXireDoeI", "libScePad", 1, "libScePad", 1, 1, scePadDisconnectDevice);
LIB_FUNCTION("9ez71nWSvD0", "libScePad", 1, "libScePad", 1, 1, scePadDisconnectPort);
LIB_FUNCTION("77ooWxGOIVs", "libScePad", 1, "libScePad", 1, 1, scePadEnableAutoDetect);
LIB_FUNCTION("+cE4Jx431wc", "libScePad", 1, "libScePad", 1, 1, scePadEnableExtensionPort);
LIB_FUNCTION("E1KEw5XMGQQ", "libScePad", 1, "libScePad", 1, 1, scePadEnableSpecificDeviceClass);
LIB_FUNCTION("DD-KiRLBqkQ", "libScePad", 1, "libScePad", 1, 1, scePadEnableUsbConnection);
LIB_FUNCTION("Q66U8FdrMaw", "libScePad", 1, "libScePad", 1, 1, scePadGetBluetoothAddress);
LIB_FUNCTION("qtasqbvwgV4", "libScePad", 1, "libScePad", 1, 1, scePadGetCapability);
LIB_FUNCTION("gjP9-KQzoUk", "libScePad", 1, "libScePad", 1, 1, scePadGetControllerInformation); LIB_FUNCTION("gjP9-KQzoUk", "libScePad", 1, "libScePad", 1, 1, scePadGetControllerInformation);
LIB_FUNCTION("Uq6LgTJEmQs", "libScePad", 1, "libScePad", 1, 1, scePadGetDataInternal);
LIB_FUNCTION("hDgisSGkOgw", "libScePad", 1, "libScePad", 1, 1, scePadGetDeviceId);
LIB_FUNCTION("4rS5zG7RFaM", "libScePad", 1, "libScePad", 1, 1, scePadGetDeviceInfo);
LIB_FUNCTION("hGbf2QTBmqc", "libScePad", 1, "libScePad", 1, 1,
scePadGetExtControllerInformation);
LIB_FUNCTION("1DmZjZAuzEM", "libScePad", 1, "libScePad", 1, 1, scePadGetExtensionUnitInfo);
LIB_FUNCTION("PZSoY8j0Pko", "libScePad", 1, "libScePad", 1, 1, scePadGetFeatureReport);
LIB_FUNCTION("u1GRHp+oWoY", "libScePad", 1, "libScePad", 1, 1, scePadGetHandle);
LIB_FUNCTION("kiA9bZhbnAg", "libScePad", 1, "libScePad", 1, 1, scePadGetIdleCount);
LIB_FUNCTION("1Odcw19nADw", "libScePad", 1, "libScePad", 1, 1, scePadGetInfo);
LIB_FUNCTION("4x5Im8pr0-4", "libScePad", 1, "libScePad", 1, 1, scePadGetInfoByPortType);
LIB_FUNCTION("vegw8qax5MI", "libScePad", 1, "libScePad", 1, 1,
scePadGetLicenseControllerInformation);
LIB_FUNCTION("WPIB7zBWxVE", "libScePad", 1, "libScePad", 1, 1, scePadGetMotionSensorPosition);
LIB_FUNCTION("k4+nDV9vbT0", "libScePad", 1, "libScePad", 1, 1, scePadGetMotionTimerUnit);
LIB_FUNCTION("do-JDWX+zRs", "libScePad", 1, "libScePad", 1, 1, scePadGetSphereRadius);
LIB_FUNCTION("QuOaoOcSOw0", "libScePad", 1, "libScePad", 1, 1, scePadGetVersionInfo);
LIB_FUNCTION("hv1luiJrqQM", "libScePad", 1, "libScePad", 1, 1, scePadInit);
LIB_FUNCTION("bi0WNvZ1nug", "libScePad", 1, "libScePad", 1, 1, scePadIsBlasterConnected);
LIB_FUNCTION("mEC+xJKyIjQ", "libScePad", 1, "libScePad", 1, 1, scePadIsDS4Connected);
LIB_FUNCTION("d2Qk-i8wGak", "libScePad", 1, "libScePad", 1, 1,
scePadIsLightBarBaseBrightnessControllable);
LIB_FUNCTION("4y9RNPSBsqg", "libScePad", 1, "libScePad", 1, 1, scePadIsMoveConnected);
LIB_FUNCTION("9e56uLgk5y0", "libScePad", 1, "libScePad", 1, 1, scePadIsMoveReproductionModel);
LIB_FUNCTION("pFTi-yOrVeQ", "libScePad", 1, "libScePad", 1, 1, scePadIsValidHandle);
LIB_FUNCTION("CfwUlQtCFi4", "libScePad", 1, "libScePad", 1, 1, scePadMbusInit);
LIB_FUNCTION("s7CvzS+9ZIs", "libScePad", 1, "libScePad", 1, 1, scePadMbusTerm);
LIB_FUNCTION("xk0AcarP3V4", "libScePad", 1, "libScePad", 1, 1, scePadOpen);
LIB_FUNCTION("WFIiSfXGUq8", "libScePad", 1, "libScePad", 1, 1, scePadOpenExt);
LIB_FUNCTION("71E9e6n+2R8", "libScePad", 1, "libScePad", 1, 1, scePadOpenExt2);
LIB_FUNCTION("DrUu8cPrje8", "libScePad", 1, "libScePad", 1, 1, scePadOutputReport);
LIB_FUNCTION("q1cHNfGycLI", "libScePad", 1, "libScePad", 1, 1, scePadRead);
LIB_FUNCTION("fm1r2vv5+OU", "libScePad", 1, "libScePad", 1, 1, scePadReadBlasterForTracker);
LIB_FUNCTION("QjwkT2Ycmew", "libScePad", 1, "libScePad", 1, 1, scePadReadExt);
LIB_FUNCTION("2NhkFTRnXHk", "libScePad", 1, "libScePad", 1, 1, scePadReadForTracker);
LIB_FUNCTION("3u4M8ck9vJM", "libScePad", 1, "libScePad", 1, 1, scePadReadHistory);
LIB_FUNCTION("YndgXqQVV7c", "libScePad", 1, "libScePad", 1, 1, scePadReadState);
LIB_FUNCTION("5Wf4q349s+Q", "libScePad", 1, "libScePad", 1, 1, scePadReadStateExt);
LIB_FUNCTION("DscD1i9HX1w", "libScePad", 1, "libScePad", 1, 1, scePadResetLightBar);
LIB_FUNCTION("+4c9xRLmiXQ", "libScePad", 1, "libScePad", 1, 1, scePadResetLightBarAll);
LIB_FUNCTION("+Yp6+orqf1M", "libScePad", 1, "libScePad", 1, 1,
scePadResetLightBarAllByPortType);
LIB_FUNCTION("rIZnR6eSpvk", "libScePad", 1, "libScePad", 1, 1, scePadResetOrientation);
LIB_FUNCTION("jbAqAvLEP4A", "libScePad", 1, "libScePad", 1, 1,
scePadResetOrientationForTracker);
LIB_FUNCTION("r44mAxdSG+U", "libScePad", 1, "libScePad", 1, 1,
scePadSetAngularVelocityDeadbandState);
LIB_FUNCTION("ew647HuKi2Y", "libScePad", 1, "libScePad", 1, 1, scePadSetAutoPowerOffCount);
LIB_FUNCTION("MbTt1EHYCTg", "libScePad", 1, "libScePad", 1, 1, scePadSetButtonRemappingInfo);
LIB_FUNCTION("MLA06oNfF+4", "libScePad", 1, "libScePad", 1, 1, scePadSetConnection);
LIB_FUNCTION("bsbHFI0bl5s", "libScePad", 1, "libScePad", 1, 1, scePadSetExtensionReport);
LIB_FUNCTION("xqgVCEflEDY", "libScePad", 1, "libScePad", 1, 1, scePadSetFeatureReport);
LIB_FUNCTION("lrjFx4xWnY8", "libScePad", 1, "libScePad", 1, 1, scePadSetForceIntercepted);
LIB_FUNCTION("RR4novUEENY", "libScePad", 1, "libScePad", 1, 1, scePadSetLightBar);
LIB_FUNCTION("dhQXEvmrVNQ", "libScePad", 1, "libScePad", 1, 1, scePadSetLightBarBaseBrightness);
LIB_FUNCTION("etaQhgPHDRY", "libScePad", 1, "libScePad", 1, 1, scePadSetLightBarBlinking);
LIB_FUNCTION("iHuOWdvQVpg", "libScePad", 1, "libScePad", 1, 1, scePadSetLightBarForTracker);
LIB_FUNCTION("o-6Y99a8dKU", "libScePad", 1, "libScePad", 1, 1, scePadSetLoginUserNumber);
LIB_FUNCTION("clVvL4ZDntw", "libScePad", 1, "libScePad", 1, 1, scePadSetMotionSensorState); LIB_FUNCTION("clVvL4ZDntw", "libScePad", 1, "libScePad", 1, 1, scePadSetMotionSensorState);
} LIB_FUNCTION("flYYxek1wy8", "libScePad", 1, "libScePad", 1, 1, scePadSetProcessFocus);
LIB_FUNCTION("DmBx8K+jDWw", "libScePad", 1, "libScePad", 1, 1, scePadSetProcessPrivilege);
LIB_FUNCTION("FbxEpTRDou8", "libScePad", 1, "libScePad", 1, 1,
scePadSetProcessPrivilegeOfButtonRemapping);
LIB_FUNCTION("yah8Bk4TcYY", "libScePad", 1, "libScePad", 1, 1,
scePadSetShareButtonMaskForRemotePlay);
LIB_FUNCTION("vDLMoJLde8I", "libScePad", 1, "libScePad", 1, 1, scePadSetTiltCorrectionState);
LIB_FUNCTION("z+GEemoTxOo", "libScePad", 1, "libScePad", 1, 1, scePadSetUserColor);
LIB_FUNCTION("yFVnOdGxvZY", "libScePad", 1, "libScePad", 1, 1, scePadSetVibration);
LIB_FUNCTION("8BOObG94-tc", "libScePad", 1, "libScePad", 1, 1, scePadSetVibrationForce);
LIB_FUNCTION("--jrY4SHfm8", "libScePad", 1, "libScePad", 1, 1, scePadSetVrTrackingMode);
LIB_FUNCTION("zFJ35q3RVnY", "libScePad", 1, "libScePad", 1, 1, scePadShareOutputData);
LIB_FUNCTION("80XdmVYsNPA", "libScePad", 1, "libScePad", 1, 1, scePadStartRecording);
LIB_FUNCTION("gAHvg6JPIic", "libScePad", 1, "libScePad", 1, 1, scePadStopRecording);
LIB_FUNCTION("Oi7FzRWFr0Y", "libScePad", 1, "libScePad", 1, 1, scePadSwitchConnection);
LIB_FUNCTION("0MB5x-ieRGI", "libScePad", 1, "libScePad", 1, 1, scePadVertualDeviceAddDevice);
LIB_FUNCTION("N7tpsjWQ87s", "libScePad", 1, "libScePad", 1, 1, scePadVirtualDeviceAddDevice);
LIB_FUNCTION("PFec14-UhEQ", "libScePad", 1, "libScePad", 1, 1, scePadVirtualDeviceDeleteDevice);
LIB_FUNCTION("pjPCronWdxI", "libScePad", 1, "libScePad", 1, 1,
scePadVirtualDeviceDisableButtonRemapping);
LIB_FUNCTION("LKXfw7VJYqg", "libScePad", 1, "libScePad", 1, 1,
scePadVirtualDeviceGetRemoteSetting);
LIB_FUNCTION("IWOyO5jKuZg", "libScePad", 1, "libScePad", 1, 1, scePadVirtualDeviceInsertData);
LIB_FUNCTION("KLmYx9ij2h0", "libScePad", 1, "libScePad", 1, 1, Func_28B998C7D8A3DA1D);
LIB_FUNCTION("KY0hSB+Uyfo", "libScePad", 1, "libScePad", 1, 1, Func_298D21481F94C9FA);
LIB_FUNCTION("UeUUvNOgXKU", "libScePad", 1, "libScePad", 1, 1, Func_51E514BCD3A05CA5);
LIB_FUNCTION("ickjfjk9okM", "libScePad", 1, "libScePad", 1, 1, Func_89C9237E393DA243);
LIB_FUNCTION("7xA+hFtvBCA", "libScePad", 1, "libScePad", 1, 1, Func_EF103E845B6F0420);
};
} // namespace Libraries::LibPad } // namespace Libraries::Pad

View File

@ -4,125 +4,324 @@
#pragma once #pragma once
#include "common/types.h" #include "common/types.h"
#include "src/core/libraries/system/userservice.h"
namespace Core::Loader { namespace Core::Loader {
class SymbolsResolver; class SymbolsResolver;
} }
namespace Libraries::LibPad { namespace Libraries::Pad {
constexpr s8 ORBIS_PAD_PORT_TYPE_STANDARD = 0; constexpr int ORBIS_PAD_MAX_TOUCH_NUM = 2;
constexpr s8 ORBIS_PAD_PORT_TYPE_SPECIAL = 2; constexpr int ORBIS_PAD_MAX_DEVICE_UNIQUE_DATA_SIZE = 12;
constexpr s8 ORBIS_PAD_DEVICE_CLASS_PAD = 0; constexpr int ORBIS_PAD_PORT_TYPE_STANDARD = 0;
constexpr s8 ORBIS_PAD_DEVICE_CLASS_GUITAR = 1; constexpr int ORBIS_PAD_PORT_TYPE_SPECIAL = 2;
constexpr s8 ORBIS_PAD_DEVICE_CLASS_DRUMS = 2;
constexpr s8 ORBIS_PAD_CONNECTION_TYPE_STANDARD = 0; enum OrbisPadDeviceClass {
constexpr s8 ORBIS_PAD_CONNECTION_TYPE_REMOTE = 2; ORBIS_PAD_DEVICE_CLASS_INVALID = -1,
ORBIS_PAD_DEVICE_CLASS_STANDARD = 0,
enum ScePadButton : u32 { ORBIS_PAD_DEVICE_CLASS_GUITAR = 1,
L3 = 0x00000002, ORBIS_PAD_DEVICE_CLASS_DRUM = 2,
R3 = 0x00000004, ORBIS_PAD_DEVICE_CLASS_DJ_TURNTABLE = 3,
OPTIONS = 0x00000008, ORBIS_PAD_DEVICE_CLASS_DANCEMAT = 4,
UP = 0x00000010, ORBIS_PAD_DEVICE_CLASS_NAVIGATION = 5,
RIGHT = 0x00000020, ORBIS_PAD_DEVICE_CLASS_STEERING_WHEEL = 6,
DOWN = 0x00000040, ORBIS_PAD_DEVICE_CLASS_STICK = 7,
LEFT = 0x00000080, ORBIS_PAD_DEVICE_CLASS_FLIGHT_STICK = 8,
L2 = 0x00000100, ORBIS_PAD_DEVICE_CLASS_GUN = 9,
R2 = 0x00000200,
L1 = 0x00000400,
R1 = 0x00000800,
TRIANGLE = 0x00001000,
CIRCLE = 0x00002000,
CROSS = 0x00004000,
SQUARE = 0x00008000,
TOUCH_PAD = 0x00100000,
INTERCEPTED = 0x80000000,
}; };
struct ScePadOpenParam { struct OrbisPadDeviceClassExtendedInformation {
u8 reserve[8]; OrbisPadDeviceClass deviceClass;
u8 reserved[4];
union {
struct {
u8 capability;
u8 reserved1[1];
u16 maxPhysicalWheelAngle;
u8 reserved2[8];
} steeringWheel;
struct {
u8 capability;
u8 quantityOfSelectorSwitch;
u8 reserved[10];
} guitar;
struct {
u8 capability;
u8 reserved[11];
} drum;
struct {
u8 capability;
u8 reserved[11];
} flightStick;
u8 data[12];
} classData;
}; };
struct ScePadAnalogStick { struct OrbisPadDeviceClassData {
u8 x; OrbisPadDeviceClass deviceClass;
u8 y; bool bDataValid;
union {
struct {
float steeringWheelAngle;
u16 steeringWheel;
u16 acceleratorPedal;
u16 brakePedal;
u16 clutchPedal;
u16 handBrake;
u8 gear;
u8 reserved[1];
} steeringWheel;
struct {
u8 toneNumber;
u8 whammyBar;
u8 tilt;
u8 fret;
u8 fretSolo;
u8 reserved[11];
} guitar;
struct {
u8 snare;
u8 tom1;
u8 tom2;
u8 floorTom;
u8 hihatCymbal;
u8 rideCymbal;
u8 crashCymbal;
u8 reserved[9];
} drum;
struct {
u16 stickAxisX;
u16 stickAxisY;
u8 stickTwist;
u8 throttle;
u8 trigger;
u8 rudderPedal;
u8 brakePedalLeft;
u8 brakePedalRight;
u8 antennaKnob;
u8 rangeKnob;
u8 reserved[4];
} flightStick;
struct {
u8 dataLen;
u8 reserved[3];
u8 data[ORBIS_PAD_MAX_DEVICE_UNIQUE_DATA_SIZE];
} others;
} classData;
}; };
struct ScePadAnalogButtons {
struct OrbisPadAnalogButtons {
u8 l2; u8 l2;
u8 r2; u8 r2;
u8 padding[2]; u8 padding[2];
}; };
struct SceFQuaternion { struct OrbisPadAnalogStick {
u8 x;
u8 y;
};
enum OrbisPadButtonDataOffset {
ORBIS_PAD_BUTTON_L3 = 0x00000002,
ORBIS_PAD_BUTTON_R3 = 0x00000004,
ORBIS_PAD_BUTTON_OPTIONS = 0x00000008,
ORBIS_PAD_BUTTON_UP = 0x00000010,
ORBIS_PAD_BUTTON_RIGHT = 0x00000020,
ORBIS_PAD_BUTTON_DOWN = 0x00000040,
ORBIS_PAD_BUTTON_LEFT = 0x00000080,
ORBIS_PAD_BUTTON_L2 = 0x00000100,
ORBIS_PAD_BUTTON_R2 = 0x00000200,
ORBIS_PAD_BUTTON_L1 = 0x00000400,
ORBIS_PAD_BUTTON_R1 = 0x00000800,
ORBIS_PAD_BUTTON_TRIANGLE = 0x00001000,
ORBIS_PAD_BUTTON_CIRCLE = 0x00002000,
ORBIS_PAD_BUTTON_CROSS = 0x00004000,
ORBIS_PAD_BUTTON_SQUARE = 0x00008000,
ORBIS_PAD_BUTTON_TOUCH_PAD = 0x00100000,
ORBIS_PAD_BUTTON_INTERCEPTED = 0x80000000,
};
struct OrbisFQuaternion {
float x, y, z, w; float x, y, z, w;
}; };
struct SceFVector3 { struct OrbisFVector3 {
float x, y, z; float x, y, z;
}; };
struct ScePadTouch { struct OrbisPadTouch {
u16 x; u16 x;
u16 y; u16 y;
u8 id; u8 id;
u8 reserve[3]; u8 reserve[3];
}; };
constexpr int SCE_PAD_MAX_TOUCH_NUM = 2; struct OrbisPadTouchData {
typedef struct ScePadTouchData {
u8 touchNum; u8 touchNum;
u8 reserve[3]; u8 reserve[3];
u32 reserve1; u32 reserve1;
ScePadTouch touch[SCE_PAD_MAX_TOUCH_NUM]; OrbisPadTouch touch[ORBIS_PAD_MAX_TOUCH_NUM];
} ScePadTouchData; };
struct ScePadExtensionUnitData { struct OrbisPadExtensionUnitData {
u32 extensionUnitId; u32 extensionUnitId;
u8 reserve[1]; u8 reserve[1];
u8 dataLength; u8 dataLength;
u8 data[10]; u8 data[10];
}; };
struct ScePadData { struct OrbisPadData {
u32 buttons; u32 buttons;
ScePadAnalogStick leftStick; OrbisPadAnalogStick leftStick;
ScePadAnalogStick rightStick; OrbisPadAnalogStick rightStick;
ScePadAnalogButtons analogButtons; OrbisPadAnalogButtons analogButtons;
SceFQuaternion orientation; OrbisFQuaternion orientation;
SceFVector3 acceleration; OrbisFVector3 acceleration;
SceFVector3 angularVelocity; OrbisFVector3 angularVelocity;
ScePadTouchData touchData; OrbisPadTouchData touchData;
bool connected; bool connected;
u64 timestamp; u64 timestamp;
ScePadExtensionUnitData extensionUnitData; OrbisPadExtensionUnitData extensionUnitData;
uint8_t connectedCount; u8 connectedCount;
uint8_t reserve[2]; u8 reserve[2];
uint8_t deviceUniqueDataLen; u8 deviceUniqueDataLen;
uint8_t deviceUniqueData[12]; u8 deviceUniqueData[ORBIS_PAD_MAX_DEVICE_UNIQUE_DATA_SIZE];
}; };
struct OrbisPadInformation { struct OrbisPadTouchPadInformation {
float touchpadDensity; float pixelDensity;
u16 touchResolutionX; struct {
u16 touchResolutionY; u16 x;
u8 stickDeadzoneL; u16 y;
u8 stickDeadzoneR; } resolution;
};
struct OrbisPadStickInformation {
u8 deadZoneLeft;
u8 deadZoneRight;
};
struct OrbisPadControllerInformation {
OrbisPadTouchPadInformation touchPadInfo;
OrbisPadStickInformation stickInfo;
u8 connectionType; u8 connectionType;
u8 count; u8 connectedCount;
s8 connected; bool connected;
s8 deviceClass; OrbisPadDeviceClass deviceClass;
u8 unknown[8]; u8 reserve[8];
}; };
struct OrbisPadOpenParam {
u8 reserve[8];
};
struct OrbisPadLightBarParam {
u8 r;
u8 g;
u8 b;
u8 reserve[1];
};
struct OrbisPadVibrationParam {
u8 largeMotor;
u8 smallMotor;
};
int PS4_SYSV_ABI scePadClose(s32 handle);
int PS4_SYSV_ABI scePadConnectPort();
int PS4_SYSV_ABI scePadDeviceClassGetExtendedInformation(
s32 handle, OrbisPadDeviceClassExtendedInformation* pExtInfo);
int PS4_SYSV_ABI scePadDeviceClassParseData(s32 handle, const OrbisPadData* pData,
OrbisPadDeviceClassData* pDeviceClassData);
int PS4_SYSV_ABI scePadDeviceOpen();
int PS4_SYSV_ABI scePadDisableVibration();
int PS4_SYSV_ABI scePadDisconnectDevice();
int PS4_SYSV_ABI scePadDisconnectPort();
int PS4_SYSV_ABI scePadEnableAutoDetect();
int PS4_SYSV_ABI scePadEnableExtensionPort();
int PS4_SYSV_ABI scePadEnableSpecificDeviceClass();
int PS4_SYSV_ABI scePadEnableUsbConnection();
int PS4_SYSV_ABI scePadGetBluetoothAddress();
int PS4_SYSV_ABI scePadGetCapability();
int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerInformation* pInfo);
int PS4_SYSV_ABI scePadGetDataInternal();
int PS4_SYSV_ABI scePadGetDeviceId();
int PS4_SYSV_ABI scePadGetDeviceInfo();
int PS4_SYSV_ABI scePadGetExtControllerInformation();
int PS4_SYSV_ABI scePadGetExtensionUnitInfo();
int PS4_SYSV_ABI scePadGetFeatureReport();
int PS4_SYSV_ABI scePadGetHandle(s32 userId, s32 type, s32 index);
int PS4_SYSV_ABI scePadGetIdleCount();
int PS4_SYSV_ABI scePadGetInfo();
int PS4_SYSV_ABI scePadGetInfoByPortType();
int PS4_SYSV_ABI scePadGetLicenseControllerInformation();
int PS4_SYSV_ABI scePadGetMotionSensorPosition();
int PS4_SYSV_ABI scePadGetMotionTimerUnit();
int PS4_SYSV_ABI scePadGetSphereRadius();
int PS4_SYSV_ABI scePadGetVersionInfo();
int PS4_SYSV_ABI scePadInit(); int PS4_SYSV_ABI scePadInit();
int PS4_SYSV_ABI scePadOpen(Libraries::UserService::OrbisUserServiceUserId userId, s32 type, int PS4_SYSV_ABI scePadIsBlasterConnected();
s32 index, const ScePadOpenParam* pParam); int PS4_SYSV_ABI scePadIsDS4Connected();
int PS4_SYSV_ABI scePadReadState(int32_t handle, ScePadData* pData); int PS4_SYSV_ABI scePadIsLightBarBaseBrightnessControllable();
int PS4_SYSV_ABI scePadIsMoveConnected();
int PS4_SYSV_ABI scePadIsMoveReproductionModel();
int PS4_SYSV_ABI scePadIsValidHandle();
int PS4_SYSV_ABI scePadMbusInit();
int PS4_SYSV_ABI scePadMbusTerm();
int PS4_SYSV_ABI scePadOpen(s32 userId, s32 type, s32 index, const OrbisPadOpenParam* pParam);
int PS4_SYSV_ABI scePadOpenExt();
int PS4_SYSV_ABI scePadOpenExt2();
int PS4_SYSV_ABI scePadOutputReport();
int PS4_SYSV_ABI scePadRead(s32 handle, OrbisPadData* pData, s32 num);
int PS4_SYSV_ABI scePadReadBlasterForTracker();
int PS4_SYSV_ABI scePadReadExt();
int PS4_SYSV_ABI scePadReadForTracker();
int PS4_SYSV_ABI scePadReadHistory();
int PS4_SYSV_ABI scePadReadState(s32 handle, OrbisPadData* pData);
int PS4_SYSV_ABI scePadReadStateExt();
int PS4_SYSV_ABI scePadResetLightBar(s32 handle);
int PS4_SYSV_ABI scePadResetLightBarAll();
int PS4_SYSV_ABI scePadResetLightBarAllByPortType();
int PS4_SYSV_ABI scePadResetOrientation(s32 handle);
int PS4_SYSV_ABI scePadResetOrientationForTracker();
int PS4_SYSV_ABI scePadSetAngularVelocityDeadbandState(s32 handle, bool bEnable);
int PS4_SYSV_ABI scePadSetAutoPowerOffCount();
int PS4_SYSV_ABI scePadSetButtonRemappingInfo();
int PS4_SYSV_ABI scePadSetConnection();
int PS4_SYSV_ABI scePadSetExtensionReport();
int PS4_SYSV_ABI scePadSetFeatureReport();
int PS4_SYSV_ABI scePadSetForceIntercepted();
int PS4_SYSV_ABI scePadSetLightBar(s32 handle, const OrbisPadLightBarParam* pParam);
int PS4_SYSV_ABI scePadSetLightBarBaseBrightness();
int PS4_SYSV_ABI scePadSetLightBarBlinking();
int PS4_SYSV_ABI scePadSetLightBarForTracker();
int PS4_SYSV_ABI scePadSetLoginUserNumber();
int PS4_SYSV_ABI scePadSetMotionSensorState(s32 handle, bool bEnable);
int PS4_SYSV_ABI scePadSetProcessFocus();
int PS4_SYSV_ABI scePadSetProcessPrivilege();
int PS4_SYSV_ABI scePadSetProcessPrivilegeOfButtonRemapping();
int PS4_SYSV_ABI scePadSetShareButtonMaskForRemotePlay();
int PS4_SYSV_ABI scePadSetTiltCorrectionState(s32 handle, bool bEnable);
int PS4_SYSV_ABI scePadSetUserColor();
int PS4_SYSV_ABI scePadSetVibration(s32 handle, const OrbisPadVibrationParam* pParam);
int PS4_SYSV_ABI scePadSetVibrationForce();
int PS4_SYSV_ABI scePadSetVrTrackingMode();
int PS4_SYSV_ABI scePadShareOutputData();
int PS4_SYSV_ABI scePadStartRecording();
int PS4_SYSV_ABI scePadStopRecording();
int PS4_SYSV_ABI scePadSwitchConnection();
int PS4_SYSV_ABI scePadVertualDeviceAddDevice();
int PS4_SYSV_ABI scePadVirtualDeviceAddDevice();
int PS4_SYSV_ABI scePadVirtualDeviceDeleteDevice();
int PS4_SYSV_ABI scePadVirtualDeviceDisableButtonRemapping();
int PS4_SYSV_ABI scePadVirtualDeviceGetRemoteSetting();
int PS4_SYSV_ABI scePadVirtualDeviceInsertData();
int PS4_SYSV_ABI Func_28B998C7D8A3DA1D();
int PS4_SYSV_ABI Func_298D21481F94C9FA();
int PS4_SYSV_ABI Func_51E514BCD3A05CA5();
int PS4_SYSV_ABI Func_89C9237E393DA243();
int PS4_SYSV_ABI Func_EF103E845B6F0420();
void padSymbolsRegister(Core::Loader::SymbolsResolver* sym); void RegisterlibScePad(Core::Loader::SymbolsResolver* sym);
} // namespace Libraries::Pad
}; // namespace Libraries::LibPad

View File

@ -2,8 +2,8 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include "core/libraries/kernel/time_management.h" #include "core/libraries/kernel/time_management.h"
#include "core/libraries/pad/pad.h"
#include "input/controller.h" #include "input/controller.h"
namespace Input { namespace Input {
GameController::GameController() { GameController::GameController() {
@ -11,12 +11,12 @@ GameController::GameController() {
m_last_state = State(); m_last_state = State();
} }
void GameController::readState(State* state, bool* isConnected, int* connectedCount) { void GameController::ReadState(State* state, bool* isConnected, int* connectedCount) {
std::scoped_lock lock{m_mutex}; std::scoped_lock lock{m_mutex};
*isConnected = m_connected; *isConnected = m_connected;
*connectedCount = m_connected_count; *connectedCount = m_connected_count;
*state = getLastState(); *state = GetLastState();
} }
int GameController::ReadStates(State* states, int states_num, bool* isConnected, int GameController::ReadStates(State* states, int states_num, bool* isConnected,
@ -50,7 +50,7 @@ int GameController::ReadStates(State* states, int states_num, bool* isConnected,
return ret_num; return ret_num;
} }
State GameController::getLastState() const { State GameController::GetLastState() const {
if (m_states_num == 0) { if (m_states_num == 0) {
return m_last_state; return m_last_state;
} }
@ -60,7 +60,7 @@ State GameController::getLastState() const {
return m_states[last]; return m_states[last];
} }
void GameController::addState(const State& state) { void GameController::AddState(const State& state) {
if (m_states_num >= MAX_STATES) { if (m_states_num >= MAX_STATES) {
m_states_num = MAX_STATES - 1; m_states_num = MAX_STATES - 1;
m_first_state = (m_first_state + 1) % MAX_STATES; m_first_state = (m_first_state + 1) % MAX_STATES;
@ -74,9 +74,9 @@ void GameController::addState(const State& state) {
m_states_num++; m_states_num++;
} }
void GameController::checkButton(int id, u32 button, bool isPressed) { void GameController::CheckButton(int id, u32 button, bool isPressed) {
std::scoped_lock lock{m_mutex}; std::scoped_lock lock{m_mutex};
auto state = getLastState(); auto state = GetLastState();
state.time = Libraries::Kernel::sceKernelGetProcessTime(); state.time = Libraries::Kernel::sceKernelGetProcessTime();
if (isPressed) { if (isPressed) {
state.buttonsState |= button; state.buttonsState |= button;
@ -84,7 +84,36 @@ void GameController::checkButton(int id, u32 button, bool isPressed) {
state.buttonsState &= ~button; state.buttonsState &= ~button;
} }
addState(state); AddState(state);
}
void GameController::Axis(int id, Input::Axis axis, int value) {
std::scoped_lock lock{m_mutex};
auto state = GetLastState();
state.time = Libraries::Kernel::sceKernelGetProcessTime();
int axis_id = static_cast<int>(axis);
state.axes[axis_id] = value;
if (axis == Input::Axis::TriggerLeft) {
if (value > 0) {
state.buttonsState |= Libraries::Pad::OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L2;
} else {
state.buttonsState &= ~Libraries::Pad::OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L2;
}
}
if (axis == Input::Axis::TriggerRight) {
if (value > 0) {
state.buttonsState |= Libraries::Pad::OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2;
} else {
state.buttonsState &= ~Libraries::Pad::OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2;
}
}
AddState(state);
} }
} // namespace Input } // namespace Input

View File

@ -8,11 +8,28 @@
namespace Input { namespace Input {
enum class Axis {
LeftX = 0,
LeftY = 1,
RightX = 2,
RightY = 3,
TriggerLeft = 4,
TriggerRight = 5,
AxisMax
};
struct State { struct State {
u32 buttonsState = 0; u32 buttonsState = 0;
u64 time = 0; u64 time = 0;
int axes[static_cast<int>(Axis::AxisMax)] = {128, 128, 128, 128, 0, 0};
}; };
inline int GetAxis(int min, int max, int value) {
int v = (255 * (value - min)) / (max - min);
return (v < 0 ? 0 : (v > 255 ? 255 : v));
}
constexpr u32 MAX_STATES = 64; constexpr u32 MAX_STATES = 64;
class GameController { class GameController {
@ -20,11 +37,12 @@ public:
GameController(); GameController();
virtual ~GameController() = default; virtual ~GameController() = default;
void readState(State* state, bool* isConnected, int* connectedCount); void ReadState(State* state, bool* isConnected, int* connectedCount);
int ReadStates(State* states, int states_num, bool* isConnected, int* connectedCount); int ReadStates(State* states, int states_num, bool* isConnected, int* connectedCount);
State getLastState() const; State GetLastState() const;
void checkButton(int id, u32 button, bool isPressed); void CheckButton(int id, u32 button, bool isPressed);
void addState(const State& state); void AddState(const State& state);
void Axis(int id, Input::Axis axis, int value);
private: private:
struct StateInternal { struct StateInternal {

View File

@ -96,42 +96,155 @@ void WindowSDL::onResize() {
} }
void WindowSDL::onKeyPress(const SDL_Event* event) { void WindowSDL::onKeyPress(const SDL_Event* event) {
using Libraries::LibPad::ScePadButton; using Libraries::Pad::OrbisPadButtonDataOffset;
u32 button = 0; u32 button = 0;
Input::Axis axis = Input::Axis::AxisMax;
int axisvalue = 0;
int ax = 0;
switch (event->key.keysym.sym) { switch (event->key.keysym.sym) {
case SDLK_UP: case SDLK_UP:
button = ScePadButton::UP; button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_UP;
break; break;
case SDLK_DOWN: case SDLK_DOWN:
button = ScePadButton::DOWN; button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_DOWN;
break; break;
case SDLK_LEFT: case SDLK_LEFT:
button = ScePadButton::LEFT; button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_LEFT;
break; break;
case SDLK_RIGHT: case SDLK_RIGHT:
button = ScePadButton::RIGHT; button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_RIGHT;
break; break;
case SDLK_KP_8: case SDLK_KP_8:
button = ScePadButton::TRIANGLE; button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TRIANGLE;
break; break;
case SDLK_KP_6: case SDLK_KP_6:
button = ScePadButton::CIRCLE; button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_CIRCLE;
break; break;
case SDLK_KP_2: case SDLK_KP_2:
button = ScePadButton::CROSS; button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_CROSS;
break; break;
case SDLK_KP_4: case SDLK_KP_4:
button = ScePadButton::SQUARE; button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_SQUARE;
break; break;
case SDLK_RETURN: case SDLK_RETURN:
button = ScePadButton::OPTIONS; button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_OPTIONS;
break;
case SDLK_a:
axis = Input::Axis::LeftX;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += -127;
} else {
axisvalue = 0;
}
ax = Input::GetAxis(-0x80, 0x80, axisvalue);
break;
case SDLK_d:
axis = Input::Axis::LeftX;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += 127;
} else {
axisvalue = 0;
}
ax = Input::GetAxis(-0x80, 0x80, axisvalue);
break;
case SDLK_w:
axis = Input::Axis::LeftY;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += -127;
} else {
axisvalue = 0;
}
ax = Input::GetAxis(-0x80, 0x80, axisvalue);
break;
case SDLK_s:
axis = Input::Axis::LeftY;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += 127;
} else {
axisvalue = 0;
}
ax = Input::GetAxis(-0x80, 0x80, axisvalue);
break;
case SDLK_j:
axis = Input::Axis::RightX;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += -127;
} else {
axisvalue = 0;
}
ax = Input::GetAxis(-0x80, 0x80, axisvalue);
break;
case SDLK_l:
axis = Input::Axis::RightX;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += 127;
} else {
axisvalue = 0;
}
ax = Input::GetAxis(-0x80, 0x80, axisvalue);
break;
case SDLK_i:
axis = Input::Axis::RightY;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += -127;
} else {
axisvalue = 0;
}
ax = Input::GetAxis(-0x80, 0x80, axisvalue);
break;
case SDLK_k:
axis = Input::Axis::RightY;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += 127;
} else {
axisvalue = 0;
}
ax = Input::GetAxis(-0x80, 0x80, axisvalue);
break;
case SDLK_x:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L3;
break;
case SDLK_m:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R3;
break;
case SDLK_q:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L1;
break;
case SDLK_u:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R1;
break;
case SDLK_e:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L2;
axis = Input::Axis::TriggerLeft;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += 255;
} else {
axisvalue = 0;
}
ax = Input::GetAxis(0, 0x80, axisvalue);
break;
case SDLK_o:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2;
axis = Input::Axis::TriggerRight;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += 255;
} else {
axisvalue = 0;
}
ax = Input::GetAxis(0, 0x80, axisvalue);
break;
case SDLK_SPACE:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD;
break; break;
default: default:
break; break;
} }
if (button != 0) { if (button != 0) {
controller->checkButton(0, button, event->type == SDL_EVENT_KEY_DOWN); controller->CheckButton(0, button, event->type == SDL_EVENT_KEY_DOWN);
}
if (axis != Input::Axis::AxisMax) {
controller->Axis(0, axis, ax);
} }
} }