Merge pull request #626 from InvoxiPlayGames/special-pad

pad: add support for configurable special pad class
This commit is contained in:
georgemoralis 2024-08-28 13:24:37 +03:00 committed by GitHub
commit 878fac7f94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 67 additions and 2 deletions

View File

@ -17,6 +17,8 @@ static s32 gpuId = -1; // Vulkan physical device index. Set to negative for auto
static std::string logFilter;
static std::string logType = "async";
static std::string userName = "shadPS4";
static bool useSpecialPad = false;
static int specialPadClass = 1;
static bool isDebugDump = false;
static bool isShowSplash = false;
static bool isNullGpu = false;
@ -81,6 +83,14 @@ std::string getUserName() {
return userName;
}
bool getUseSpecialPad() {
return useSpecialPad;
}
int getSpecialPadClass() {
return specialPadClass;
}
bool debugDump() {
return isDebugDump;
}
@ -197,6 +207,14 @@ void setUserName(const std::string& type) {
userName = type;
}
void setUseSpecialPad(bool use) {
useSpecialPad = use;
}
void setSpecialPadClass(int type) {
specialPadClass = type;
}
void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h) {
main_window_geometry_x = x;
main_window_geometry_y = y;
@ -330,6 +348,13 @@ void load(const std::filesystem::path& path) {
isShowSplash = toml::find_or<bool>(general, "showSplash", true);
}
if (data.contains("Input")) {
const toml::value& input = data.at("Input");
useSpecialPad = toml::find_or<bool>(input, "useSpecialPad", false);
specialPadClass = toml::find_or<int>(input, "specialPadClass", 1);
}
if (data.contains("GPU")) {
const toml::value& gpu = data.at("GPU");
@ -411,6 +436,8 @@ void save(const std::filesystem::path& path) {
data["General"]["logType"] = logType;
data["General"]["userName"] = userName;
data["General"]["showSplash"] = isShowSplash;
data["Input"]["useSpecialPad"] = useSpecialPad;
data["Input"]["specialPadClass"] = specialPadClass;
data["GPU"]["screenWidth"] = screenWidth;
data["GPU"]["screenHeight"] = screenHeight;
data["GPU"]["nullGpu"] = isNullGpu;
@ -457,6 +484,8 @@ void setDefaultValues() {
logFilter = "";
logType = "async";
userName = "shadPS4";
useSpecialPad = false;
specialPadClass = 1;
isDebugDump = false;
isShowSplash = false;
isNullGpu = false;

View File

@ -17,6 +17,9 @@ std::string getLogFilter();
std::string getLogType();
std::string getUserName();
bool getUseSpecialPad();
int getSpecialPadClass();
u32 getScreenWidth();
u32 getScreenHeight();
s32 getGpuId();
@ -44,6 +47,9 @@ void setLanguage(u32 language);
void setNeoMode(bool enable);
void setUserName(const std::string& type);
void setUseSpecialPad(bool use);
void setSpecialPadClass(int type);
void setLogType(const std::string& type);
void setLogFilter(const std::string& type);

View File

@ -4,6 +4,7 @@
// Generated By moduleGenerator
#include <common/assert.h>
#include <common/singleton.h>
#include "common/config.h"
#include "common/logging/log.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/libs.h"
@ -25,6 +26,9 @@ int PS4_SYSV_ABI scePadConnectPort() {
int PS4_SYSV_ABI scePadDeviceClassGetExtendedInformation(
s32 handle, OrbisPadDeviceClassExtendedInformation* pExtInfo) {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
if (Config::getUseSpecialPad()) {
pExtInfo->deviceClass = (OrbisPadDeviceClass)Config::getSpecialPadClass();
}
return ORBIS_OK;
}
@ -107,6 +111,10 @@ int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerIn
pInfo->connectedCount = 1;
pInfo->connected = true;
pInfo->deviceClass = ORBIS_PAD_DEVICE_CLASS_STANDARD;
if (Config::getUseSpecialPad()) {
pInfo->connectionType = ORBIS_PAD_PORT_TYPE_SPECIAL;
pInfo->deviceClass = (OrbisPadDeviceClass)Config::getSpecialPadClass();
}
return SCE_OK;
}
@ -239,11 +247,26 @@ int PS4_SYSV_ABI scePadMbusTerm() {
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);
if (Config::getUseSpecialPad()) {
if (type != ORBIS_PAD_PORT_TYPE_SPECIAL)
return ORBIS_PAD_ERROR_DEVICE_NOT_CONNECTED;
} else {
if (type != ORBIS_PAD_PORT_TYPE_STANDARD)
return ORBIS_PAD_ERROR_DEVICE_NOT_CONNECTED;
}
return 1; // dummy
}
int PS4_SYSV_ABI scePadOpenExt() {
int PS4_SYSV_ABI scePadOpenExt(s32 userId, s32 type, s32 index,
const OrbisPadOpenExtParam* pParam) {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
if (Config::getUseSpecialPad()) {
if (type != ORBIS_PAD_PORT_TYPE_SPECIAL)
return ORBIS_PAD_ERROR_DEVICE_NOT_CONNECTED;
} else {
if (type != ORBIS_PAD_PORT_TYPE_STANDARD)
return ORBIS_PAD_ERROR_DEVICE_NOT_CONNECTED;
}
return 1; // dummy
}

View File

@ -229,6 +229,13 @@ struct OrbisPadOpenParam {
u8 reserve[8];
};
struct OrbisPadOpenExtParam {
u16 vendorId;
u16 productId;
u16 productId_2;
u8 reserve[10];
};
struct OrbisPadLightBarParam {
u8 r;
u8 g;
@ -284,7 +291,7 @@ 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 scePadOpenExt(s32 userId, s32 type, s32 index, const OrbisPadOpenExtParam* pParam);
int PS4_SYSV_ABI scePadOpenExt2();
int PS4_SYSV_ABI scePadOutputReport();
int PS4_SYSV_ABI scePadRead(s32 handle, OrbisPadData* pData, s32 num);