Draft: Add support for keyboard emulation keys
Draft, because it depends on !26 (merged) (custom keyboard layouts) and also has some unresolved issues, see below.
This commit adds support for keyboard emulation, using the KWin fake input protocol. Implements #14
This way, we can have some (or all) keys on the keyboard send events as emulated keyboard events, as some keys (ex. Tab, Escape, Meta, Ctrl) can't be sent over input method events in input_method_v1. I tried to approach this in a similar way to how Windows 11 implements its vkbd, which combines the smart "input context" with traditional keyboard emulation keys.
In order to accomplish this:
- I extracted some visual QML components into a QML plugin that can be shared between the "style" and "layouts"
- I added a new type of Qt Vkbd key, KeysymKey that is designed for sending simulated keyboard keys
- I added a new class KWinFakeInput to manage sending simulated keyboard events, and stores the press states of modifier keys (ex. Meta, Alt, Ctrl)
- I added logic separation in InputListenerItem, that directs certain keys to org_kde_kwin_fake_input, and other keys to input_method_v1 depending on what they are
- I created a new singleton PlasmaKeyboardState for the keyboard layout to display the modifier "press state"
Pending issues:
-
I currently just changed the "British English" locale layout to this emulated keyboard layout. We need to add layout switching logic within a layout (confusing, I know) so that it can be swapped out for the simpler layout for certain usecases (ex. for mobile, bigscreen, user preference). This requires UI/UX design for how we can (or shouldn't) present this to the user. How this interacts with locales also needs to be investigated, since Qt Vkbd layouts are tied to locales...
-
If the user starts using emulated keyboards, keep the input panel visible
-
Full keyboard emulation when there isn't an input context. This vkbd currently operates in a mixed mode, certain keys (ex. Tab, Meta, ...) trigger keyboard events, but regular keys (ex. A, B, C, Enter) use the input context. If there is no input context, emulate all keys as a fake keyboard. Then we can implement...
-
A manual vkbd show trigger. There needs to be something in the system tray (or some other trigger) to allow the user to manually popup the keyboard.
-
Finish making the full keyboard layout, which keys do we want?
-
Floating panel mode? So that the user can drag it around wherever they want
-
The shift key is managed by both Qt vkbd and KWinFakeInput, the state needs to be unified (since it's tertiary in Qt with "caps lock")
Note: This is not what the final product will look like, do not post outside of MR. On mobile & bigscreen this layout shouldn't be shown, we should have the simplified layout without keyboard emulation keys