Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upRefactor input to use shrev #385
Conversation
Xaeroxe
added
project: input
status: ready
type: improvement
labels
Sep 29, 2017
Xaeroxe
requested review from
omni-viral and
torkleyy
Sep 29, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Sep 29, 2017
Member
I'm in favor of making InputHandler optional, as @Rhuagh suggested (together with allowing custom bindings). Not sure if that's what this PR is doing, I'll have to review this tomorrow.
|
I'm in favor of making |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
I'll have a PR for this PR soon, that does that. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Xaeroxe
Sep 29, 2017
Member
Thanks for your PR @Rhuagh, I also had a few improvements of my own on top of your ideas. This is ready for review now.
|
Thanks for your PR @Rhuagh, I also had a few improvements of my own on top of your ideas. This is ready for review now. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jojolepro
Sep 29, 2017
Collaborator
Code looks fine to me. I asked questions on gitter, and I'll approve when I have the answers ;)
|
Code looks fine to me. I asked questions on gitter, and I'll approve when I have the answers ;) |
| } | ||
| /// Add a button to an action. | ||
| /// | ||
| /// This will insert a new binding between this action and the button. | ||
| - pub fn insert_action_binding<T: AsRef<str>>(&mut self, id: T, binding: Button) { | ||
| + pub fn insert_action_binding(&mut self, id: AC, binding: Button) { |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
omni-viral
Sep 29, 2017
Member
I think it can be less restrictive
pub fn insert_action_binding<A>(&mut self, id: AC, binding: Button)
where A: Hash + Eq + Into<AC>,
AC: Borrow<A>
{
For AC = String id can type of type &str with allocation only if not present in map yet.
omni-viral
Sep 29, 2017
Member
I think it can be less restrictive
pub fn insert_action_binding<A>(&mut self, id: AC, binding: Button)
where A: Hash + Eq + Into<AC>,
AC: Borrow<A>
{
For AC = String id can type of type &str with allocation only if not present in map yet.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Rhuagh
Sep 29, 2017
Member
I considered how that could be done, couldn't figure it out in the time I had, but our almighty omni figured it out :)
I don't foresee this method being called very often, but being less restrictive is always good.
Rhuagh
Sep 29, 2017
Member
I considered how that could be done, couldn't figure it out in the time I had, but our almighty omni figured it out :)
I don't foresee this method being called very often, but being less restrictive is always good.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
r? @omni-viral |
| @@ -41,13 +41,13 @@ where | ||
| fn run(&mut self, (input, mut handler, mut output): Self::SystemData) { | ||
| match input.read(&mut self.reader) { | ||
| - Ok(data) => for d in data { | ||
| + Ok(EventReadData::Data(data)) => for d in data { | ||
| if let &Event::WindowEvent { ref event, .. } = d { | ||
| handler.send_event(event, &mut *output); | ||
| } | ||
| }, | ||
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Rhuagh
Sep 29, 2017
Member
Might want a variant for EventReadData::Overflow that do the same things as above, and log a warning ?
Rhuagh
Sep 29, 2017
Member
Might want a variant for EventReadData::Overflow that do the same things as above, and log a warning ?
Xaeroxe
requested a review
from
Aceeri
Sep 29, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Xaeroxe
Sep 29, 2017
Member
@Aceeri I'd like you to review the InputEvent enum specifically and tell me if you think that gives you enough input data to make the UI framework.
|
@Aceeri I'd like you to review the InputEvent enum specifically and tell me if you think that gives you enough input data to make the UI framework. |
jojolepro
approved these changes
Sep 30, 2017
You have my seal of approval! https://media.giphy.com/media/uTv1bQNRPFYTS/giphy.gif
Side note: Supporting controllers + VR headset positional data is a must have for the future.
Xaeroxe
and others
added some commits
Sep 26, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Controllers and vr headsets require support in winit first, but yes. |
| -pub struct Bindings { | ||
| - pub(super) axes: HashMap<String, Axis>, | ||
| - pub(super) actions: HashMap<String, SmallVec<[Button; 4]>>, | ||
| +pub struct Bindings<AX, AC> where AX: Hash + Eq, AC: Hash + Eq { |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Xaeroxe
Sep 30, 2017
Member
@Rhuagh winit has stated that is out of scope: tomaka/winit#119 so we'll need another crate that can gather input for that.
|
@Rhuagh winit has stated that is out of scope: tomaka/winit#119 so we'll need another crate that can gather input for that. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Looks great! bors r+ |
Xaeroxe commentedSep 29, 2017
Problem with the current InputHandler: It queries for if a key was pressed or release
ThisFramewhich isn't very helpful to systems and state functions that don't trigger every frame. Solution: Integrate shrev with the InputHandler so users can acquire and useReaderIDs with anEventHandler<InputEvent>specs resource. More enhancements to the input system are on the way, but I just wanted to share this much since it is ready.Notice: This PR also sneaks in a few other small improvements, such as Scancode buttons, and some new
new()constructors.cc @Rhuagh @jojolepro