ref: 2783a8c62a74b253d5974d2aa7eba8c515adc88b
parent: e5df91377545372b1481a8d65777d665054140d9
parent: a449d9d5a24fbeeaf3e6fcde2d6af93f59eee32f
author: Jonne Kokkonen <jonne.kokkonen@gmail.com>
date: Fri Jul 1 08:46:48 EDT 2022
Merge pull request #81 from smootalicious/main Make zerobyte detection work for hardware M8.
--- a/main.c
+++ b/main.c
@@ -165,7 +165,6 @@
// get current inputs
input_msg_s input = get_input_msg(&conf);
- if (input.value != 0) zerobyte_packets = 0; // don't try to detect disconnect until user stops pressing buttons
switch (input.type) {case normal:
if (input.value != prev_input) {@@ -233,16 +232,12 @@
zerobyte_packets++;
if (zerobyte_packets > conf.wait_packets) {// i guess it can be assumed that the device has been disconnected
- if (conf.wait_for_device) {- zerobyte_packets = 0; // reset so we dont constantly reset the device if waiting
- run = WAIT_FOR_DEVICE;
- close_serial_port(port);
- port = NULL;
- break;
- } else {- SDL_LogCritical(SDL_LOG_CATEGORY_ERROR,"Device disconnect detected.");
- run = QUIT;
- }
+ zerobyte_packets = 0; // reset so we dont constantly reset the device if waiting
+ run = WAIT_FOR_DEVICE;
+ close_serial_port(port);
+ port = NULL;
+ // we'll make one more loop to see if the device is still there but just sending zero bytes
+ // if it doesn't get detected when resetting the port, it will disconnect
}
break;
}
--
⑨