AltGr not working with UHID keyboard + Danish keyboard layout
Utilizing the UHID keyboard with scrcpy and the Danish keyboard layout does so that AltGr cannot be utilized.
System Specs
- Operating system: Arch Linux
- Display server protocol: Wayland
- Compositor: Sway
- Keyboard Layout: Utilizing the danish keyboard layout as can be seen here:
(source of picture here)
Phone specs
- Phone: Google pixel 9 pro XL
- Operating system: GrapheneOS.
- Keyboard: Using the default android keyboard bundled with GrapheneOS, Danish layout.
Description of problem
Scrcpy is running through xwayland.
Running
scrcpy --video-codec=h265 --max-size=1920 --max-fps=60 --no-audio --keyboard=uhid --shortcut-mod lalt -V verbose and pressing+releasing AltGr gives the following output:
VERBOSE: hid keyboard: key down scancode=e6 (230) mod=00 VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00 VERBOSE: hid keyboard: key up scancode=e6 (230) mod=00 VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00
However, upon pressing e.g. AltGr+2 to input the character '@' in scrcpy, the character is not input. '2' is simply input.
There is an odd thing, however. The ´-button (located just to the left of the backspace button on my keyboard) does not input anything in scrcpy when pressed on its own.
However, if the ´-button is pressed twice with AltGr held down in scrcpy, the character ´ is input.
This character is normally input when pressing the button on its own without AltGr in my operating system.
The following output is obtained by
Pressing AltGr-->pressing the ´-button twice -->releasing AltGr
in scrcpy:
VERBOSE: hid keyboard: key down scancode=e6 (230) mod=00 VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00 VERBOSE: keys[2e] = true VERBOSE: hid keyboard: key down scancode=2e (46) mod=00 VERBOSE: input: UHID input [1] 00 00 2E 00 00 00 00 00 VERBOSE: keys[2e] = false VERBOSE: hid keyboard: key up scancode=2e (46) mod=00 VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00 VERBOSE: keys[2e] = true VERBOSE: hid keyboard: key down scancode=2e (46) mod=00 VERBOSE: input: UHID input [1] 00 00 2E 00 00 00 00 00 VERBOSE: keys[2e] = false VERBOSE: hid keyboard: key up scancode=2e (46) mod=00 VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00 VERBOSE: hid keyboard: key up scancode=e6 (230) mod=00 VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00
AltGr works completely fine in scrcpy with the --keyboard=sdk option, however.
A recent-ish comment in this issue #4725 describes a similar problem to mine.
Source: Genymobile/scrcpy