The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Don't send SDL_KEYDOWN during IME
ancientcc


Joined: 22 Feb 2011
Posts: 24
It is on Window OS.

I'm migrating SDL from 1.3 to 2.0.3. Dealing with keyboard input, find SDL 2.0.3 send SDL_KEYDOWN when IME, it cause trouble to me.

On application level, according to event.key parameter, it cannot distinguish current keyboard state wheather in IME or not.

I hope that SDL don't send SDL_KEYDOWN during IME same as SDL 1.3.

Go deep into SDL 2.0.3 source code, try to modify.

LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
......
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
{
SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam );
if (wParam != VK_PROCESSKEY && code != SDL_SCANCODE_UNKNOWN ) {
SDL_SendKeyboardKey(SDL_PRESSED, code );
}
}
......
}

Change "if (code != SDL_SCANCODE_UNKNOWN)" to "if (wParam != VK_PROCESSKEY && code != SDL_SCANCODE_UNKNOWN)".
kagari


Joined: 08 Jan 2015
Posts: 1
FYI, I've reported this bug in Bugzilla.
Bug 2836 - Windows: No way to tell whether SDL_KEY* events was trapped by the IMs