Facepunch / sbox-issues

176 stars 12 forks source link

Keybinds not working when using CJK IMEs #547

Open goaaats opened 3 years ago

goaaats commented 3 years ago

Describe the bug When using an IME input method like Japanese or Chinese, and switching to a mode with a dictionary(not "Direct Input"), s&box will fail to recognize any keybinds(walking, jumping, back to menu, etc) in-game.

This basically breaks all input and can be very confusing. For example, Japanese keyboards have a button to toggle between modes - so it is easy to accidentally enable this and have all input in the game stop working without any feedback as to why.

To Reproduce

  1. Switch to the Microsoft Japanese input method
  2. Start s&box, enter sandbox mode on whatever map
  3. Switch to a dictionary mode while playing(e.g. hankaku/zenkaku hotkey or right click the A in the taskbar while the game is selected)
  4. See error

Expected behavior Toggling IME modes should not be possible if no text field is selected. The IME mode should always be set to "Direct Input" when not typing any text.

Screenshots https://streamable.com/zacbaw (Observe me not being able to walk when the Hiragana symbol is shown)

Additional Context There's this article from 2009 that I've used before as a reference to fix this in a personal project, maybe it can be of help: https://blog.gatunka.com/2009/09/20/ime-basics-for-developers/

Ryhon0 commented 3 years ago

Duplicate of #306 ?

goaaats commented 3 years ago

Ah, that's true, but I guess it's missing the angle of input not working at all when toggling it in-game - might be wise to merge them

rebel1324 commented 3 years ago

Can confirm this, CJK key events are not registering in the code. Confirmed with Korean Input Mode.

garrynewman commented 3 years ago

This should be good now

MuffinTastic commented 3 years ago

As far as keybinds being blocked goes, this is no longer an issue. However with Japanese IMEs, the Alt+` shortcut for toggling the IME doesn't get blocked and causes the console to open and close when you don't intend it to.

When it comes to actually typing CJK text, a bit more work is still left to be done. With Chinese and Japanese IMEs it's possible but the composition suggestion box doesn't appear (ideally it should appear but only when the player is actually supposed to type). With Korean IMEs it's impossible as every new complete character overwrites the last. Perhaps #306 should be reopened to focus on this though.