Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression 11.5: key events not triggered when an IME language is active (windows) #2031

Open
expikr opened this issue Mar 6, 2024 · 12 comments
Labels
library dependency Related to a library used by LÖVE Windows

Comments

@expikr
Copy link

expikr commented Mar 6, 2024

If you have a CJK language active then the corresponding keypressed/keyreleased events are not triggered.

It's the same kind of problem that Minecraft has (which uses glfw), so it might have something to do with naive handling of scancode/virtual-key codes.

tested on 11.5

EDIT: works correctly in 11.4 so it's a regression.

test code:

local vkeycode_count = 0
local scancode_count = 0

function love.keypressed(vkey,scan,isRepeat)
    if vkey=="w" then vkeycode_count = vkeycode_count + 1 end
    if scan=="w" then scancode_count = scancode_count + 1 end
end
function love.keyreleased(vkey,scan)
    if vkey=="w" then vkeycode_count = vkeycode_count - 1 end
    if scan=="w" then scancode_count = scancode_count - 1 end
end
function love.draw()
    love.graphics.print(
        "love.keyboard.isDown('w') = "         .. (love.keyboard.isDown('w')         and "true" or "false") .. "\n" .. 
        "love.keyboard.isScancodeDown('w') = " .. (love.keyboard.isScancodeDown('w') and "true" or "false") .. "\n" .. 
        "vkey w press count = " .. vkeycode_count .. "\n" ..
        "scan w press count = " .. scancode_count
    )
end
@slime73
Copy link
Member

slime73 commented Mar 6, 2024

Is there a game you know of that does work as you expect on your system?

That being said, since love uses SDL for input handling, if it is even possible for apps to control that behaviour then SDL's code would have to change rather than love's code.

@expikr expikr changed the title key events not triggered when an IME language is active (windows) Regression 11.5: key events not triggered when an IME language is active (windows) Mar 6, 2024
@expikr
Copy link
Author

expikr commented Mar 6, 2024

re-tested 11.4 works correctly, so it's a regression.

Is there a game you know of that does work as you expect on your system?

Overwatch for example, and basically pretty much any game that started off with an AAA-ish engine.

@slime73
Copy link
Member

slime73 commented Mar 6, 2024

Are you able to test directly with the latest SDL and file a bug there if needed? love 11.4 used SDL 2.0.18, and 11.5 uses 2.28.5.

@expikr
Copy link
Author

expikr commented Mar 6, 2024

latest SDL.dll fails for both 11.4 and 11.5

11.4's SDL.dll works when copied to 11.5 as well.

So it's upstream.

@slime73
Copy link
Member

slime73 commented Mar 6, 2024

A couple clarifying questions:

  • do you get love.textedited and love.textinput events in that situation?
  • is an IME dialog / UI element visible at all?
  • if you turn text input off, does the behaviour change?

@expikr
Copy link
Author

expikr commented Mar 6, 2024

  1. first time I've heard of those events. Will test.
  2. no element visible whatsoever. Just like with Minecraft
  3. what do you mean by turning it off?

@slime73
Copy link
Member

slime73 commented Mar 6, 2024

first time I've heard of those events.

If you ever want to have a text box or handle typed text from users, you'll definitely want to use those instead of love.keypressed (whereas the latter is good for other game input unrelated to text). :)

what do you mean by turning it off?

love.keyboard.setTextInput

@expikr
Copy link
Author

expikr commented Mar 6, 2024

In both versions, during IME mode no textinput events are generated, and textedited events are only generated when changing the key pressed (repeat presses do not generate new events, nor do key releases).

With love.keyboard.setTextInput(false) the IME toolbar is locked into alphanumeric mode, and the keypresses registers correctly.

So the only difference between 11.4 and 11.5 is whether or not isDown/isScancodeDown/keypressed/keyreleased registers during IME, the textinput/textedit/setTextInput behaviors are identical.

local vkeycode_accu = 0
local scancode_accu = 0
local input_count = 0
local edit_count = 0


function love.mousepressed(x,y,button,istouch,presses)
    if button==3 then love.keyboard.setTextInput( not love.keyboard.hasTextInput() ) end
end

function love.textinput(text)
    input_count = input_count + 1
end

function love.textedited( text, start, length )
    edit_count = edit_count + 1
end

function love.keypressed(vkey,scan,isRepeat)
    if vkey=="w" then vkeycode_accu = vkeycode_accu + 1 end
    if scan=="w" then scancode_accu = scancode_accu + 1 end
end
function love.keyreleased(vkey,scan)
    if vkey=="w" then vkeycode_accu = vkeycode_accu - 1 end
    if scan=="w" then scancode_accu = scancode_accu - 1 end
end
function love.draw()
    love.graphics.print(
        "love.keyboard.isDown('w') = "         .. (love.keyboard.isDown('w')         and "true" or "false") .. "\n" .. 
        "love.keyboard.isScancodeDown('w') = " .. (love.keyboard.isScancodeDown('w') and "true" or "false") .. "\n" .. 
        "vkey w accu = " .. vkeycode_accu .. "\n" ..
        "scan w accu = " .. scancode_accu .. "\n" ..
        "textinput count = " .. input_count .. "\n" .. 
        "textedited count = " .. edit_count
    )
end

@slime73 slime73 added library dependency Related to a library used by LÖVE Windows labels Mar 7, 2024
@ericoporto
Copy link

ericoporto commented Mar 9, 2024

@expikr can you verify if SDL release 2.24.2 already had this issue or if it still worked? The dll can be found in either the win32 assets (x86 or x64).

@expikr
Copy link
Author

expikr commented Mar 9, 2024

2.24.2 fails.

Daaaav added a commit to Daaaav/Ved that referenced this issue Mar 16, 2024
This _should_ implement support for IMEs for CJK, by showing what the
currently edited text is. This is still a little untested, since I
want to do that on another computer and it's easier to just push
immediately and pull there, than to copy it over with a USB stick or
something, heh.

This also adds the behavior change that while uncommitted IME text is
currently set, regular key input (love.keypressed and
love.keyboard.isDown()) is ignored. This is because inputs that should
go to the IME (like Enter, Esc, etc) were also interpreted by Ved,
meaning if you press Enter to commit text, Ved would first insert a
new line and then commit the text. At least, this would happen in
LÖVE 11.4 and below, because in 11.5 the behavior changed to one I
actually need, lol: love2d/love#2031

[pre23]
@slime73
Copy link
Member

slime73 commented Mar 20, 2024

no element visible whatsoever

With love.keyboard.setTextInput(false) the IME toolbar is locked into alphanumeric mode

I'm a bit confused by this - is there IME-related UI visible and active while text input is active, or is there not?

@expikr
Copy link
Author

expikr commented Mar 20, 2024

The IME toolbar is a status indicator in the systray, next to the system clock.

The IME character selection overlay element is never visible in Love2D.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
library dependency Related to a library used by LÖVE Windows
Projects
None yet
Development

No branches or pull requests

3 participants