Add input support; extract glfw crate.#95
Open
tychedelia wants to merge 6 commits intoprocessing:mainfrom
Open
Add input support; extract glfw crate.#95tychedelia wants to merge 6 commits intoprocessing:mainfrom
tychedelia wants to merge 6 commits intoprocessing:mainfrom
Conversation
Contributor
|
So many match statements 🌀 🌀 Questions:
Excitement: |
Member
Author
For Processing4, we also use GLFW, so they'll just call our input APIs to forward those input events from GLFW Java to Bevy.
Yes! It should be trivial to enable picking now. I'll just have to do some research into prior art here in the processing world. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #41
Adds two new crates:
processing_input, which handles extracting input data from Bevy when requested.processing_glfw, which is now just a common crate for GLFW related stuff, rather than having it separately versioned in examples and pyo3.The goal here is to use Bevy's input machinery, rather than directly going from GLFW to processing. As such, when we poll events from GLFW, we feed them into Bevy as regular Bevy input events. We "flush" input by running the
PreUpdateschedule which allows Bevy's internal input bookeeping to populate the respectiveButtonInput, etc., resources.One thing to note is that processing is kind of weird in that many input states are not reset every frame. So if you check for a pressed key it will remain "pressed" until a new key is pressed. For example, see the docs here: https://p5js.org/reference/p5/keyPressed/. As such, we need to track the most recent key press separately.
Something else worth noting is the strategy for allowing users to reference stuff like
mouse_xin their Python sketches, wheremouse_xis magically updated every frame. To do so, we set those as global variables in the scope of the draw function. This strategy likely has some gaps, and may need to be expanded on later.