Skip to content
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

Multiple Actions with the same KeyCode #45

Open
nic96 opened this issue Dec 3, 2020 · 5 comments
Open

Multiple Actions with the same KeyCode #45

nic96 opened this issue Dec 3, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@nic96
Copy link

nic96 commented Dec 3, 2020

Currently it's not possible to have multiple actions use the same KeyCode. Would this be possible to implement?

@PradeepKumarRajamanickam
Copy link
Owner

Hey @nic96,
I am assuming you want to use the same keycode for different action depending on the view eg. game view will map key to one action and inventory view will map the same key to another. You can use stack to push and pop binding.

eg,

// utility to get bindings from Iron file, you can also create this object by code
let new_binding = Kurinji::get_bindings_from_ron("xyz.ron");
kurinji.push(new_binding); // push it to stack
....
kurinji.pop(); // to return to previous state

@nic96
Copy link
Author

nic96 commented Dec 5, 2020

No, that's not really what I'm looking for. In my case it's actually desired that both actions would be active at the same time or at least it wouldn't matter. I guess what would need to be done is bind and action to a key instead of a key to an action. If that makes any sense, but anyway if this is not something you intend to support that's fine.

@PradeepKumarRajamanickam
Copy link
Owner

PradeepKumarRajamanickam commented Dec 5, 2020

Could you share an example? I would like to know in which scenario it might be useful.

@nic96
Copy link
Author

nic96 commented Dec 5, 2020

Let's say you have a two guns on a vehicle. I'd want to allow either individual keys to fire the guns or a single key to fire both at once. Depending on a user's preference. Godot allows it and has multiple actions by default that have the same keys bound to it. It's also useful for UI, I mean bevy doesn't have much for UI at the moment, but one use case is using Space for both ui_select and also use Space key ui_accept.

@PradeepKumarRajamanickam PradeepKumarRajamanickam added the enhancement New feature or request label Dec 9, 2020
@nic96
Copy link
Author

nic96 commented Jan 31, 2021

I'm currently using my own simple input map implementation and in it I'm using multimap. This allows for both multiple actions with a single key binding and multiple key bindings for a single action. I'm using the bitflags crate for action states so I can do a union across all the action states of the various keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants