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

Map scancode to KeyCode #10977

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Map scancode to KeyCode #10977

wants to merge 10 commits into from

Conversation

estin
Copy link
Contributor

@estin estin commented Jun 17, 2024

Hi! It's an optional solution to use a keyboard scancode.

Based on the comment: #165 (comment)

And on: #10228
 
Introduced the new feature scancode to enable the following logic:

  • on command  and jump-to-word modes query keyboard pressed scancode  via keyboard_query
  • map scancode to key and build a new KeyEvent and pass it back.

It isn't required to change user keymap configurations.
 

cargo install --features scancode --locked --path helix-term
  Config
[editor.scancode]
layout = "qwerty" # from pre-configured defaults
# layout = "myconfig"  # user defined config

# user personal config
[editor.scancode.map]

# [scancode, [key, shifted key]]
myconfig = [
  [1, ["esc"]],
  [2, ["1", "!"]],
  [3, ["2", "@"]],
  [4, ["3", "#"]],
  [5, ['4', '$']],
  [6, ['5', '%']],
  [7, ['6', '^']],
  [8, ['7', '&']],
  [9, ['8', '*']],
  [10, ['9', '(']],
  [11, ['0', ')']],
  [12, ["-", "_"]],
  [13, ['=', "+"]],
]
  

And it works well on my setup (linux/x11 and qwerty keyboard).

I tried to implement it in a separate module and simplify the API as an optional helix feature.

Such an approach as the compilation flag for "desktop" Helix users is the right way?

  

@kirawi kirawi added the A-helix-term Area: Helix term improvements label Jun 21, 2024
@estin estin marked this pull request as ready for review June 23, 2024 11:38
@estin estin force-pushed the scancode branch 2 times, most recently from c371b45 to 4c40b05 Compare July 22, 2024 06:24
@estin estin force-pushed the scancode branch 3 times, most recently from 4345daa to 070a337 Compare July 29, 2024 06:12
@estin estin force-pushed the scancode branch 2 times, most recently from a598e8f to fb8f2e6 Compare December 18, 2024 06:15
@estin estin force-pushed the scancode branch 2 times, most recently from 76f939a to a9dade4 Compare January 6, 2025 09:56
@estin
Copy link
Contributor Author

estin commented Jan 23, 2025

New option - read scancode via evdev

cargo install --path helix-term  --features scancode-evdev --locked

And previous way via keyboard_query

cargo install --path helix-term  --features scancode-query --locked
feature crate linux (x11) linux (wayland) windows macos
scancode-evdev evdev yes yes no no
scancode-query keyboard_query yes no ? ?
scancode-hidapi hidapi yes yes ? ?
  • no not supported
  • yes works, tested
  • ? must works, not tested

P.S. In plans try to read keyboard scancodes via libusb/hidapi

UPDATE

New variant to read keyboard events - use hidapi (on Linux /dev/hidrawX must be allowed to read)

cargo install --path helix-term  --features scancode-hidapi --locked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants