Daemon icon indicating copy to clipboard operation
Daemon copied to clipboard

SDL2 incorrect key behaviour under wayland

Open Adriankhl opened this issue 2 years ago • 8 comments

OS: OpenSUSE Tumbleweed Desktop environment: SwayWM

I believe this is a bug of SDL2 instead of Daemon, but I hope someone here could identify the bug and file a bug report to the SDL2 repo.

Under wayland (SDL_VIDEODRIVER=wayland), after switching to other windows and switch back to Unvanquished, the character won't move continuously when I keep pressing a movement key, such as W. Instead, a "key up" event is triggered shortly after the key is pressed.

The problem is fixed under xwayland (SDL_VIDEODRIVER=x11).

I tried to look into the source but I am not familiar enough with the engine and SDL2 so I cannot locate the exact problem.

Adriankhl avatar Aug 23 '22 17:08 Adriankhl

Does anyone use wayland on our team?

DolceTriade avatar Aug 23 '22 17:08 DolceTriade

https://github.com/DaemonEngine/Daemon/blob/bf768da95ade20b80e6fdcb958950597250c7270/src/engine/sys/sdl_input.cpp#L1053

I spent a bit more time on this problem. I think this is the where the issue occurs, SDL_KEYUP is triggered while I am pressing a key.

Do you think this issue (https://github.com/libsdl-org/SDL/issues/6037) is relevant?

Adriankhl avatar Aug 23 '22 20:08 Adriankhl

My initial reading of the issue does not seem to imply that its relevant, but I'm not super familiar with SDL2 internals.It certainly does look like an SDL2 issue if you're still holding a key down, but receiving a KEYUP event.

We'll need to follow up with upstream.

DolceTriade avatar Aug 23 '22 20:08 DolceTriade

I have had problems using Wayland too, I cannot scroll the console with my trackpad under Wayland (but can with xwayland) - the console scrolls up then immediately back down again. This is with kwin, Arch Linux.

cu-kai avatar Aug 23 '22 20:08 cu-kai

I have no problem on Wayland, SDL 2.0.20 and GNOME 42.4. What's your version of SDL?

necessarily-equal avatar Sep 03 '22 10:09 necessarily-equal

I have no problem on Wayland, SDL 2.0.20 and GNOME 42.4. What's your version of SDL?

2.24.0

Adriankhl avatar Sep 03 '22 13:09 Adriankhl

FWIW, the user can only have a different version of SDL2 if they built the game themselves, as we statically link SDL.

ghost avatar Sep 03 '22 13:09 ghost

FYI, yes I built the game myself.

Adriankhl avatar Sep 03 '22 13:09 Adriankhl