-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: leafwing action for grab #55
base: main
Are you sure you want to change the base?
Conversation
Thanks for the PR! Adding input logic like combos to this crate feels slightly like scope creep. Maybe it could be doable by having an optional dependency on leafwing-input-manager instead? And allow arbitrary actions. Or have some other more flexible way of triggering moves? Perhaps events? I'm not saying it's a definitive no, just hoping we could avoid having this sort of general purpose input logic here, since it's difficult to get right and cover every use case. For instance, I believe the PR as it currently is interprets
As a valid key combo, which is probably not what the user would expect. |
Thanks for that feedback! Adding I'll update the PR with the optional leafwing actions shortly |
I've added a |
FWIW the example I committed using leafwing's chords also has that weird ordering behavior you described, but now the issue is no longer on this crate, which I think is a positive change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
I think we should probably settle on one default value for grab_buttons
, but otherwise this is fine.
src/lib.rs
Outdated
grab_buttons: vec![MouseButton::Left, MouseButton::Right, MouseButton::Middle], | ||
#[cfg(feature = "leafwing-input-manager")] | ||
grab_buttons: vec![], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... I'm not sure how I feel about changing the defaults based on a feature flag... could lead to subtle surprising behavior/bugs if you have multiple crates that depend on pancam?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to have the default be using standard input if one requested leafwing. I made a big change around this now (will detail it in the main thread).
src/lib.rs
Outdated
/// This is only available when the `leafwing-input-manager` feature is enabled | ||
#[derive(Actionlike, PartialEq, Eq, Hash, Clone, Copy, Debug, Reflect)] | ||
#[cfg(feature = "leafwing-input-manager")] | ||
pub enum Action { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Action
feels maybe a bit too broad and it will probably have to be aliased when used to make intention clear? Maybe prefixing it PanCamAction
is better?
(Honest question) :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think I agree. Initially I assumed Action
was "fine" because we're inside the bevy_pancam
module, but it's pretty common to use import the type directly (or sometimes even via ::*
) which would surely dirty up the namespace.
Yeah, it's quite a subtle thing. If I understand correctly, this is the issue to follow Leafwing-Studios/leafwing-input-manager#49 |
@johanhelsing I pushed a refactor around defaults that consists of a breaking change. The reason for it is I needed to move Like I said, it does make it breaking, because existing code won't work without some minor corrections (see what I did on the examples). |
Hey sorry for the late response, but i think i prefer it in a single component. I generally follow the approach of making the common use case dead simple, while making more advanced use cases possible. I think it's acceptable if leafwing users have to set |
I mean have the features be truly additive. Do you think it's possible? Maybe I'm asking too much, but just thought a not entirely thought through response is better than no response |
I can certainly do that, but I think it makes for a messier API. The idea that choosing leafwing uses leafwing to setup the default made more sense to me. Unfortunately, it did make it so I had to create a bundle type initializer instead of using the original. I'll sit down to work on game stuff later tonight, until then if you have any thoughts let me know. If I don't hear back I'll just do what you asked and revert back to the buttons vector default. |
Thanks, perhaps you're right. I can have another look Thursday or Friday alternatively |
e07cbd9
to
f3229fb
Compare
f3229fb
to
81439a8
Compare
I've update it against |
82c17bb
to
f1e9155
Compare
Allow using leafwing-input-manager for action binding. See
examples/leafwing.rs
.