-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[rcore] Draft: IME support #2809
base: master
Are you sure you want to change the base?
Conversation
It has not yet been merged into GLFW, so the fails of the tests are as expected. Please see the wiki of |
@daipom Thank you very much for all the hard work on this new feature! I couldn't review it carefully yet, probably some function could be renamed but the example looks fantastic! Thanks! 😄 |
Thanks! |
37eb6f7
to
88a0d77
Compare
I have just rebased this branch to the latest master. |
In connection with #2814, many characters can be entered at one time when using an IME. Lines 335 to 337 in 50a716c
It would be great if this could be made larger, such as |
88a0d77
to
574f985
Compare
I have fixed some APIs: |
574f985
to
3666805
Compare
I rebased this branch to the latest master and added the feature to take candidate list (Win32 ONLY). If you would like this feature to be separated into another PR, please let me know. |
@daipom Hi! It's been quite long since this amazing improvement was proposed, what is the current state? Is there some workaround to allow this feature to be added in raylib? |
This will definitely require some rebasing and modifications now the platform split is merged, to move the relevant code to rcore_desktop.c |
I think It'll be better to change |
I just saw there was some update on this PR. I'm keeping it open for a bit longer, it seems lately GLFW is receiving several updates... |
3666805
to
90cb37e
Compare
Hi, I'm a collaborator of this work.
IME support of GLFW isn't merged yet, it's planned as a part of v3.5: https://github.com/glfw/glfw/milestone/25 |
A commit is added automatically by CI: I'm not sure we can leave it as is, or we should do something more or not. |
This is for GLFW3 Preedit Callback: glfwSetPreeditCallback
This is for GLFW3: glfwSetPreeditCursorRectangle
This is for GLFW3: glfwGetPreeditCursorRectangle
This is for GLFW3: glfwGetInputMode (mode: GLFW_IME)
This is for GLFW3: glfwSetInputMode (mode: GLFW_IME)
This is for GLFW3: glfwResetPreeditText
Support the GLFW preedit candidate feature. This feature supports only Win32 currently. We can use this feature by enabling `FLAG_MANAGE_PREEDIT_CANDIDATE` flag on Win32.
ccf2ddf
to
b44c05d
Compare
This is a fix for issue #1945.
We are mainly assuming Japanese input, but this feature can be used for other languages using IME as well.
We are implementing IME support features in GLFW now:
This fix adds the corresponding APIs to raylib.
It may take a while to be merged in GLFW, so we have created this PR as a draft ahead of time.
APIs to be added
void SetPreeditCallback(PreeditCallback callback)
void (*PreeditCallback)(int preeditLength, int *preeditString, int blockCount, int *blockSizes, int focusedBlock, int caret)
CharCallback
.CharCallback
, is that this is not likeCharCallback
, where the input is resolved for each character, but rather requires managing the entire current preedit info at all times. Therefore, it is inefficient for an app to ask for preedit info every frame, so we use a callback to notify the change of preedit info.void SetPreeditCursorRectangle(int x, int y, int w, int h)
void GetPreeditCursorRectangle(int *x, int *y, int *w, int *h)
SetPreeditCursorRectangle
.void ResetPreedit(void)
bool IsImeOn(void)
void SetImeStatus(bool on)
Feature to take candidate list (Win32 ONLY)
For a detailed explanation, please see below.
void SetPreeditCandidateCallback(PreeditCandidateCallback callback)
void (*PreeditCandidateCallback)(int candidatesCount, int selectedIndex, int pageStart, int pageSize)
GetPreeditCandidate
.int *GetPreeditCandidate(int index, int *textCount)
Specifications for each platform
Details are in the GLFW PR glfw/glfw#2130.
Win32
macOS
X11
SetPreeditWindowPosition
andGetPreeditWindowPosition
work, and other APIs don't work.Wayland
SetPreeditCallback
,SetPreeditWindowPosition
, andGetPreeditWindowPosition
.Sample Application
We are implementing the sample application
RaylibIMEInputSampleApp
.We can check all newly added APIs in this application.
Known issues
Additional planned fixes
Since the fix of GLFW is large, we will submit separate PRs to GLFW for the following features.
For this reason, we have also separated the fixes for raylib.
FLAG_SOFT_FULLSCREEN
config flag to make the fullscreen not exclusive.Feature to take candidate list (Win32 ONLY)
Usually, the IME displays the candidate window, so the app side doesn't need to get canidate list.
However, sometimes, we need to display it on the app side.
For example, it could be for displaying it correctly on exclusive fullscreen, or for using a custom design.
This is especially common in games for Windows.
This feature is OFF by default.
We can use this by setting the
FLAG_MANAGE_PREEDIT_CANDIDATE
config flag.Currently, this feature is available only on Win32, since this feature is especially common on Windows.
We'd like to make it available on every platform if possible, but it may be difficult because of platform specific issues.
This feature is also involved in the issue with fullscreen and IME.
If fullscreen is strongly exclusive, then the candidate window of IME can't be displayed correctly.
This problem is especially serious in Windows, so this feature is one workaround for fullscreen on Windows.
We also have another fix that reduces fullscreen exclusivity for the IME, but the fix of GLFW for Windows is tricky...
(Please see
Additional planned fixes
)We can check this behavior in the sample application with
MANAGE_PREEDIT_CANDIDATE
cmake option.