Skip to content

Commit

Permalink
Merge pull request #4383 from nanshiki/sdl2imespace
Browse files Browse the repository at this point in the history
Fixed space key input when IME ON in SDL2 version
  • Loading branch information
joncampbell123 authored Jul 25, 2023
2 parents ac1264a + 3d9f431 commit c4615ec
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
20 changes: 9 additions & 11 deletions src/gui/sdlmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5744,24 +5744,22 @@ void GFX_Events() {
if (event.type == SDL_KEYDOWN && isModifierApplied())
ClipKeySelect(event.key.keysym.sym);
if(dos.im_enable_flag) {
#if defined (WIN32) && !defined(HX_DOS) || defined(MACOSX)
#if defined(MACOSX)
if(event.type == SDL_KEYDOWN && IME_GetEnable()) {
// Enter, BS, TAB, <-, ->
if(event.key.keysym.sym == 0x0d || event.key.keysym.sym == 0x08 || event.key.keysym.sym == 0x09 || (event.key.keysym.scancode >= 0x4f && event.key.keysym.scancode <= 0x52)) {
if(ime_text.size() != 0) {
break;
}
} else {
if((event.key.keysym.mod & 0x03) == 0 && event.key.keysym.scancode == 0x2c && ime_text.size() == 0 && dos.loaded_codepage == 932) {
// Zenkaku space
BIOS_AddKeyToBuffer(0xf100 | 0x81);
BIOS_AddKeyToBuffer(0xf000 | 0x40);
break;
}
#if defined(WIN32)
else if(ime_text.size() != 0)
#endif
break;
if(event.key.keysym.scancode == 0x2c && ime_text.size() == 0 && dos.loaded_codepage == 932) {
if((event.key.keysym.mod & 0x03) == 0) {
// Zenkaku space
BIOS_AddKeyToBuffer(0xf100 | 0x81);
BIOS_AddKeyToBuffer(0xf000 | 0x40);
break;
}
} else break;
}
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion vs/sdl2/src/video/windows/SDL_windowsevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0);
}
}
if ((wParam != VK_PROCESSKEY || (lParam >> 16) == 0x39) && code != SDL_SCANCODE_UNKNOWN) {
if (wParam != VK_PROCESSKEY && code != SDL_SCANCODE_UNKNOWN) {
SDL_SendKeyboardKey(SDL_PRESSED, code);
}
}
Expand Down
10 changes: 10 additions & 0 deletions vs/sdl2/src/video/windows/SDL_windowskeyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,16 @@ IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoD
IME_InputLangChanged(videodata);
break;
case WM_IME_CHAR:
if(wParam == 0x20) {
// enable IME input space
PostMessage(hwnd, WM_KEYDOWN, 0x20, 0x390001);
} else if(wParam == 0x3000) {
// input Zenkaku space
videodata->ime_composition[0] = 0x3000;
videodata->ime_composition[1] = 0;
IME_SendEditingEvent(videodata);
IME_SendInputEvent(videodata);
}
trap = SDL_TRUE;
break;
case WM_IME_SETCONTEXT:
Expand Down

0 comments on commit c4615ec

Please sign in to comment.