-
Notifications
You must be signed in to change notification settings - Fork 63
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
Input event still passed down to the game when I type inside the console. #2
Comments
I don't actually now, if you could figure that out I can fix it, or you can open a PR yourself :) |
If anyone else comes across this, I worked around this in my game by handling input only if the console is closed, like this: fn handle_input(
mut events: EventReader<KeyboardInput>,
console_open: Res<ConsoleOpen>,
) {
if !console_open.open {
for event in events.iter() {
if let ElementState::Pressed = event.state {
if let Some(KeyCode::T) = event.key_code {
// handle pressing T
}
}
}
}
} I quickly checked to see if this method could also work with leafwing-input-manager, and my best guess at how to temporarily disable the input manager is release_all, though I haven't tested it. |
Okay I think a possible solution would be creating a system which users can opt-in for which "consumes" all keyboard events after the i.e.: pub fn block_inputs_on_console_focus(
mut events: ResMut<Events<KeyboardInput>>,
console_open: Res<ConsoleOpen>
){
if console_open.open {
events.drain().for_each(drop)
}
} I don't think we should make this a default though since removing all keyboard inputs downstream is very imposing, @brandon-reinhart what do you think ? |
Can confirm that release_all() is a valid approach for preventing game input while the console is open, assuming your main game input is routed through leafwing_input_manager: I have a plugin that adds the console plugin and custom commands, and clears input before CoreStage::Update:
Adding my two cents on input exclusivity, dedicated ad-hoc solutions (such as the |
FWIW, leafwing-input-manager has an optional feature Edit: I've just noted a regression where the feature flag no longer works to prevent this behavior. I'll update this comment if I discover a fix. |
You should be able to handle this in your own input handling by simply checking |
…gestion-completion Revert "Argument suggestion completion"
Hi. I was able to smack this bad boy into my game and it is working correctly. My problem is that if I have controls assigned to certain characters for example 'A', 'D' etc.. The game still registers this.
Is that possible to block the capturing of the input events to the game when the terminal is up?
The text was updated successfully, but these errors were encountered: