May-27-2022, 08:12 PM
If you don't get get data within 1 second the read gives up and returns an empty buffer. It is possible that you could also time out while reading data and get a partial buffer. You might also get a transmission error that results in bad data. I would cover all three possibilities by wrapping an exception handler around the conversion and only updating the mouse position when you successfully read a new value.