From a1a67697c456921325b4a0f948e401c6e04d89bd Mon Sep 17 00:00:00 2001 From: icex2 Date: Wed, 6 Jan 2021 19:31:32 +0100 Subject: [PATCH] iidxio-bio2: Properly fix flushing on shutdown Moved this hardware/iidxio impl specific logic from vigem-iidxio to iidxio-bio2. Other hardware impls should follow this if necessary to ensure a transparent and deterministic interface (as good as possible) --- src/main/iidxio-bio2/iidxio.c | 9 +++++++++ src/main/vigem-iidxio/main.c | 22 +++------------------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/main/iidxio-bio2/iidxio.c b/src/main/iidxio-bio2/iidxio.c index a0ed1cb..8169baf 100644 --- a/src/main/iidxio-bio2/iidxio.c +++ b/src/main/iidxio-bio2/iidxio.c @@ -166,6 +166,15 @@ bool iidx_io_init( void iidx_io_fini(void) { + // Pushing some final state before closing the IO to the actual outputs, e.g. lights on/off + // can be a bit finicky. Do a few polls to "enforce"/flush this final state + for (uint8_t i = 0; i < 3; i++) { + iidx_io_ep1_send(); + iidx_io_ep2_recv(); + + Sleep(10); + } + running = false; while (processing_io) { diff --git a/src/main/vigem-iidxio/main.c b/src/main/vigem-iidxio/main.c index 2247602..54ebc54 100644 --- a/src/main/vigem-iidxio/main.c +++ b/src/main/vigem-iidxio/main.c @@ -251,23 +251,7 @@ static void _all_lights_off() iidx_io_ep1_set_panel_lights(0); iidx_io_ep1_set_top_lamps(0); iidx_io_ep1_set_top_neons(false); -} - -static void _all_lights_off_shutdown() -{ - // Cleanup, turn all lights off - _all_lights_off(); - - // Depending on the IO, pushing the state to the actual outputs, e.g. lights on/off - // can be a bit finicky. Do a few times to "enforce" the state - for (uint8_t i = 0; i < 3; i++) { - iidx_io_ep1_send(); - // Required to handle iidxio-ezusb specific quirks with flushing 16seg text - iidx_io_ep2_recv(); - iidx_io_ep3_write_16seg(" "); - - Sleep(10); - } + iidx_io_ep3_write_16seg(" "); } int main(int argc, char **argv) @@ -418,8 +402,6 @@ int main(int argc, char **argv) Sleep(1); } - _all_lights_off_shutdown(); - for (uint8_t i = 0; i < JOYSTICKS_NUM; i++) { vigem_target_remove(client, pad[i]); vigem_target_free(pad[i]); @@ -429,6 +411,8 @@ int main(int argc, char **argv) Sleep(1000); + _all_lights_off(); + iidx_io_fini(); return 0;