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

Forward scancodes via egui-winit #2977

Closed
zkrising opened this issue May 7, 2023 · 5 comments · Fixed by #3649
Closed

Forward scancodes via egui-winit #2977

zkrising opened this issue May 7, 2023 · 5 comments · Fixed by #3649

Comments

@zkrising
Copy link
Contributor

zkrising commented May 7, 2023

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

I'm currently working on reimplementing an existing codebase using egui and eframe. For part of this application, the keybindings SHIFT+1, SHIFT+2, SHIFT+3, and so on... are used frequently. Changing these keybindings isn't really an option as all existing users of this software practically have it burned into their memory.

The problem here is that these inputs (shift+1, etc.) are instead passed as egui::Event::Text instead of the raw scancode information. Since Shift+2 might output Text('@') or Text('"'), it's not possible to hack around this by reading the characters sent to the device.

Furthermore, things like consume_shortcut don't work with shortcuts like this.

Describe the solution you'd like

I'd like for the virtual_keycode part of winit::event::KeyboardInput to be accessible somehow from the eframe input handler. That way, I can handle this logic myself. At the moment, it is converted to a key with translate_virtual_key_code and that results in the loss of a lot of information.

Describe alternatives you've considered

I've tried checking if Num1 is pressed and modifiers.shift is pressed, but that doesn't work as the input is coerced into "!".

It's possible that I'm missing some way already to access the raw winit:: events that already exists?

Additional context

I don't know much about the egui codebase or where this could nicely fit in as a feature. Strapping it onto egui::Event::Key could work, but seems unorthodox. Some sort of alternative place to access "raw" winit input would be potentially interesting too.

I'd be willing to work on this if there were some pointers on how this could fit in.

@edisno
Copy link

edisno commented May 8, 2023

I would also like this. To deploy egui apps on Android TV for example, I have been forced to vendor egui-winit to forward the scancodes to get all the special remote control buttons. Also if I remember correctly, winit's key code list is more complete than egui's. It would be nice to have the scancode, or a more complete keycode list in egui (copy winit's list for example). Of course the translation scancode -> key code should probably really happen in winit, but the key code list in egui must be extended or we must have access to the raw scan code I think.

@zkrising
Copy link
Contributor Author

zkrising commented May 8, 2023

I'd be very interested in that vendoring of egui-winit if you could make that public. Perhaps that could be shaped up into a PR for egui?

@sdasda7777
Copy link

Completely agree there should be a way to access the raw key information. There are many layouts that don't have keys A-Z, or 0-9. The current approach just assumes too much about user's machine and a more general one is clearly needed.

@emilk
Copy link
Owner

emilk commented Nov 28, 2023

Will be fixed in #3649

@parasyte
Copy link
Contributor

parasyte commented Dec 6, 2023

Seems related: #3266.

emilk added a commit that referenced this issue Dec 18, 2023
* Closes #3542
* Closes #2977
* Closes #3303

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
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

Successfully merging a pull request may close this issue.

5 participants