blish-hud / Blish-HUD

A Guild Wars 2 overlay with extreme extensibility through compiled modules.
https://blishhud.com
MIT License
311 stars 60 forks source link

Support for Input Method (IME)? #804

Open real-zony opened 1 year ago

real-zony commented 1 year ago

I am a MonoGame beginner and I would love to develop modules for blishhud, but blishhud doesn't seem to provide support for IME. (My friend and I are both Chinese client)

Can you give me some advice? My intuition tell me to start with TextInputBase.

Of course, I'm trying to implement it.

dlamkins commented 1 year ago

Hello,

Yes, that would likely be the place to start. You may also need to play around with the keyboardmanager under the input service. I'm afraid I'm not familiar with the ins and outs of IME input and what hurdles there might be.

Feel free to join our Discord for more real-time discussions, if you wish. 👍

real-zony commented 1 year ago

Thank you very much for your advice, so far I have some idea and am implementing it. 🤓 I have joined Discord.

entrhopi commented 1 year ago

Hi! I'm probably the guy with the most Blish keyboard madness on my record. 😊

Like @dlamkins I'm not very familiar with IME but I out of the top of my head I suggest looking at KeyboardHandler and TypedInputUtil. Those are probably the best candidates. I rewrote both of those substantially to support modifier keys at all.

If you need help just hit me up. Either here or on Discord. I'm trying to be more present again. This year has been crazy....

real-zony commented 1 year ago

Hi @entrhopi ,I'm back. Could you give me some advice? I tried to enable IME support using the method of WindowsDXTests in IMEHelper, but unfortunately, it doesn't work. https://github.com/ryancheung/MonoGame.IMEHelper

real-zony commented 1 year ago

I ran this test project alone and it worked well. I am a beginner in MonoGame/Windows development (I mainly work on web server), so I can only guess if Blish HUD intercepted the key events or if there is something special about Blish HUD's form?

entrhopi commented 1 year ago

I think the main challenge is, that we need to use pretty low level access for keyboard input. This is because we need to catch some things even before they are passed to the game. So all 'text' input fields are not native to whatever the operating system will use.

I'm currently on the road and can't test things, but here are some quick thoughts until I'm back on the weekends:

Pardon my unknowingness, but my understanding is, that you type a few letters and then there will probably be a selection for the right Chinese symbol?

My first intuition would be to test if you can copy and paste Chinese into Blish text input fields. If so, then your first post might be correct in the assumption that you probably need to extend the TextInputBase with a kind of autocomplete-popup routine and a library of the Chinese symbols.

real-zony commented 1 year ago

Hi @entrhopi , thank you very much for your answer. Your guess is correct. The actual scenario is that after entering English letters, a candidate box will pop up to select the matching Chinese symbol. Currently, TextInput cannot display Chinese characters, and this issue is closely related to #423. Of course, I tested it myself and found that replacing BitmapFont with the font class provided by FontStashSharp can enable normal copy and paste of Chinese characters. image

And @dlamkins do you have any suggestions on this? I believe that the change in font system will allow more regions' text to be displayed properly on Blish HUD. #866 #282

dlamkins commented 1 year ago

We have plans to switch to FontStashSharp in the future, but it's a larger change that likely isn't coming soon because it comes with some breaking changes.

real-zony commented 1 year ago

OK, I understand. I have tested it locally and the scope of changes is significant, which may be a breaking change for some modules. I can do this job (#423) if needed.