mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-06-02 21:05:13 -06:00
Attempt to fix yet another input regression in some Unity games (#4480)
* Set dummy GameController's m_connected to false * Remove this check and handle it differently * Save one reverse lookup on a map this is mostly irrelevant on performance * i have no clue so let's just log stuff * apparently this is the correct default * swap this to debug logging * the loathsome clang-formatter
This commit is contained in:
parent
0f094cb6c8
commit
2b5aa0b1c3
@ -42,20 +42,6 @@ static u64 pad_handle_counter = 1;
|
||||
static std::unordered_map<HandleKey, s32, HandleKeyHash> pad_handle_map{};
|
||||
static std::unordered_map<s32, GameController*> handle_to_controller_map{};
|
||||
|
||||
static std::optional<HandleKey> FindHandleKeyByHandle(s32 handle) {
|
||||
for (const auto& [key, value] : pad_handle_map) {
|
||||
if (value == handle) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
static bool IsUnavailableSpecialHandle(const std::optional<HandleKey>& handle_key) {
|
||||
return handle_key.has_value() && handle_key->device_class == ORBIS_PAD_PORT_TYPE_SPECIAL &&
|
||||
!EmulatorSettings.IsUsingSpecialPad();
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI scePadClose(s32 handle) {
|
||||
LOG_WARNING(Lib_Pad, "called, handle: {}", handle);
|
||||
if (handle_to_controller_map.erase(handle) == 0) {
|
||||
@ -151,13 +137,10 @@ int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerIn
|
||||
if (it == handle_to_controller_map.end()) {
|
||||
return ORBIS_PAD_ERROR_INVALID_HANDLE;
|
||||
}
|
||||
const auto handle_key = FindHandleKeyByHandle(handle);
|
||||
bool connected = false;
|
||||
int connected_count = 0;
|
||||
Input::State state{};
|
||||
if (!IsUnavailableSpecialHandle(handle_key)) {
|
||||
it->second->ReadState(&state, &connected, &connected_count);
|
||||
}
|
||||
it->second->ReadState(&state, &connected, &connected_count);
|
||||
|
||||
std::memset(pInfo, 0, sizeof(OrbisPadControllerInformation));
|
||||
pInfo->touchPadInfo.pixelDensity = 1;
|
||||
@ -167,14 +150,15 @@ int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerIn
|
||||
pInfo->stickInfo.deadZoneRight = 1;
|
||||
pInfo->connectionType = ORBIS_PAD_CONNECTION_TYPE_LOCAL;
|
||||
pInfo->connectedCount = static_cast<u8>(std::clamp(connected_count, 0, 0xff));
|
||||
pInfo->deviceClass = OrbisPadDeviceClass::Invalid;
|
||||
pInfo->deviceClass = OrbisPadDeviceClass::Standard;
|
||||
pInfo->connected = connected;
|
||||
if (handle_key.has_value() && handle_key->device_class == ORBIS_PAD_PORT_TYPE_STANDARD) {
|
||||
pInfo->deviceClass = OrbisPadDeviceClass::Standard;
|
||||
} else if (handle_key.has_value() && handle_key->device_class == ORBIS_PAD_PORT_TYPE_SPECIAL &&
|
||||
EmulatorSettings.IsUsingSpecialPad()) {
|
||||
pInfo->deviceClass = (OrbisPadDeviceClass)EmulatorSettings.GetSpecialPadClass();
|
||||
if (connected) {
|
||||
pInfo->deviceClass = EmulatorSettings.IsUsingSpecialPad()
|
||||
? (OrbisPadDeviceClass)EmulatorSettings.GetSpecialPadClass()
|
||||
: OrbisPadDeviceClass::Standard;
|
||||
}
|
||||
LOG_DEBUG(Lib_Pad, "c: {} cc: {}, ct: {}, dc: {}", pInfo->connected, pInfo->connectedCount,
|
||||
pInfo->connectionType, std::to_underlying(pInfo->deviceClass));
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -178,7 +178,10 @@ class GameControllers {
|
||||
public:
|
||||
GameControllers()
|
||||
: controllers({new GameController(), new GameController(), new GameController(),
|
||||
new GameController(), new GameController()}) {};
|
||||
new GameController(), new GameController()}) {
|
||||
controllers[4]->m_connected = false;
|
||||
controllers[4]->m_connected_count = 0;
|
||||
};
|
||||
virtual ~GameControllers() = default;
|
||||
GameController* operator[](const size_t& i) const {
|
||||
if (i > 4) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user