Leafwing-Studios / leafwing-input-manager

A straightforward stateful input manager for the Bevy game engine.
Apache License 2.0
682 stars 105 forks source link

Detect currently active input device #242

Open TimJentzsch opened 2 years ago

TimJentzsch commented 2 years ago

What problem does this solve?

As a user, I want to have UI overlays that fit the input device I'm currently using (e.g. either shortcut keys when I'm using my mouse and keyboards, or gamepad glyphs if I'm using a gamepad).

As a developer, I want an easy way to detect which device is currently active, so that I can adapt my UI accordingly.

What solution would you like?

I think the easiest way would be to provide a Resource which contains an enum indicating the currently active device. This enum should be updated by the plugin automatically.

Ideally, for controllers it would even identify the device type, e.g. if it's an Xbox of PS controller, so that the glyphs can be shown accordingly. But I'm not sure if that's possible.

[Optional] How could this be implemented?

[Optional] What alternatives have you considered?

This could also be handled manually by the developer. I think a built in solution that works well would be nice though. This makes it easier to add proper gamepad support.

Related work

alice-i-cecile commented 2 years ago

I'm on board with this as a feature :) Ideally it should be toggleable via plugin settings.

Ideally, for controllers it would even identify the device type, e.g. if it's an Xbox of PS controller, so that the glyphs can be shown accordingly. But I'm not sure if that's possible.

This is likely to require examining information provided by glam. I'm not sure if they currently expose this information; it may require a PR upstream.

Definitely split this part out into future work :)

TimJentzsch commented 2 years ago

Ideally it should be toggleable via plugin settings.

Why is this necessary? It would already be optional to use the provided resource. Or is it to save resources by disabling the updating system?

alice-i-cecile commented 2 years ago

The latter :) Most desktop apps don't care about this functionality, so it's good to split it out in some way.

Perhaps an entirely seperate plugin?