SDL-IM: IM(Input Method) support in SDL
(update date: 2007/02/07) TW Big5 Page CN GB2312 Page
A forum for SDL-IM, every news will be posted here.
A new patch for pygame using SDL-IM! Please see here and the screenshot! Thanks Tiberius Teng!
To patch or not to patch, that is the question!
Where can I get necessary files?
you can get SDL-1.2.8 from: http://www.libsdl.org/release/SDL-1.2.8.tar.gz
you can get the patch for SDL-1.2.8 from : SDL_im-1.2.8-20070327.diff.gz
This(20050828) is applied with harpy's XIM patch(Thanks harpy!)
This(20070106) fixed a bug crashed when typing ALT key in Japanese Windows XP.(Thanks Makoto HARADA!)
Some people
ask me why my patch will crash their program,
but no one give me
their tracing report.
Unfortunately,
I can not reproduce this crashing result in my Windows XP.
SDL_im
patch works fine all the time. Makoto HARADA traces and shares
me his tracing report. :-)
The more supports?(New option pack for SDL-IM)
In order to make games looks more professional, SDL-IM should provide more IM information to help users to draw IM widgets in their game UI. Although SDL-IM provides SDL_GetIMInfo to get the handle and the context of IM server, but I think it may trouble some people.
At the same time, I also hope SDL-IM can keep simple to be suitable with future technology, so I still evaluate this support about more IM information or OnTheSpot mode. If you have any ideas, please mail to me.
* * *
Now, there is an option pack based on SDL-IM named SDL_imm can solve some parts of this problem.
Anything else?
Yes! Here are some samples or libraries applied this patch:
1. GuiChan/SDL-IM by harpy (Thanks harpy!)
2. patch for paraGUI-1.1.8 (update: 2005/02/11)
3. patch for aedGUI-0.1.8a (update: 2005/03/12)
4. a tutorial of i18n support with standard C/C++ and an easy used library ustring which is a template wrapper for std::basic_string. (update: 2005/07/31)
5. patch for OGRE(> 1.0.3) to make it supports i18n (update: 2005/07/30)
Some screenshot or test:
1. showfont.c(included in test.tar.gz) example for SDL_ttf. screenshot1 and screenshot2(Japanese Input)
2. test.tar.gz: simple tests for SDL-IM. (update: 2005/08/28)
The binary package for SDL_im( Development Libraries ):
SDL-devel-1.2.8-VC6.zip
(Visual C++ 5,6,7)
SDL-devel-1.2.8-mingw32.tar.gz (Mingw32)
How to apply this patch?
1.
download SDL-1.2.8 and decompress it(ex. $tar zxvf
SDL-1.2.8.tar.gz).
2. download patch in the SDL-1.2.8 extracted
directory and decompress it(ex. $gzip -d
SDL_im-1.2.8-20050828.diff.gz).
3. patch this diff file in the
SDL-1.2.8 directory(ex. $patch -p1 <
SDL_im-1.2.8-20050731.diff).
4. Make sure the pre-processer symbol
is defined(ENABLE_IM_EVENT).
5. then, build SDL and enjoy it! :-)
Note: If you use Visual C++ in Win32, using DirectX and adding ENABLE_IM_EVENT define in your Makefile or Project file. If you use automake in MSYS, just check “--enable-im-event” and "--enable-directx" symbols when you command “./configure”.
There are the project files for VC6 and VC7.1: VisualC.zip, VisualC7.zip
There is the DirectX devel source for MinGW to build SDL: http://www.libsdl.org/extras/win32/common/
What platforms are supported?
This patch supported IME(Input Method Editor) in Win32 and XIM(X Input Method) in Linux(X11). It also supported to flip IME/XIM window in fullscreen mode.
How to use these new functions?
First, ensure your IM at least supporting one of three modes: Root, OverTheSpot, OnTheSpot.
(In GNU/Linux with XIM, if setting the environment variable "SDLIM_STYLE", SDL-IM will prefer to use variable setting. For example, in bash, we use $export SDLIM_STYLE=OverTheSpot to set variable, then SDL-IM will prefer to use OverTheSpot mode.)
And then, read following manual:
If you have any suggestion, question, or problem, please mail to: < dr.courage@gmail.com >
If you have interest in maintaining, please mail to: < jserv AT kaffe.org >
Why should I apply this patch?
I have two reasons to do this:
1.If you want to develop an online-game and distribute it to the world, especially to Asia, IM support is necessary.
2.There are many good GUI libraries based on SDL. If SDL supported IM, that means we can not only choose MFC, Qt or GTK+ for your window application, but also have many other GUI libraries to use. There is nothing better than feeling free to choose what you really want.
Can I patch SDL by myself?
Of course! It is NOT very hard to patch, because SDL's structure is clear and object-based. And what technology you have to know is just knowing how to create a window and let this main window receive events in your platform. I will be very glad if you are interested to make SDL supporting IM.
Do you need help?
Yes! I need your help:
1. In Win32 DirectDraw environment, although I had successfully flip IME window in fullscreen mode, the status window still can not be flipped. I don't know how to do this, If you know, please tell me.( This problem is solved! )
2. This patch doesn't have many tests. If you can test it by using Japanese, Korean or any other language using multi-byte characters, I will greatly appreciate your help.
3. If you have some window programming experience in Mac (Classic), MacOS X, FreeBSD or any other platform Please join me to implement IM support together! :-)
What are the important points to patch?
First, the reason SDL don't support IM now is that SDL have held up the events translation to IM server. In order to translate events to IM server, you have to find out where the events was held up:
1. In Win32(DirectX), in file “src/video/windx5/SDL_dx5events.c”, at function DX5_CheckInput, add TranslateMessage function in the first event loop.
2. In Linux(X11), in file “src/video/x11/SDL_x11events.c”, at function X11_DispatchEvent, add XFilterEvent function after XNextEvent.
Second, to understand the structure of SDL video event is important. All of the new function are the virtual members function of interface SDL_VideoDevice(see “src/video/SDL_sysvideo.h”). To implement any other platform, all you have to do is just to implement the virtual function. For example, the function X11_FlushIMString in “src/video/x11/SDL_x11events_c.h” and “src/video/x11/SDL_x11events.c” is the implement of virtual member “SDL_VideoDevice::FlushIMString”.
[To Be Continued..]
Page changes log:
2007/02/07: add a news and a hyperlink about a patch for pygame.
2007/01/06: fixed a bug crashed when typing ALT key in Japanese Windows XP.(Thanks Makoto HARADA!)
2004/12/27: This page/patch is available. :-)
2004/12/31: hosted in http://svn.csie.net/. Thanks jserv and lwhsu! :-D
2005/02/11:
Add something about new patches(especially for paraGUI-1.1.8), binary
libraries, and screenshots, and change a few rules about
SDL_FlushIMString interface.
2005/03/07: Add patch for
aedGUI-0.1.8a, and add UNICODE_to_UTF8 example in SDL_FlushIMString
manual.
2005/03/11: Add new patch(fix some utf-8 handle) for
aedGUI-0.1.8a.
2005/03/12: Optimize SDL_im and update it(source
only). Add Big5 and GB2312 main pages.
2005/07/25: Add ustring and
the OGRE i18n patch.
2005/07/30: Fix Ogre::font and update
SDL-IM.
2005/07/31: Solving the problem with SDL-IM that it can
not flip state window in win32 fullscreen mode and adding the the
explain of cvt_traits.
2005/08/28:
change the spec of SDL_FlushIMString(see the manual), add new option
pack "SDL_imm".
2005/09/02: fixed ustring and ogre patch
with some compiling error.
Copyright 2004-2005 L.Y.C., Taiwan(Formosa).