add card connect support (#923)

There are no servers to test this, but:

* touch, touch with mouse
* in theory card reader should work
* printer works (RGB, front and back)
* test/service button, lights

What is (painfully) missing:
* windowed mode

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
bicarusandCopilot authored and GitHub committed 2026-10-11 01:04:14 -07:00
1 parent cf5d87d4d5
commit fdc7adff7f
22 files changed
+1358 -79

No files matched your search

+2 -5
View File
@@ -46,17 +46,14 @@ MessageData *ACIODeviceEmu::create_msg(uint8_t addr, uint16_t code, uint8_t pid,
}
// allocate data
auto data_raw = new uint8_t[MSG_HEADER_SIZE + data_size];
auto msg = new MessageData {};
// set header
auto msg = (MessageData *) &data_raw[0];
set_header(msg, addr, code, pid, (uint8_t) data_size);
// set data
if (data) {
memcpy(data_raw + MSG_HEADER_SIZE, data, data_size);
} else {
memset(data_raw + MSG_HEADER_SIZE, 0, data_size);
memcpy(msg->cmd.raw, data, data_size);
}
// return prepared message
+8 -1
View File
@@ -14,15 +14,20 @@ bool acioemu::ACIOHandle::open(LPCWSTR lpFileName) {
return false;
}
std::lock_guard<std::mutex> lock(mutex);
log_info("acioemu", "Opened {} (ACIO)", ws2s(com_port));
// ACIO device
acio_emu.add_device(new acioemu::ICCADevice(false, true, icca_node_count));
if (!initialized) {
acio_emu.add_device(new acioemu::ICCADevice(false, true, icca_node_count));
initialized = true;
}
return true;
}
int acioemu::ACIOHandle::read(LPVOID lpBuffer, DWORD nNumberOfBytesToRead) {
std::lock_guard<std::mutex> lock(mutex);
auto buffer = reinterpret_cast<uint8_t *>(lpBuffer);
// read from emu
@@ -42,6 +47,7 @@ int acioemu::ACIOHandle::read(LPVOID lpBuffer, DWORD nNumberOfBytesToRead) {
}
int acioemu::ACIOHandle::write(LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite) {
std::lock_guard<std::mutex> lock(mutex);
auto buffer = reinterpret_cast<const uint8_t *>(lpBuffer);
// write to emu
@@ -64,6 +70,7 @@ int acioemu::ACIOHandle::device_io(
}
size_t acioemu::ACIOHandle::bytes_available() {
std::lock_guard<std::mutex> lock(mutex);
return acio_emu.bytes_available();
}
+4
View File
@@ -1,5 +1,7 @@
#pragma once
#include <mutex>
#include "acioemu/acioemu.h"
#include "hooks/devicehook.h"
@@ -12,6 +14,8 @@ namespace acioemu {
uint8_t icca_node_count;
acioemu::ACIOEmu acio_emu;
std::mutex mutex;
bool initialized = false;
public:
ACIOHandle(LPCWSTR lpCOMPort, uint8_t iccaNodeCount = 2);
+15 -9
View File
@@ -46,9 +46,9 @@ ICCADevice::ICCADevice(bool flip_order, bool keypad_thread, uint8_t node_count)
// keypad thread for faster polling
if (keypad_thread) {
this->keypad_thread = new std::thread([this]() {
this->keypad_thread = std::jthread([this](std::stop_token stop_token) {
timeutils::PreciseSleepTimer timer;
while (this->cards) {
while (!stop_token.stop_requested()) {
for (int unit = 0; unit < this->node_count; unit++) {
this->update_keypad(unit, false);
}
@@ -61,11 +61,15 @@ ICCADevice::ICCADevice(bool flip_order, bool keypad_thread, uint8_t node_count)
ICCADevice::~ICCADevice() {
// stop thread
delete keypad_thread;
if (keypad_thread.joinable()) {
keypad_thread.request_stop();
keypad_thread.join();
}
// delete cards in array
for (int i = 0; i < node_count; i++) {
delete cards[i];
delete[] cards[i];
delete[] keypad_last[i];
}
// delete the rest
@@ -107,7 +111,7 @@ bool ICCADevice::parse_msg(MessageData *msg_in,
if (avs::game::is_model({"LDJ", "TBS", "UJK", "XIF"}) ||
games::sdvx::is_valkyrie_model()) {
this->set_version(msg, 0x3, 0, 1, 7, 0, "ICCA");
} else if (avs::game::is_model("VFG")) {
} else if (avs::game::is_model({"VFG", "TCS"})) {
this->set_version(msg, 0x3, 0, 1, 7, 0, "ICCB");
} else {
this->set_version(msg, 0x3, 0, 1, 6, 0, "ICCA");
@@ -160,7 +164,7 @@ bool ICCADevice::parse_msg(MessageData *msg_in,
break;
case 0x12: // EJECT
if (this->cards[unit] != nullptr) {
delete this->cards[unit];
delete[] this->cards[unit];
}
this->cards[unit] = nullptr;
this->hold[unit] = false;
@@ -267,7 +271,7 @@ bool ICCADevice::parse_msg(MessageData *msg_in,
memcpy(msg->cmd.raw, this->cards[unit], 8);
// delete card
delete this->cards[unit];
delete[] this->cards[unit];
this->cards[unit] = nullptr;
this->hold[unit] = false;
}
@@ -326,7 +330,9 @@ bool ICCADevice::parse_msg(MessageData *msg_in,
}
//log_info("icca", "counter[{}] = {}", unit, this->counter[unit]);
auto msg = this->create_msg_status(msg_in, this->counter[unit]);
// Card Connect waits for a successful reply without retrying this command.
auto msg = this->create_msg_status(
msg_in, avs::game::is_model("TCS") ? 0 : this->counter[unit]);
write_msg(msg, response_buffer);
delete msg;
break;
@@ -363,7 +369,7 @@ void ICCADevice::update_card(int unit) {
if (difftime(t_now, this->cards_time[unit]) >= 10.f) {
if (this->cards[unit] != nullptr) {
delete this->cards[unit];
delete[] this->cards[unit];
}
this->cards[unit] = nullptr;
this->hold[unit] = false;
+1 -1
View File
@@ -17,7 +17,7 @@ namespace acioemu {
private:
bool type_new;
bool flip_order;
std::thread *keypad_thread;
std::jthread keypad_thread;
std::mutex keypad_mutex;
uint8_t **cards;
time_t *cards_time;