fossilised code elimination

This commit is contained in:
kalaposfos13 2026-03-03 14:58:17 +01:00
parent 83ad83c8ef
commit 9a487010d7
4 changed files with 9 additions and 73 deletions

View File

@ -211,13 +211,6 @@ void IPC::InputLoop() {
} else if (cmd == "RELOAD_INPUTS") {
std::string config = next_str();
Input::ParseInputConfig(config);
} else if (cmd == "SET_ACTIVE_CONTROLLER") {
std::string active_controller = next_str();
GamepadSelect::SetSelectedGamepad(active_controller);
SDL_Event checkGamepad;
SDL_memset(&checkGamepad, 0, sizeof(checkGamepad));
checkGamepad.type = SDL_EVENT_CHANGE_CONTROLLER;
SDL_PushEvent(&checkGamepad);
} else {
std::cerr << ";UNKNOWN CMD: " << cmd << std::endl;
}

View File

@ -411,7 +411,7 @@ int PS4_SYSV_ABI scePadRead(s32 handle, OrbisPadData* pData, s32 num) {
int connected_count = 0;
bool connected = false;
std::vector<Input::State> states(64);
auto controller_id = GamepadSelect::GetControllerIndexFromUserID(handle);
auto controller_id = GameControllers::GetControllerIndexFromUserID(handle);
if (!controller_id) {
return ORBIS_PAD_ERROR_INVALID_HANDLE;
}
@ -444,7 +444,7 @@ int PS4_SYSV_ABI scePadReadHistory() {
int PS4_SYSV_ABI scePadReadState(s32 handle, OrbisPadData* pData) {
LOG_TRACE(Lib_Pad, "handle: {}", handle);
auto controller_id = GamepadSelect::GetControllerIndexFromUserID(handle);
auto controller_id = GameControllers::GetControllerIndexFromUserID(handle);
if (!controller_id) {
return ORBIS_PAD_ERROR_INVALID_HANDLE;
}
@ -465,7 +465,7 @@ int PS4_SYSV_ABI scePadReadStateExt() {
int PS4_SYSV_ABI scePadResetLightBar(s32 handle) {
LOG_INFO(Lib_Pad, "(DUMMY) called");
auto controller_id = GamepadSelect::GetControllerIndexFromUserID(handle);
auto controller_id = GameControllers::GetControllerIndexFromUserID(handle);
if (!controller_id) {
return ORBIS_PAD_ERROR_INVALID_HANDLE;
}
@ -488,7 +488,7 @@ int PS4_SYSV_ABI scePadResetLightBarAllByPortType() {
int PS4_SYSV_ABI scePadResetOrientation(s32 handle) {
LOG_INFO(Lib_Pad, "scePadResetOrientation called handle = {}", handle);
auto controller_id = GamepadSelect::GetControllerIndexFromUserID(handle);
auto controller_id = GameControllers::GetControllerIndexFromUserID(handle);
if (!controller_id) {
return ORBIS_PAD_ERROR_INVALID_HANDLE;
}
@ -545,7 +545,7 @@ int PS4_SYSV_ABI scePadSetLightBar(s32 handle, const OrbisPadLightBarParam* pPar
if (GameControllers::GetOverrideControllerColor()) {
return ORBIS_OK;
}
auto controller_id = GamepadSelect::GetControllerIndexFromUserID(handle);
auto controller_id = GameControllers::GetControllerIndexFromUserID(handle);
if (!controller_id) {
return ORBIS_PAD_ERROR_INVALID_HANDLE;
}
@ -625,7 +625,7 @@ int PS4_SYSV_ABI scePadSetUserColor() {
}
int PS4_SYSV_ABI scePadSetVibration(s32 handle, const OrbisPadVibrationParam* pParam) {
auto controller_id = GamepadSelect::GetControllerIndexFromUserID(handle);
auto controller_id = GameControllers::GetControllerIndexFromUserID(handle);
if (!controller_id) {
return ORBIS_PAD_ERROR_INVALID_HANDLE;
}

View File

@ -13,8 +13,6 @@
#include "core/libraries/system/userservice.h"
#include "input/controller.h"
static std::string SelectedGamepad = "";
namespace Input {
using Libraries::Pad::OrbisPadButtonDataOffset;
@ -376,55 +374,10 @@ u8 GameControllers::GetGamepadIndexFromJoystickId(SDL_JoystickID id) {
return index;
}
} // namespace Input
namespace GamepadSelect {
int GetDefaultGamepad(SDL_JoystickID* gamepadIDs, int gamepadCount) {
char GUIDbuf[33];
if (EmulatorSettings.GetDefaultControllerId() != "") {
for (int i = 0; i < gamepadCount; i++) {
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepadIDs[i]), GUIDbuf, 33);
std::string currentGUID = std::string(GUIDbuf);
if (currentGUID == EmulatorSettings.GetDefaultControllerId()) {
return i;
}
}
}
return -1;
}
std::optional<u8> GetControllerIndexFromUserID(s32 user_id) {
std::optional<u8> GameControllers::GetControllerIndexFromUserID(s32 user_id) {
if (user_id < 1 || user_id > 4)
return std::nullopt;
return static_cast<u8>(user_id - 1);
}
int GetIndexfromGUID(SDL_JoystickID* gamepadIDs, int gamepadCount, std::string GUID) {
char GUIDbuf[33];
for (int i = 0; i < gamepadCount; i++) {
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepadIDs[i]), GUIDbuf, 33);
std::string currentGUID = std::string(GUIDbuf);
if (currentGUID == GUID) {
return i;
}
}
return -1;
}
std::string GetGUIDString(SDL_JoystickID* gamepadIDs, int index) {
char GUIDbuf[33];
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepadIDs[index]), GUIDbuf, 33);
std::string GUID = std::string(GUIDbuf);
return GUID;
}
std::string GetSelectedGamepad() {
return SelectedGamepad;
}
void SetSelectedGamepad(std::string GUID) {
SelectedGamepad = GUID;
}
} // namespace GamepadSelect
} // namespace Input

View File

@ -150,7 +150,6 @@ public:
float gyro_buf[3] = {0.0f, 0.0f, 0.0f}, accel_buf[3] = {0.0f, 9.81f, 0.0f};
u32 user_id = Libraries::UserService::ORBIS_USER_SERVICE_USER_ID_INVALID;
SDL_Gamepad* m_sdl_gamepad = nullptr;
SDL_JoystickID m_sdl_joystickid{};
private:
void PushState();
@ -258,6 +257,7 @@ public:
}
static void TryOpenSDLControllers(GameControllers& controllers);
static u8 GetGamepadIndexFromJoystickId(SDL_JoystickID id);
static std::optional<u8> GetControllerIndexFromUserID(s32 user_id);
static void CalculateOrientation(Libraries::Pad::OrbisFVector3& acceleration,
Libraries::Pad::OrbisFVector3& angularVelocity,
@ -279,13 +279,3 @@ public:
};
} // namespace Input
namespace GamepadSelect {
std::optional<u8> GetControllerIndexFromUserID(s32 user_id);
int GetIndexfromGUID(SDL_JoystickID* gamepadIDs, int gamepadCount, std::string GUID);
std::string GetGUIDString(SDL_JoystickID* gamepadIDs, int index);
std::string GetSelectedGamepad();
void SetSelectedGamepad(std::string GUID);
} // namespace GamepadSelect