fix(pad): preserve connected port state across initialization

This commit is contained in:
SlugZero authored and Adrià Franch committed 2026-10-24 19:21:15 +02:00
1 parent 58a1bcc5a3
commit 6b7d6796ff
2 files changed
+12 -2

No files matched your search

+5 -2
View File
@@ -47,7 +47,11 @@ namespace {
};
std::mutex stateMutex;
std::array<PadSlot, PAD_MAX_CONTROLLERS> slots;
std::array<PadSlot, PAD_MAX_CONTROLLERS> slots = [] {
std::array<PadSlot, PAD_MAX_CONTROLLERS> initialSlots{};
initialSlots[0].connected = true;
return initialSlots;
}();
std::exception_ptr failure;
bool initialized = false;
constexpr float kAngularVelocityDeadband = 0.017453292f;
@@ -136,7 +140,6 @@ void Pad::Initialize() {
slots[i].lastFuseTime = now;
slots[i].queue.clear();
slots[i].pressedSinceRead = 0;
slots[i].connected = (i == 0);
}
}
initialized = true;
+7
View File
@@ -634,7 +634,14 @@ int main() {
Require(scePadGetHandle(user, PAD_PORT_TYPE_SPECIAL, 0) == earlySpecial);
Require(scePadClose_nid_postfix(earlySpecial) == PAD_OK);
Require(scePadGetHandle(user, PAD_PORT_TYPE_SPECIAL, 0) == noHandle);
PadSetPortConnected_nid_postfix(1, true);
Require(scePadInit_nid_postfix() == 0);
PadInfo initInfo{};
Require(scePadGetInfo_nid_postfix(&initInfo) == PAD_OK);
Require(initInfo.connectedCount[0] == 2);
Require(initInfo.padTypeInfo[0].connectPort == 0);
Require(initInfo.padTypeInfo[1].connectPort == 1);
PadSetPortConnected_nid_postfix(1, false);
Require(scePadUnknown_n3kSX62fgNo() == PAD_OK);
const int handle = scePadOpen_nid_postfix(user, 0, 0, nullptr);
Require(handle > 0);