author Sam Lantinga <>
Thu, 17 Apr 2014 22:36:14 -0700
changeset 8716 0aade9c0203f
parent 5894 414b2fa01526
permissions -rw-r--r--
Fixed bug 2325 - SDL_EnableUNICODE sometimes drops keyboard events completely

Rafał Mużyło

The most annoying part of this bug is that though I've found it in two separate apps, I don't have a trivial testcase for it.

The problem seems to be a condition race, as it's triggered quite randomly (therefore it will be hard to tell whether it really gets fixed, if a probable fix is found).

While it's specific to SDL 1.2, it seems quite similar to the problem described and fixed in

Now, I should start describing the problem.

A game uses Escape to open menu (the exact key might not be important). Upon opening, it calls SDL_EnableUNICODE(1). Upon closing it calls SDL_EnableUNICODE(0).

I have an IME running.

Game uses SDL_PollEvent to get the events.

If Escape is pressed repeatedly, menu is opened and closed, till it eventually freezes in open state.
"freezes" in this context means "app itself still runs, but no keyboard events are getting delivered (though - for example - mouse events still are)". "getting delivered" should mean "SDL_PollEvent is not receiving any".
If it matters, the last delivered keyboard event is a keypress, the release never arrives.

It seems (no guarantees, due to random nature of the freeze) that unsetting XMODIFIERS (which - AFAIU - will disable IME as far as SDL is concerned) prevents the freeze, therefore the reference to that SDL2 thread.
     2 Project files for embedded Visual C++ 3.0, 4.0 and 
     3 Visual Studio 2005 can be found in the VisualCE directory.
     5 SDL supports GAPI and WinDib output for Windows CE.
     7 GAPI driver supports:
     9 - all possible WinCE devices (Pocket PC, Smartphones, HPC)
    10   with different orientations of video memory and resolutions.
    11 - 4, 8 and 16 bpp devices
    12 - special handling of 8bpp on 8bpp devices
    13 - VGA mode, you can even switch between VGA and GAPI in runtime
    14   (between 240x320 and 480x640 for example). On VGA devices you can
    15   use either GAPI or VGA.
    16 - Landscape mode and automatic rotation of buttons and stylus coordinates.
    17   To enable landscape mode make width of video screen bigger than height.
    18   For example: 
    19     SDL_SetVideoMode(320,240,16,SDL_FULLSCREEN)
    20 - WM2005
    21 - SDL_ListModes
    23 NOTE:
    24 There are several SDL features not available in the WinCE port of SDL.
    26 - DirectX is not yet available
    27 - Semaphores are not available
    28 - Joystick support is not available
    29 - CD-ROM control is not available
    31 In addition, there are several features that run in "degraded" mode:
    33 Preprocessor Symbol		Effect
    34 ===================		=================================
    36 SDL_systimer.c:
    37 USE_GETTICKCOUNT		Less accurate values for SDL time functions
    38 USE_SETTIMER			Use only a single marginally accurate timer
    40 SDL_syswm.c:
    41 DISABLE_ICON_SUPPORT		Can't set the runtime window icon
    43 SDL_sysmouse.c:
    44 USE_STATIC_CURSOR		Only the arrow cursor is available
    46 SDL_sysevents.c:
    47 NO_GETKEYBOARDSTATE		Can't get modifier state on keyboard focus
    49 SDL_dibevents.c:
    50 NO_GETKEYBOARDSTATE		Very limited keycode translation
    52 SDL_dibvideo.c:
    53 NO_GETDIBITS			Can't distinguish between 15 bpp and 16 bpp
    54 NO_CHANGEDISPLAYSETTINGS	No fullscreen support
    55 NO_GAMMA_SUPPORT		Gamma correction not available