Refactor input handling and add windowBlurred event #135
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.
Introduces the 'windowBlurred' event to the core event list and refactors input event handling for improved pointer, mouse, and touch management. Adds a resetInput method, uses a Set for pressed mouse buttons, ensures pointer capture/release, and streamlines event listener attachment for better reliability and maintainability.
windowBlurred
This is an event that is called when we tab out of the current browser tab. Useful if say we are doing something complex and want to pause the game or stop logic until the user returns.
resetInput
This is another feature that is more of a quality of life thing. We can at anytime remove all input currently held. Pairs nicely with windowBlurred.
I reworked the logic for mouse presses and specifically events. Before hand there was some odd logic with holding mouse 1 or 2 and pressing the other button. For example if you hold mouse 1 and tap mouse 2 we dont release
mouseIsPressed
. But if you hold mouse 2 then tap mouse 1 we do release!So the logic here makes the mouse down parity p5. Where if you hold 2 mouse buttons releasing 1 causes
mouseIsPressed
to be false.Also added some small touch ups.
Also updated
_updateTouches
to be more modern js code 😄