add pressed_btns class property #11
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.
While adding a "chording" functionality to the minesweeper application I realized that the USB_Host_Mouse library didn't provide a way of determining if a mouse button was being held down or detecting when it is released.
By making the pressed_btns variable an accessible class property the calling application can now determine the current state of the button pushes after each call to the update method.
The start of the mouse update loop for minesweeper would be modified to the following which allows both the x,y coordinates and the current mouse button status to be monitored independently:
Edit: Without these changes, if there is no mouse data (the mouse isn't moved and the button status doesn't change) when the update method is called a value of None is returned for the button values and the current state of the buttons is lost.
Edit: If the application is only interested in capturing button pushes and not the held or released status then the return value can be used as it had been before this update.