From 99b88aef2236d49cd55ad7344583cf9f5455bdcc Mon Sep 17 00:00:00 2001 From: nat Date: Wed, 10 Jan 2024 08:08:25 -0800 Subject: [PATCH] aimeio: less verbose, handle console created case --- aimeio/aimeio.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/aimeio/aimeio.c b/aimeio/aimeio.c index 2cb9b3c..f876d12 100644 --- a/aimeio/aimeio.c +++ b/aimeio/aimeio.c @@ -22,11 +22,15 @@ uint16_t aime_io_get_api_version(void) HRESULT aime_io_init(void) { int ret; - - AllocConsole(); - SetConsoleTitle("aimeio-pcsc"); FILE* fp; - freopen_s(&fp, "CONOUT$", "w", stdout); + + ret = AllocConsole(); + + // someone might already allocated a console - seeing this on fufubot's segatools + if (ret != 0) { + // only when we allocate a console, we need to redirect stdout + freopen_s(&fp, "CONOUT$", "w", stdout); + } ctx = aimepcsc_create(); if (!ctx) { @@ -57,7 +61,6 @@ HRESULT aime_io_nfc_poll(uint8_t unit_no) } memset(&data, 0, sizeof(data)); - printf("aimeio-pcsc: poll.\n"); ret = aimepcsc_poll(ctx, &data);