plover icon indicating copy to clipboard operation
plover copied to clipboard

Wayland support with keyboard emulation and capture using uinput

Open LilleAila opened this issue 1 year ago • 0 comments

Summary of changes

This adds support for keyboard emulation and capture using uinput. As opposed to #1461, this implements a uinput-based output backend. Uinput is present in most linux distributions, and works at a lower level. This means that it does not rely on a specific protocol, and will work in Wayland, X11 and even the TTY console, as it essentially emulates a keyboard. The drawback to this is that it varies by the software layout, and there is not a way to directly input characters not in the keyboard layout, so it relies on an IME such as iBus or fcitx5. The latter should work fine in window managers like Hyprland or sway from my testing. It assumes the key binding to type unicode is set to the default, which is ctrl+shift+u.

It adds the following new dependencies:

  • xkbcommon
  • evdev

This should close #1655 and close #1050

Remaining stuff to do

  • [x] Add tests
    • The already existing test/test_keyboard.py should work with this, and the tests pass when running tox r -e test
  • [x] Add news
  • [x] Implement suppressing in KeyboardCapture, probably by passing the keys to KeyboardEmulation as a workaround
  • [x] Figure out a way to get the system's keyboard layout used by the emulated keyboard
    • There is a config option. The default value is us, and it will still work fine for most people using a non-us keyboard, as long as the alphanumeric keys are in the same positions.
  • [x] Figure out how to install the udev rule automaticaly (KERNEL=="uinput", GROUP="input", MODE="0660", OPTIONS+="static_node=uinput")
    • The rule now gets installed, but the code for it is not the best
  • [x] Resolve error Qt: Wayland does not support QWindow::requestActivate()

Pull Request Checklist

  • [x] Changes have tests
  • [x] News fragment added in news.d. See documentation for details

LilleAila avatar Jul 11 '24 17:07 LilleAila