Fruitjam Match3: Improve mouse compatibility #3164
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When some mice, including the inexpensive mouse from the Adafruit shop, were used with the Match3 game, mouse movement was restricted to the X axis only and that motion was controlled by moving the mouse in the Y direction.
For some reason these mice were reading data buffers of length 8 but apparently have the data format of a 4 byte buffer read.
This PR adds logic to check 8 byte buffer reads and see if the first 50 reads from the mouse show exactly 0 movement in the Y direction. If it does, the mouse is assume to be supplying the buffer data in the 4 byte format.
The read timeout was also increased from 10 to 20 milliseconds since the 10 mSec was apparently too fast for the Adafruit mouse I was testing with.
I tested with the Adafruit Mouse as well as a cheap Logitech gaming mouse and they both worked well with these changes.
For the mice that need the data format change, the 50 reads takes a couple seconds so the mouse initially is stuck just moving left and right but once the format switches it has normal motion control.