libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
10.17k stars 1.86k forks source link

Regression: key events not triggered when an IME language is active #9215

Open expikr opened 8 months ago

expikr commented 8 months ago

See https://github.com/love2d/love/issues/2031#issuecomment-1981952827

slouken commented 5 months ago

I'm not sure this is a bug. The correct behavior on all platforms is that when the IME is composing the keystrokes are consumed by that process. It works this way on Windows and Linux, and is supposed to work that way on macOS but doesn't for technical reasons.

Can you give a specific example of what you expect to work and what behavior you're seeing?

expikr commented 4 months ago

I’m really not familiar with how IME is supposed to work in general, but my expectation of behaviour comes from that of a player of a game, in that I expect my character’s ability to move with WASD to not be influenced by the currently selected language. Whereas in say Minecraft (which uses glfw), if I accidentally switch to an IME language in the background, my inputs are simply locked with no indication as to why. This behaviour is also observed when you make a simple WASD-controlled game in Love2D.

@slime73 perhaps you might have a better idea of whether the responsibility rests with SDL or Love2D?

slime73 commented 4 months ago

if I accidentally switch to an IME language in the background, my inputs are simply locked with no indication as to why. This behaviour is also observed when you make a simple WASD-controlled game in Love2D.

This is only the case when you have text input enabled (so it starts generating textedited events instead of key press events), right? Which sounds like it's intentional behaviour from what Sam said, otherwise you might end up moving around ingame or activating menu options or shooting your friends or something unintentionally as you compose text.

expikr commented 4 months ago

So to clarify, the expectation is that the developer of the game must always remember to first disable textinput whenever they are in a character-controlling mode?

It seems like an easy mistake to not know about being expected to disable textinput, especially since even the likes of Minecraft doesn’t know to do this.

It probably makes more sense for Love2D or SDL to start off with textinput disabled by default and the developer only enable it on an as-needed basis.

In any case, regardless of whether or not the expectation is a reasonable design choice, I guess this means that this isn’t an issue on SDL’s part and is therefore not a library dependency issue for Love2D?

slime73 commented 4 months ago

love uses SDL's default state on a given platform (SDL2 has text input off by default on platforms where there's usually a virtual keyboard, like phones), however text input and key events are changing a fair amount in SDL3: https://github.com/libsdl-org/SDL/blob/main/docs/README-migration.md#sdl_keyboardh

slouken commented 4 months ago

So to clarify, the expectation is that the developer of the game must always remember to first disable textinput whenever they are in a character-controlling mode?

It seems like an easy mistake to not know about being expected to disable textinput, especially since even the likes of Minecraft doesn’t know to do this.

It probably makes more sense for Love2D or SDL to start off with textinput disabled by default and the developer only enable it on an as-needed basis.

SDL3 starts with textinput disabled by default for exactly this reason.