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

Is there interest to use semantic scan code? #1904

Closed
stephanemagnenat opened this issue Apr 7, 2021 · 2 comments
Closed

Is there interest to use semantic scan code? #1904

stephanemagnenat opened this issue Apr 7, 2021 · 2 comments
Labels
S - enhancement Wouldn't this be the coolest?

Comments

@stephanemagnenat
Copy link

stephanemagnenat commented Apr 7, 2021

I am working on a GUI library in Rust, aiming at making it backend-independent. So, my library defines abstract events, to be filled by the backend-specific data. For the scan code, I found the scancode crate, based on libSDL2, itself based on the USB HID standard. This seems a good way to encode scan codes, but unfortunately the scancode crate seems unmaintained, and I saw that winit currently uses a u32 for the scan code.

So I'm wondering whether there is interest to:

  • use semantic scancode matching the USB HID standard, possibly based on the scancode crate,
  • move this and the VirtualKeyCode struct into their own crate as part of rust-windowing.
@stephanemagnenat stephanemagnenat changed the title Is there interest to move VirtualKeyCode into its own crate? Is there interest to use semantic scan code? Apr 7, 2021
@maroider
Copy link
Member

maroider commented Apr 7, 2021

* use semantic scancode matching the USB HID standard, possibly based on the `scancode` crate,

We're already working on implementing something like this (see #1806 and src/event.rs and src/keyboard.rs in #1788).

Do note that USB HID scancodes don't get forwarded to applications, as far as I'm aware.

move this and the VirtualKeyCode struct into their own crate as part of rust-windowing.

I have had thoughts along these lines myself, and we did consider using keyboard-types in Winit while discussing things in #753, but we decided to use our own enumerations and structs for the time being. There was also an attempt to pull out other types into a separate crate (#1298), but that effort has largely stalled.

I have been intending to bring this up again, but I'm currently trying to focus on implementing the API in #753/#1788.

@stephanemagnenat
Copy link
Author

stephanemagnenat commented Apr 7, 2021

Thank you for the answer, and pointing out the keyboard-types crate. Hopefully at some point the ecosystem converges to a common crate with well-accepted tradeoffs :-)

@maroider maroider added the S - enhancement Wouldn't this be the coolest? label Jul 12, 2021
kchibisov added a commit that referenced this issue May 28, 2023
Overhaul the keyboard API in winit to mimic the W3C specification
to achieve better crossplatform parity. The `KeyboardInput` event
is now uses `KeyEvent` which consists of:

  - `physical_key` - a cross platform way to refer to scancodes;
  - `logical_key`  - keysym value, which shows your key respecting the
                     layout;
  - `text`         - the text produced by this keypress;
  - `location`     - the location of the key on the keyboard;
  - `repeat`       - whether the key was produced by the repeat.

And also a `platform_specific` field which encapsulates extra
information on desktop platforms, like key without modifiers
and text with all modifiers.

The `Modifiers` were also slightly reworked as in, the information
whether the left or right modifier is pressed is now also exposed
on platforms where it could be queried reliably. The support was
also added for the web and orbital platforms finishing the API
change.

This change made the `OptionAsAlt` API on macOS redundant thus it
was removed all together.

Co-Authored-By: Artúr Kovács <kovacs.artur.barnabas@gmail.com>
Co-Authored-By: Kirill Chibisov <contact@kchibisov.com>
Co-Authored-By: daxpedda <daxpedda@gmail.com>
Fixes: #2631.
Fixes: #2055.
Fixes: #2032.
Fixes: #1904.
Fixes: #1810.
Fixes: #1700.
Fixes: #1443.
Fixes: #1343.
Fixes: #1208.
Fixes: #1151.
Fixes: #812.
Fixes: #600.
Fixes: #361.
Fixes: #343.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S - enhancement Wouldn't this be the coolest?
Development

No branches or pull requests

2 participants