ekt: make ports configurable, misc corrections

This commit is contained in:
2025-09-02 13:54:07 +02:00
parent fdd9c2fbc8
commit da0fc56500
4 changed files with 17 additions and 23 deletions

View File

@ -81,6 +81,11 @@ dipsw1=0
; modding frameworks such as BepInEx.
targetAssembly=
[flatPanelReader]
enable=1
port_field=4
port_printer=0
; -----------------------------------------------------------------------------
; LED settings
; -----------------------------------------------------------------------------

View File

@ -108,13 +108,9 @@ void y3_config_load(
memset(cfg->target_code_printer, ' ', sizeof(cfg->target_code_printer) - 1);
cfg->target_code_printer[sizeof(cfg->target_code_printer) - 1] = '\0';
cfg->enable = GetPrivateProfileIntW(L"y3", L"enable", 1, filename);
cfg->ws_enable = GetPrivateProfileIntW(L"y3", L"ws_enable", 1, filename);
cfg->ws_port = GetPrivateProfileIntW(L"y3", L"ws_port", 3597, filename);
cfg->ws_timeout = GetPrivateProfileIntW(L"y3", L"ws_timeout", 30000, filename);
cfg->enable = GetPrivateProfileIntW(L"flatPanelReader", L"enable", 1, filename);
cfg->port_field = GetPrivateProfileIntW(L"flatPanelReader", L"port_field", 10, filename);
cfg->port_printer = GetPrivateProfileIntW(L"flatPanelReader", L"port_printer", 11, filename);
cfg->dll_version = (float)GetPrivateProfileIntW(
L"flatPanelReader",

View File

@ -261,8 +261,8 @@ static struct y3_config y3_config;
#define MAX_CARD_SIZE 32
static struct CardInfo card_data[MAX_CARD_SIZE];
static const int* Y3_COM_FIELD = (int*)10;
static const int* Y3_COM_PRINT = (int*)11;
static int* Y3_COM_FIELD = (int*)10;
static int* Y3_COM_PRINT = (int*)11;
void y3_hook_init(const struct y3_config* cfg, HINSTANCE self) {
assert(cfg != NULL);
@ -272,12 +272,14 @@ void y3_hook_init(const struct y3_config* cfg, HINSTANCE self) {
}
memcpy(&y3_config, cfg, sizeof(*cfg));
Y3_COM_FIELD = (int*)(uintptr_t)cfg->port_field;
Y3_COM_PRINT = (int*)(uintptr_t)cfg->port_printer;
y3_insert_hooks(NULL);
memset(card_data, 0, sizeof(card_data));
dprintf("Y3: hook enabled\n");
dprintf("Y3: hook enabled (field port = %d, printer port = %d)\n", cfg->port_field, cfg->port_printer);
}
void y3_insert_hooks(HMODULE target) {
@ -322,12 +324,6 @@ CALL uint32_t API_GetErrorMessage(uint32_t errNo, char* szMessage,
CALL int* API_Connect(char* szPortName) {
dprintf("Y3: %s(%s)\n", __func__, szPortName);
if ((GetAsyncKeyState(0x11) & 0x8000) &&
(GetAsyncKeyState(0x42) & 0x8000)) {
dprintf("Y3: Ctrl+B is active!\n");
return NULL;
}
if (!y3_config.enable) {
return NULL;
} else {
@ -367,7 +363,6 @@ CALL uint32_t API_GetFirmName(int* hDevice) {
} else if (hDevice == Y3_COM_PRINT) {
result = convert_string_to_uint(y3_config.firm_name_printer);
dprintf("This Y3 device is PRINTER: %s\n", y3_config.firm_name_printer);
// DebugBreak();
} else {
dprintf("This Y3 device is UNKNOWN\n");
}
@ -385,7 +380,6 @@ CALL uint32_t API_GetTargetCode(int* hDevice) {
} else if (hDevice == Y3_COM_PRINT) {
result = convert_string_to_uint(y3_config.target_code_printer);
dprintf("This Y3 device is PRINTER: %s\n", y3_config.target_code_printer);
// DebugBreak();
} else {
dprintf("This Y3 device is UNKNOWN\n");
}
@ -450,13 +444,13 @@ CALL int API_GetCardInfo(int* hDevice, int numCards, struct CardInfo* pCardInfo)
pCardInfo[i].fY = paddingY + (row * cardWidth);
pCardInfo[i].fAngle = 0.0f;
pCardInfo[i].eCardType = TYPE0;
pCardInfo[i].eCardStatus = MARKER;
pCardInfo[i].eCardStatus = VALID;
pCardInfo[i].uID = 1000 + i;
pCardInfo[i].nNumChars = 0;
pCardInfo[0].ubChar0.Data = 0;
pCardInfo[0].ubChar1.Data = 0x4000;
pCardInfo[0].ubChar1.Data = 0;
pCardInfo[0].ubChar2.Data = 0;
pCardInfo[0].ubChar3.Data = 0x0; // 40
pCardInfo[0].ubChar3.Data = 0;
pCardInfo[0].ubChar4.Data = 0;
pCardInfo[0].ubChar5.Data = 0;
}

View File

@ -52,9 +52,6 @@ struct CardInfo {
struct y3_config {
bool enable;
uint8_t ws_enable;
uint16_t ws_port;
uint32_t ws_timeout;
float dll_version;
float firm_version;
@ -62,6 +59,8 @@ struct y3_config {
char firm_name_printer[5];
char target_code_field[5];
char target_code_printer[5];
uint8_t port_field;
uint8_t port_printer;
};
void y3_hook_init(const struct y3_config *cfg, HINSTANCE self);