Turns out i'm retarded

No longer stopping the cardIO polling thread once we read a card.
This commit is contained in:
Farewell_ 2024-05-18 19:42:48 +02:00
parent ce6d0f1cae
commit ff5fd4bc5d

View File

@ -25,53 +25,55 @@ static unsigned int __stdcall reader_poll_thread_proc(void *ctx)
if (HasCard && !usingSmartCard) // A Cardio scan is already in progress, SmartCard doesn't need any extra cooldown. if (HasCard && !usingSmartCard) // A Cardio scan is already in progress, SmartCard doesn't need any extra cooldown.
{ {
Sleep(500); Sleep(500);
return 0;
} }
else
uint8_t UID[8] = {0};
// update devices
if (!usingSmartCard) // CardIO
{ {
EnterCriticalSection(&CARDIO_HID_CRIT_SECTION);
for (size_t device_no = 0; device_no < CARDIO_HID_CONTEXTS_LENGTH; device_no++) uint8_t UID[8] = {0};
// update devices
if (!usingSmartCard) // CardIO
{ {
struct cardio_hid_device *device = &CARDIO_HID_CONTEXTS[device_no]; EnterCriticalSection(&CARDIO_HID_CRIT_SECTION);
for (size_t device_no = 0; device_no < CARDIO_HID_CONTEXTS_LENGTH; device_no++)
// get status
cardio_hid_poll_value_t status = cardio_hid_device_poll(device);
if (status == HID_POLL_CARD_READY)
{ {
struct cardio_hid_device *device = &CARDIO_HID_CONTEXTS[device_no];
// read card // get status
if (cardio_hid_device_read(device) == HID_CARD_NONE) cardio_hid_poll_value_t status = cardio_hid_device_poll(device);
continue; if (status == HID_POLL_CARD_READY)
{
// if card not empty // read card
if (*((uint64_t *)&device->u.usage_value[0]) > 0) if (cardio_hid_device_read(device) == HID_CARD_NONE)
for (int i = 0; i < 8; ++i) continue;
UID[i] = device->u.usage_value[i];
// if card not empty
if (*((uint64_t *)&device->u.usage_value[0]) > 0)
for (int i = 0; i < 8; ++i)
UID[i] = device->u.usage_value[i];
}
} }
LeaveCriticalSection(&CARDIO_HID_CRIT_SECTION);
Sleep(readCooldown);
}
else // SmartCard
{
scard_update(UID);
} }
LeaveCriticalSection(&CARDIO_HID_CRIT_SECTION);
Sleep(readCooldown);
}
else // SmartCard
{
scard_update(UID);
}
if (UID[0] > 0) // If a card was read, format it properly and set HasCard to true so the game can insert it on next frame. if (UID[0] > 0) // If a card was read, format it properly and set HasCard to true so the game can insert it on next frame.
{ {
printWarning("%s (%s): Read card %02X%02X%02X%02X%02X%02X%02X%02X\n", __func__, module, UID[0], UID[1], UID[2], UID[3], UID[4], UID[5], UID[6], UID[7]); printWarning("%s (%s): Read card %02X%02X%02X%02X%02X%02X%02X%02X\n", __func__, module, UID[0], UID[1], UID[2], UID[3], UID[4], UID[5], UID[6], UID[7]);
// Properly format the AccessID // Properly format the AccessID
u64 ReversedAccessID; u64 ReversedAccessID;
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
ReversedAccessID = (ReversedAccessID << 8) | UID[i]; ReversedAccessID = (ReversedAccessID << 8) | UID[i];
sprintf(AccessID, "%020llu", ReversedAccessID); sprintf(AccessID, "%020llu", ReversedAccessID);
HasCard = true; HasCard = true;
}
} }
} }