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

API to view raw winit events (particularly keyboard inputs) #3266

Closed
HactarCE opened this issue Aug 20, 2023 · 6 comments
Closed

API to view raw winit events (particularly keyboard inputs) #3266

HactarCE opened this issue Aug 20, 2023 · 6 comments

Comments

@HactarCE
Copy link
Contributor

HactarCE commented Aug 20, 2023

Is your feature request related to a problem? Please describe.

In Hyperspeedcube (repo, website, online demo) the user has the ability to bind keys to scancodes rather than keycodes, which use my key-names crate to abstract over platform specifics. I would love to use eframe for Hyperspeedcube, but I need access to low-level keyboard input information. I even want platform-specific keys, so that users can bind every key on their keyboard for speedsolving.

This is also useful for first-person games or 3D movement controls where position on the keyboard matters more than keycode, so controls should use scancodes rather than keycodes to be more keyboard-layout-independent.

Describe the solution you'd like

I would like some API for accessing raw winit events, or at least keyboard events, when using eframe with winit. These events will necessarily be platform-specific, but that's ok as it's an escape hatch like EventLoopBuilderHook.

For maximum flexibility, this could be a handler that can alter, delete, or construct winit events to be sent to eframe, but really all I need is to see them at some point during the frame so that I can do my own handling. Some of my users have wanted to bind the tab key, but this is reserved in egui for accessibility reasons. If I could, I'd add an option to my application to override the tab key in certain contexts if the user has bound a custom action to it.

Describe alternatives you've considered

  • Currently I'm using pure egui+winit+wgpu and handling all the glue code myself just because of this one essential feature.
  • Alternatively, egui could provide scancode information in its own data structures for handling input. This is not my preferred option, as it's really hard to support everything I want on all platforms, and I need features that egui doesn't provide such as platform-dependent key names and keyboard layout information (which is only accessible on Windows and Linux).
  • egui could also fully embrace and/or adopt the key-names crate with all its features. I didn't write that crate with widespread use in mind (it's not even on crates.io) but that is an option.
@HactarCE HactarCE changed the title API to view raw winit events (particularly keyboard) API to view raw winit events (particularly keyboard inputs) Aug 20, 2023
@HactarCE
Copy link
Contributor Author

If you have an idea of what the API should look like, I'd be happy to implement it and submit a PR.

@HactarCE
Copy link
Contributor Author

Perhaps this should also wait on #2023

@HactarCE
Copy link
Contributor Author

HactarCE commented Feb 20, 2024

This has been solved as part of #2799 #2977. Thank you so much! I can now switch my app to using eframe, and gain all the benefits it provides. 😀

@parasyte
Copy link
Contributor

@HactarCE That links to an unresolved bug. Is it the correct reference for what solves this?

@HactarCE
Copy link
Contributor Author

🤦 I mixed up the numbers. Should've been #2977.

@HactarCE
Copy link
Contributor Author

After some more careful reading of the docs, this is not resolved by the recent updates. In particular, I can't distinguish numpad keys, and scan codes aren't available on web. It might seem nice to keep physical and logical key the same but they are fundamentally very different things and should be treated as such; they just happen to align most of the time on QWERTY.

I'll still keep this closed in favor of #3653

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

2 participants