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

Making Inputs Flexible #173

Open
aevyrie opened this issue Apr 6, 2023 · 5 comments
Open

Making Inputs Flexible #173

aevyrie opened this issue Apr 6, 2023 · 5 comments

Comments

@aevyrie
Copy link
Contributor

aevyrie commented Apr 6, 2023

Currently, bevy_egui uses bevy's input stream directly:

pub fn process_input_system(

This makes some assumptions that are difficult to work around. I'd like to request that intermediate events are used, so users can supply their own events, while not having to rewrite and maintain their own version of the process_input_system.

The biggest limitations this would unlock are:

  • Input mocking (record and replay inputs for integration testing)
  • Controller-driven mouse cursors
  • Universal input remapping, using something like leafwing input manager. For example with the controller, you might want "A" to be the left mouse down for the UI, this would allow users to specify the inputs in a central input mapping, and feed the events into bevy_egui.
  • Diegetic UI - I've been playing with making a diegetic UI (a ui screen that exists in the 3d world) using new features in bevy_mod_picking, however I need to be able to pass in cursor events relative to the virtual, raycasted pointer onto a screen in the world.

The way I'd see this working is defining an event type for mouse movement and clicks, and reading this event stream in process_input_system. bevy_egui would provide a small disable-able system to forward bevy events to keep the behavior identical to how it works now. Users could then disable this small event forwarding system, and send those events themselves if they need to. Using events would make this fast, and wouldn't have any of the issues associated with command sync points.

If you see the merits in this design, I'd be happy to do the implementation!

@mvlabat
Copy link
Owner

mvlabat commented Apr 7, 2023

Hi! I absolutely love the idea and will happily accept a PR implementing this. Input mocking, diegetic UI sound like very good use-cases for this. I guess, for the latter #163 might also be relevant.

@aevyrie
Copy link
Contributor Author

aevyrie commented Apr 7, 2023

Okay, great! Are there any inputs besides mouse movement and mouse clicks that might need to be remappable? Maybe if there are some hardcoded hotkeys, like copy and paste?

@mvlabat
Copy link
Owner

mvlabat commented Apr 7, 2023

I don't see a clear use case for keyboard input remapping yet, so I'd probably keep it simple until we have such a use case; but at the same time, I don't mind this functionality if it's not a significant effort to implement it.

@aevyrie
Copy link
Contributor Author

aevyrie commented Apr 7, 2023

I don't see a clear use case for keyboard input remapping yet

It's the same issue. If someone wants to trigger this event (let's say with the gamepad, for example), right now it is hardcoded. The goal here would be to tie all of these to some BevyEguiInputEvent or something. Any place that currently looks at the bevy keyboard/mouse/touch inputs would be replaced by an eventreader with the equivalent bevy_egui event.

@argxentakato
Copy link

I would strongly prefer this feature. Bevy itself has a weak UI with weak functionality, so this plugin helps.

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

No branches or pull requests

3 participants