SDL icon indicating copy to clipboard operation
SDL copied to clipboard

SDL_KeyboardEvent 'which' field is always 0

Open rb6502 opened this issue 2 weeks ago • 5 comments

I'm updating MAME from SDL 2 to SDL 3 (3.2.26). The initial port went smoothly (thank you for the excellent documentation on updating!), but I'm having difficulties hooking up support for multiple keyboards. On Linux (Fedora 43 with the latest updates) plenty of keyboard devices are enumerated in an X11 KDE Plasma session (including for my Logitech G502 mouse and G633 headset, which I wasn't expecting). However, when typing on any of the keyboards I have plugged in, the which field of the SDL_KeyboardEvent struct is always zero.

On a Wayland KDE Plasma session and on macOS 26, only one keyboard and one mouse are enumerated regardless of what's plugged in. I assume Wayland just doesn't have that support yet, but is it possible to see the devices separately on macOS? (I'm testing macOS on an M3 Max MacBookPro with a USB keyboard and mouse plugged in).

rb6502 avatar Dec 05 '25 15:12 rb6502

MacOS also has just one global keyboard.

X11 should work, are you using the latest main SDL code and building with XInput2 enabled?

slouken avatar Dec 05 '25 16:12 slouken

The XInput2 keyboard code is currently disabled by default: https://github.com/libsdl-org/SDL/blob/0e96cbd8ceebddb9dca9060e17a1e8913053789f/src/video/x11/SDL_x11xinput2.c#L832-L837

The upcoming SDL 3.4 supports multiple seats on Wayland, which allows for multiple, independent keyboards/mice if the compositor supports it (Sway does, not sure about others).

Kontrabant avatar Dec 05 '25 16:12 Kontrabant

Oh, right.

Yes, currently you'll only get multiple keyboard support on Windows, and as @Kontrabant said, on Wayland in the upcoming 3.4 release for compositors that support it.

slouken avatar Dec 05 '25 17:12 slouken

Ok. Not great, because Wayland is unusable on my system (everything is painfully dim on my HDR monitor and the session locks up at random), but I assume I can give that a try in the current 3.3 beta?

rb6502 avatar Dec 05 '25 18:12 rb6502

Ok. Not great, because Wayland is unusable on my system (everything is painfully dim on my HDR monitor and the session locks up at random), but I assume I can give that a try in the current 3.3 beta?

Grab the latest main code just to be sure you're getting any bug fixes.

slouken avatar Dec 05 '25 19:12 slouken