winit icon indicating copy to clipboard operation
winit copied to clipboard

linux: Send scancode instead of keycodes

Open rofferom opened this issue 3 years ago • 1 comments

X11 sends Linux keycodes that only match scancodes on a limited part of the keys. For example for extended scancodes, the values don't match.

showkey command can display a mapping:

  • https://linux.die.net/man/1/showkey

  • https://github.com/legionus/kbd/blob/master/src/showkey.c

  • [ ] Tested on all platforms changed

  • [ ] Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users

  • [ ] Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior

  • [ ] Created or updated an example program if it would help users understand this functionality

  • [ ] Updated feature matrix, if new features were added or implemented

rofferom avatar May 09 '22 13:05 rofferom

Thanks for taking the time to contribute (and apologies for taking so long to respond). Is this supposed to map Linux's keycodes to USB HID scancodes?

maroider avatar Jul 20 '22 11:07 maroider

Yes it is, but actually all implementations send "OS keycodes" rather than the raw HID scancode. My patch is incomplete, I'm not event using it anymore. Furthermore, it is a breaking change.

Maybe the correct fix would be to update the documentation of winit::event::ScanCode, because the values are more "OS/Hardware-dependent keyboard scan code".

What do you think about that ?

rofferom avatar Oct 17 '22 09:10 rofferom

What do you think about that?

Welp, I kind of forgot to reply before now. Basically, I think #2662 is preferable, since it would give you a proper platform-independent value instead of passing through the platform-dependent "scancode/keycode".

maroider avatar Jan 31 '23 05:01 maroider

Thanks for your patch, but as it was stated and as it was there for years I think, the keyboard API model proposed in #2662 (the patch is new, but the PRs doing it for dedicated platforms did dated since 2020/21) took care of it.

kchibisov avatar May 28 '23 17:05 kchibisov