livesplit-core icon indicating copy to clipboard operation
livesplit-core copied to clipboard

Add a way to resolve `KeyCode` according to the Keyboard Layout

Open CryZe opened this issue 4 years ago • 0 comments

KeyCode is based on a Keyboard layout independent web specification. This is great as this means the hotkeys will always refer to a very specific key on the Keyboard no matter the operating system or currently active layout. However when visualizing these in some user interface, the user would prefer to see the key as it is on their keyboard.

I have a WIP implementation for all the platforms, but there are some issues:

  • For Linux we need an open X11 connection.
  • In the web the API is actually async, and I don't want to expose it that way in Rust.

I initially started implementing this as a free method on KeyCode but it will likely for the reasons above need to be a method on Hook / HotkeySystem. The reason for this is that for the web we need a point where we start up the Promise that loads the layout map, such that later when we call the resolve method, the result would be available (hopefully, if not we'll just use the fallback implementation, but it resolves basically immediately on the next tick). The Hook / HotkeySystem constructor is the ideal point in time for this. Also since we need an open X11 connection on Linux, we can just reuse the one we already use for the hotkey handling. Thus implementing this as a method seems to work reasonably well on all platforms.

  • [x] Windows
  • [x] macOS
  • [ ] Linux
  • [ ] Web

CryZe avatar Oct 07 '21 15:10 CryZe