Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#83 Support IME inputs on Windows (with characters in system locale codepage)



It will be nice to add support for IME inputs on Windows in system locale codepage.
It allows for example to enter characters in Chinese GBK charset encoding.

For IME description look at http://msdn.microsoft.com/en-us/goglobal/bb688135.aspx

For example, the WM_IME_CHAR message could be handled by the Special callback (see attached code to patch freeglut_main.c fgWindowProc).


1 Attachments


  • Thanks for the suggestion. Not having access to a Chinese machine (or a machine with any other codepage active) and thus being unable to test, is this all that is needed?

    I see that char can be double byte (hence your wParam < 256 check), and that glutSpecialFunc indeed passes ints, so this should work in theory. We'll need to take this up on the list, see how others feel about it.

    • Chris06

      In order to test on your PC you can
      1) In MS Windows settings for "Region and Language", "Keyboards and Languages", "Change keyboards", add keyboard for "Chinese (Simplified, PRC)"
      2) In MS Windows settings for "Region and Language", "Administrative", "Change system locale", choose "Chinese (Simplified, PRC)".
      3) Use the language bar to switch between keyboards
      4) Use the IME editor to enter Chinese glyphs when the language is Chinese

  • A more specific question: glutSpecialFunc already fires for a bunch of keys (see the callback demo). list:

    define GLUT_KEY_F1 0x0001

    define GLUT_KEY_F2 0x0002

    define GLUT_KEY_F3 0x0003

    define GLUT_KEY_F4 0x0004

    define GLUT_KEY_F5 0x0005

    define GLUT_KEY_F6 0x0006

    define GLUT_KEY_F7 0x0007

    define GLUT_KEY_F8 0x0008

    define GLUT_KEY_F9 0x0009

    define GLUT_KEY_F10 0x000A

    define GLUT_KEY_F11 0x000B

    define GLUT_KEY_F12 0x000C

    define GLUT_KEY_LEFT 0x0064

    define GLUT_KEY_UP 0x0065

    define GLUT_KEY_RIGHT 0x0066

    define GLUT_KEY_DOWN 0x0067

    define GLUT_KEY_PAGE_UP 0x0068

    define GLUT_KEY_PAGE_DOWN 0x0069

    define GLUT_KEY_HOME 0x006A

    define GLUT_KEY_END 0x006B

    define GLUT_KEY_INSERT 0x006C

    define GLUT_KEY_NUM_LOCK 0x006D

    define GLUT_KEY_BEGIN 0x006E

    define GLUT_KEY_DELETE 0x006F

    define GLUT_KEY_SHIFT_L 0x0070

    define GLUT_KEY_SHIFT_R 0x0071

    define GLUT_KEY_CTRL_L 0x0072

    define GLUT_KEY_CTRL_R 0x0073

    define GLUT_KEY_ALT_L 0x0074

    define GLUT_KEY_ALT_R 0x0075

    Are you sure there would be no overlap between keys that can be generated by the IME and these? Because if so, we would need another way (another callback I suppose) instead, and cannot simple use glutSpecialFunc

  • Chris06

    If it is possible that special codes have values greater than 255, then of course it will be better to have a dedicated callback for IME inputs.

  • Hi Chris,

    Indeed, going through special should be fine.

    Thanks for the further suggestions. I tested as you suggested. This doesn't work cleanly I am afraid, when the IME window is open, every keypress on the keyboard generates a keyup as well. For me these almost always have keycode 229. When selecting a character in the IME, it does come out correctly through the special callback.

    Please see https://github.com/dcnieho/FreeGLUT/tree/feature_IMECHAR_callback and work with that to work out a working ime callback. Thats easier than sending pull requests through here. I'd be happy to add it in once it works cleanly.