-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[core] IME Support #1945
Comments
That's very interesting. I was thinking that we need a way to do that and there are also considerations with respect to accessibility. This is also valuable for additional languages/keyboards. The TLDR: This software is extensive and maybe larger than raylib :). Figuring out a mapping and then being able to deal with SDL2 updates is going to be challenging. I recommend that this issue be moved to Discussion since adapting SDL for inter-working with raylib is going to require extensive effort and substantial analysis and testing. === Observations The SDL2 Tutorial is tied to mingw-w64 and it involves libraries as well as a DLL that applications are expected to bundle. It is useful that the code downloads are signed. There is no public development server (GitHub or elsewhere). It may take some work to adapt that to the raylib way of doing things, whether as an external or extra. I assume that raylib should be moved to handle Unicode (probably UTF-8) in these cases. I gave the source-code download a quick look. The code is under a BSD-flavor license. Considering that this is about a Windows-centric facility (I thought) the plethora of Unix-isms is startling (*.sh, *.m4, etc.) in areas involving use of Visual C.. Apparently there are comparable integrations for other platforms. There are Visual Studio solutions and projects as part of the code. Some may be dated (one is for VS2012). The dates on files in the Zip appear to be from late July although it is not clear what that means. There is no |
First off, I might be misunderstanding what you're saying, so absolutely correct me if i'm wrong! You seem to be suggesting that we use SDL2 to solve this problem, while that might be possible my intention was more just to show what the API might look like (i'm not really experienced enough with this kind of thing to be much help with the low level details anyway). Another thing is that IMEs are not a windows thing, they're on mac and linux as well. Otherwise you wouldn't be able to type in japanese on either of those. As for whether or not it should be moved to discussion i don't really know how any of that works (this is the first issue i've ever opened). So if i need to do something then i might need instructions. |
Thank you @mia-bentzen, I understand your concern more now. が I managed to use IME right here, after using Windows 10 to install Japanese as an additional language. I did not know how to do the rest of your example, of course, although bringing up special soft keyboards might help.. I am uncertain that my browser has anything to do with this with regard to enabling IME. I am ignorant of how the interaction is handled. Two things:
|
For whatever reason none of those buttons are there for me. |
@mia-bentzen Thanks for the detailed report, this issue could require some investigation. @orcmid I think only the owner of the repo can convert an Issue to a Discussion. For me it's ok to keep it as an issue. |
I have been sleuthing in SDL. Here's what I have so far: Aside: To conduct this analysis I had to install grepWin. Any good The functions The functions These are wrappers that rely on a global variable,
The
is the parameter type used in the prototypes of various functions. This is demonstrated in the code for
The point is that the functions pointed to in the There are 7 relevant text-input and possible-screen-keyboard functions that have pointers stashed in an
There are checks on whether a pointer is present, as in
And if it is available, the function is used via the
We have seen how the keyboard functions are implemented by short procedures that call for platform-specific implementations via the global Now we need to understand where such initializations are made and what are the functions pointed to after initialization. Note 1: This is a bit like hand-rolled COM interfacing. It is weirder than that in the extreme use of indirection, even though Note 2: raylib also relies on a global data structure, |
Fantastic dive and information https://github.com/orcmid not everyone would be willing to dig into. Thanks for getting your hands dirty on this. |
Continuing ... One place where initialization of a
start ing at line 97 of The
The In Assume that This pattern applies for each of the video systems supported in SDL2. I have traced out the Windows case out of consistency and familiarity with how IME's are handled. I expect the general structure is the same for other platforms, with the implementation details specific to those systems. In the case of Linux, we are dependent on the GUI system, so there might need to be variations for different desktop Linux GUI systems. I think the hard part remains. It is beyond my capability and capacity. Like all |
==Afterthoughts What I did not address is how, using SDL2, this is all tied into the event loop and the arrival of keypresses/character codes in the interactive operation of an SDL2-based application. The equivalent operations in raylib need to be understood. The handling of keyboard/mouse/controller events and their filtering/routing are relevant to how and when IME-processing is spliced into the arrival of character codes in the graphical application. That is, how the app shifts from keyboard/mouse actions (aim, shoot, reload, run, walk, crouch, etc.) and acceptance of text (e.g., talk, respond to a prompt). For me, the raylib handling of all this is yet to be learned and understood. There's probably even more that I don't know I don't know ;). And to think that I got here because I was frustrated with "C++ Fundamentals for Game Development" not using Native Windows tools while intrigued by it using raylib as a lightweight introduction into video apps. I now return to my regularly-scheduled programming. |
@orcmid raylib is similar to SDL2 in the way Events are received but SDL2 requires manual polling and processing of events while raylib does it automatically on I've been insvestigating a bit and it seems |
It will only do that if |
I think this might be because SDL2 doesn't fully implement the IME on windows. I don't know if it's still a thing (the posts were from 2020 for reference) but when searching for the SDL IME API i found quite a few people having problems with it not showing the suggestions box at all, and some say that it's not actually implemented. (It seems to work consistently on mac and linux though, so it should still be a good reference for those platforms) Also, i managed to find the windows IME API. https://docs.microsoft.com/en-us/windows/win32/intl/input-method-manager |
I did find where it wires up IME in Windows, it is just not in a |
The Text services framework involves applications needing to install a redistributable DLL and also employ COM interfaces. This does not strike me as appealing for either SDL2 or raylib. Although the IME support began with Windows XP, that seems more likely to be usable, if at all. I presume those interfaces continue to be included in the Windows SDK for later editions of Windows, through to Windows 10/11. I notice on Windows 10 it is very easy to install accommodations of different keyboards and IMEs at the system level (using Windows Settings and then the system tray for choosing among the different ones installed). I did that to turn on the Japanese IME |
After some review, I think IME support is out of scope for raylib at this moment. In any case, it should be supported by GLFW, that is the library in charge of the platform layer, so, I'm closing this issue. |
I concur with that. How about making this a Discussion so it does not vanish deep into the whirlpool of closed issues. |
Thanks a lot! This turned out to be supported in glfw. I'll look into it later. But raylib itself doesn't seem to have an api like StartInput? Will this be added in the future? |
@jdeokkim @UradaSources It seems those changes are not merged yet but I reopen this issue to keep track of it. |
I took a quick look at the glfw api and did some tests, just simply register a callback function with glfwSetCharCallback to get the output of ime! This callback function is called once for each complete character returned by ime, and you will get that character unicode code of . |
Hi, I am one of those working on this GLFW PR. We are already working on the corresponding work for raylib.
We are planning to make a PR for raylib once GLFW is merged. Or if it seems better to set up a PR first, We will make one soon. |
@daipom The sample application looks very nice, thank you for your hard work! |
@daipom Wow! The example is very impressive! Congratulations! Thank you very much for working on this issue, this is an amazing improvement. Feel free to send a PR when ready and let's see the complexity/dependencies it adds to raylib and the better way to implement it... In any case, we can put it under a compilation flag for users requiring it. |
@jmorel33 Feel free to open a PR in draft, also useful for further discussion about this feature. |
@raysan5 Thanks! I will open the PR in draft soon! |
I have created the drat PR! |
@daipom 👏👏👏👏👏👏👏 |
@daipom Any update on the state of this feature? We are waiting for GLFW merging, right? |
@raysan5 Yes! We are waiting for GLFW merging! |
I'd really love to see it getting merged as soon as possible! 🥰 |
Still waiting for GLFW. |
@daipom Yeah, no worries... This new GLFW 3.4 release is taking quite long. We should wait... |
I'm afraid I'm closing this issue and the related PR. It's been 1.5 years since it was openend and many things changed and a lot of review is required. It's sad because it was great but we should move on. It could be checked back in the future if it applies. |
In order to be able to type text in japanese (and i assume chinese too, though i'm not familiar with it) you pretty much have to use to OS's IME (Input MEthod) to get input working right.
To give a small example of how it works: when you type が you don't actually type が directly, rather you type ga and it then automatically replaces that with が. It also comes up with suggestions based on a dictionary, and pressing space changes kana (basically letters) into kanji (basically complicated letters) so for instance you could have おんな, press space, and then it would change it into 女.
In order for the OS to know where and when to draw the IME suggestions box, the application has to tell it. The way SDL2 accomplishes this is with three methods: SDL_StartTextInput, SDL_StopTextInput, and SDL_SetTextInputRect.
The reason this would be nice to have is that without it japanese users simply can't type japanese text in any raylib application, and i'm not aware of any alternative or workaround.
The text was updated successfully, but these errors were encountered: