mirror of
https://github.com/AkaiiKitsune/TAL_CardReader
synced 2024-11-27 18:30:48 +01:00
Better card formatting
- Added extra safety if a card has already been scanned (1s cooldown) - Cards are formatted in a better way
This commit is contained in:
parent
824cf5efce
commit
1cb7165bdf
@ -30,12 +30,12 @@
|
|||||||
#include <hidsdi.h>
|
#include <hidsdi.h>
|
||||||
#include <setupapi.h>
|
#include <setupapi.h>
|
||||||
|
|
||||||
|
|
||||||
extern CRITICAL_SECTION CARDIO_HID_CRIT_SECTION;
|
extern CRITICAL_SECTION CARDIO_HID_CRIT_SECTION;
|
||||||
extern struct cardio_hid_device *CARDIO_HID_CONTEXTS;
|
extern struct cardio_hid_device *CARDIO_HID_CONTEXTS;
|
||||||
extern size_t CARDIO_HID_CONTEXTS_LENGTH;
|
extern size_t CARDIO_HID_CONTEXTS_LENGTH;
|
||||||
|
|
||||||
struct cardio_hid_device {
|
struct cardio_hid_device
|
||||||
|
{
|
||||||
LPWSTR dev_path;
|
LPWSTR dev_path;
|
||||||
HANDLE dev_handle;
|
HANDLE dev_handle;
|
||||||
OVERLAPPED read_state;
|
OVERLAPPED read_state;
|
||||||
@ -43,9 +43,9 @@ struct cardio_hid_device {
|
|||||||
BOOL io_pending;
|
BOOL io_pending;
|
||||||
|
|
||||||
BYTE report_buffer[128];
|
BYTE report_buffer[128];
|
||||||
union {
|
union
|
||||||
|
{
|
||||||
unsigned char usage_value[128];
|
unsigned char usage_value[128];
|
||||||
uint64_t usage64[8];
|
|
||||||
} u;
|
} u;
|
||||||
DWORD read_size;
|
DWORD read_size;
|
||||||
|
|
||||||
@ -55,13 +55,15 @@ struct cardio_hid_device {
|
|||||||
USHORT collection_length;
|
USHORT collection_length;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum cardio_poll_value {
|
typedef enum cardio_poll_value
|
||||||
|
{
|
||||||
HID_POLL_ERROR = 0,
|
HID_POLL_ERROR = 0,
|
||||||
HID_POLL_CARD_NOT_READY = 1,
|
HID_POLL_CARD_NOT_READY = 1,
|
||||||
HID_POLL_CARD_READY = 2,
|
HID_POLL_CARD_READY = 2,
|
||||||
} cardio_hid_poll_value_t;
|
} cardio_hid_poll_value_t;
|
||||||
|
|
||||||
typedef enum cardio_hid_card_type {
|
typedef enum cardio_hid_card_type
|
||||||
|
{
|
||||||
HID_CARD_NONE = 0,
|
HID_CARD_NONE = 0,
|
||||||
HID_CARD_ISO_15693 = 0x41,
|
HID_CARD_ISO_15693 = 0x41,
|
||||||
HID_CARD_ISO_18092 = 0x42,
|
HID_CARD_ISO_18092 = 0x42,
|
||||||
@ -83,4 +85,4 @@ cardio_hid_poll_value_t cardio_hid_device_poll(struct cardio_hid_device *ctx);
|
|||||||
|
|
||||||
cardio_hid_card_type_t cardio_hid_device_read(struct cardio_hid_device *ctx);
|
cardio_hid_card_type_t cardio_hid_device_read(struct cardio_hid_device *ctx);
|
||||||
|
|
||||||
#endif //SPICETOOLS_CARDIO_HID_H
|
#endif // SPICETOOLS_CARDIO_HID_H
|
@ -11,7 +11,7 @@ static bool HasCard = false;
|
|||||||
typedef void (*callbackTouch)(i32, i32, u8[168], u64);
|
typedef void (*callbackTouch)(i32, i32, u8[168], u64);
|
||||||
callbackTouch touchCallback;
|
callbackTouch touchCallback;
|
||||||
u64 touchData;
|
u64 touchData;
|
||||||
static char AccessID[21] = "00000000000000000001";
|
char AccessID[21] = "00000000000000000001";
|
||||||
static u8 cardData[168] = {0x01, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x92, 0x2E, 0x58, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00,
|
static u8 cardData[168] = {0x01, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x92, 0x2E, 0x58, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x5C, 0x97, 0x44, 0xF0, 0x88, 0x04, 0x00, 0x43, 0x26, 0x2C, 0x33, 0x00, 0x04,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x5C, 0x97, 0x44, 0xF0, 0x88, 0x04, 0x00, 0x43, 0x26, 0x2C, 0x33, 0x00, 0x04,
|
||||||
0x06, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
|
0x06, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||||
@ -23,6 +23,12 @@ static u8 cardData[168] = {0x01, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
|
|||||||
|
|
||||||
void PollReader()
|
void PollReader()
|
||||||
{
|
{
|
||||||
|
if (HasCard) // A card scan is already in progress
|
||||||
|
{
|
||||||
|
Sleep(1000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// update HID devices
|
// update HID devices
|
||||||
EnterCriticalSection(&CARDIO_HID_CRIT_SECTION);
|
EnterCriticalSection(&CARDIO_HID_CRIT_SECTION);
|
||||||
for (size_t device_no = 0; device_no < CARDIO_HID_CONTEXTS_LENGTH; device_no++)
|
for (size_t device_no = 0; device_no < CARDIO_HID_CONTEXTS_LENGTH; device_no++)
|
||||||
@ -45,10 +51,11 @@ void PollReader()
|
|||||||
|
|
||||||
if (waitingForTouch)
|
if (waitingForTouch)
|
||||||
{
|
{
|
||||||
// Convert card to proper format
|
// Properly format the AccessID
|
||||||
sprintf(AccessID, "%020llu", device->u.usage64[0]);
|
u64 ReversedAccessID;
|
||||||
// Format the AccessID in a way that doesn't crash the game.
|
for (int i = 0; i < 8; i++)
|
||||||
// memset(AccessID, '0', 10);
|
ReversedAccessID = (ReversedAccessID << 8) | device->u.usage_value[i];
|
||||||
|
sprintf(AccessID, "%020llu", ReversedAccessID);
|
||||||
|
|
||||||
HasCard = true;
|
HasCard = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user