Game Development Community

1.4CR2 unicode not work correct

by David Tan · in Torque Game Engine · 09/12/2005 (7:35 pm) · 45 replies

I notice that 1.4CR2 support unicode,but when I input chinese,it display both the key and the character,and the order is reverse when i input phrase .anyone has same error?
down.eptank.2288.org/disp.jpg
Unicode fix for chinese input has done!
#21
10/10/2006 (12:06 am)
I received a tip to check the handling of WM_IME_CHAR events. I found the event handler in platformWin32/winWindow.cc . Tracing though, I discover processCharMessage() in OurDispatchMessages() is receiving the characters in reverse order of input.

Looking further, I find that the events in sgWinMessages is being pop off the front (stack?). Alas, changing in to pop off the back doesn't work.

Ben?
#22
10/10/2006 (10:31 am)
Ah, that could make sense - if the IME is submitting grouped characters in "reverse" order (ie reverse of what TGE expects) then you'd get things mostly in order except for compound things... which would explain why it seems to work properly on our end to a naive eye!

Can you uncomment the various IME related log statements in winWindow.cc and show me the output you get for this situation?

Also - did you notice that the pop is two lines and not one?

msg = sgWinMessages.front();
      sgWinMessages.pop_front();

vs.

msg = sgWinMessages.back();
      sgWinMessages.pop_back();
#23
10/10/2006 (7:03 pm)
I did change the 2 "pop front" lines to "pop back" as you wrote. This results in the loss of the first character for all strings of >= 1 code point.

Here's the console output you asked.

OMG IME notify
OMG IME notify
OMG IME notify
OMG IME notify
OMG IME notify // output due to switching IME
OMG IME notify // y key
OMG IME notify // i key
OMG IME notify // e key
OMG IME notify // r key
OMG IME notify // s key
OMG IME notify // a key
OMG IME notify // n key
OMG IME notify // spacebar
OMG IME end comp
#24
10/10/2006 (7:33 pm)
Beyond the dropping, does it give correct order?

There's also one more line that dumps info on the character detected, in processCharMessage() -
// Con::printf("Got IME char code %x (%s)", charCode, out);

That line is of particular interest (sorry, I should have said so first thing!).

By the way - thanks a ton for helping to debug this problem! I suspect that if you stay the course on this issue, a solution will come together soon. I've had several other people report this bug, but they've always seemed to disappear before we could troubleshoot it...
#25
10/11/2006 (1:15 am)
Beyond dropping the first char (case of changing to pop back), the order is correct.

Console output (pop front)

OMG IME notify
OMG IME notify
OMG IME notify
OMG IME notify
OMG IME notify // output due to switching IME
OMG IME notify // y key
OMG IME notify // i key
OMG IME notify // e key
OMG IME notify // r key
OMG IME notify // s key
OMG IME notify // a key
OMG IME notify // n key
OMG IME notify // spacebar
Got IME char code 4e09 () // 3rd codepoint (simplified chinese for three)
Got IME char code 4e8c () // 2nd codepoint (simplified chinese for two)
Got IME char code 4e00 () // 1st codepoint (simplified chinese for one)
OMG IME end comp
#26
10/11/2006 (7:22 pm)
A long post to read...

I want to know if inputing Chinese will be okay in v1.5?

I think everyone who use Win2K/WinXP can add the IME to make a test, today I will try to input Koean and Japanese to see if it's a common problem.

When I input Chinese, not only the Chinese symbols are inverse, but also the English symbols (generate one Chinese symbol need typing several English symbols) are typed into the ingamee textbox before the generated Chinese symbols, in OS operation, the generation progress is in IME box, not in textbox.
#27
10/11/2006 (7:33 pm)
Hi sun, here is maybe a uesful link and code source for you, try it.

blog.csdn.net/EddieTorque/archive/2006/09/01/1152250.aspx

andy
#28
10/11/2006 (10:39 pm)
Thank you, Andy. I will try it. ;)
#29
10/12/2006 (1:02 pm)
Korean and Janpanese IME in Torque v1.4 has the same problem as the Chinese IME.
#30
10/19/2006 (8:45 pm)
Ping, any updates?
#31
10/27/2006 (6:56 am)
The unicode in TGE V1.5 still has problem.I have nothing to say.
#32
10/27/2006 (10:35 am)
Uh oh - I didn't get notifications on this thread except for the last one. Sorry about that, guys!

Sun Yu, did Prodigy Andy's fix take care of the problem?
#33
10/28/2006 (7:59 am)
The unicode input in v1.5 is disabled. I can not even bring up the IME... (Press Ctrl+Space or Ctrl + Shift in Chinese OS).

Ben Garney, I am not a coder and I haven't test the fix in that page provided by Prodigy Andy, but I read the article and I am sure the fix can resolve the problem. You can download the 2 .rar source files(one is for TBE, another is for TGE) in that page.
#34
11/01/2006 (7:06 pm)
I applied Andy's TGE fix on TGE1.4 + TLK but like Sun Yu with v1.5, I could'nt get the IME input window to come on.
#35
11/08/2006 (5:34 pm)
@Ron:
i tried Andy's TGE fix on TGE 1.4 with korean IME on XP
and it works only before "Platform::disableKeyboardTranslation" is called.

after that, even though "Platform::enableKeyboardTranslation" is called again,
IME input is not enabled. i can't figure out why.

so i just comment out "ImmAssociateContext( winState.appWindow, NULL );"
in " Platform::disableKeyboardTranslation" and it works great..

@everybody:

is it ok never to call "ImmAssociateContext( winState.appWindow, NULL );" ?

can anybody translate andy's comments to english for none chinese speaker?

i will try with TGE 1.5 because i just started my project with TGE 1.5.
i hope this IME problem is solved soon for none english users...

thanks everybody for this resource!!
#36
12/02/2006 (8:53 pm)
This is my fix for chinese input,and it work well.

1)after
Win32PlatState winState;
add:
static bool g_bImeInComposition = false;

2)find
void Platform::disableKeyboardTranslation(void)
{
#ifdef UNICODE
//   Con::printf("not translating...");
   ImmAssociateContext( winState.appWindow, NULL ); 
#endif
}
comment out
ImmAssociateContext( winState.appWindow, NULL );



3) at the begin of the function
static void processKeyMessage(UINT message, WPARAM wParam, LPARAM lParam)
add:
if (g_bImeInComposition) 	{
		return;
	}
...

4)
find
case WM_IME_STARTCOMPOSITION:
//         Con::printf("IME start comp1");
	 break;
change to :
case WM_IME_STARTCOMPOSITION:
//         Con::printf("IME start comp1");
			g_bImeInComposition = true;  
		 break;
5)find
case WM_IME_ENDCOMPOSITION:
//         Con::printf("IME start comp1");
		 break;

chang to
case WM_IME_STARTCOMPOSITION:
//               Con::printf("OMG IME end comp");
			g_bImeInComposition = false; 
		 break;

6)find
if (sgQueueEvents)
         {
         	WinMessage msg(message,wParam,lParam);

         	sgWinMessages.push_front(msg); 
			}

change to
if (sgQueueEvents)
         {
         	WinMessage msg(message,wParam,lParam);

         	sgWinMessages.push_back(msg); 
			}

7)find

if ( !mgr || !mgr->isKeyboardActive() )
      {
         switch ( message )
         {
            case WM_KEYUP:
            case WM_SYSKEYUP:
            case WM_KEYDOWN:
            case WM_SYSKEYDOWN:

               processKeyMessage(message, wParam, lParam);
               break;
        }
    }
 }
}

change to

if ( !mgr || !mgr->isKeyboardActive() )
      {
         switch ( message )
         {
            case WM_KEYUP:
            case WM_SYSKEYUP:
            case WM_KEYDOWN:
            case WM_SYSKEYDOWN:
											
			HKL hKL = GetKeyboardLayout( 0 );
			if ( ImmIsIME( hKL ))
			{
	          HIMC hIMC;
		      DWORD dwSize;
			   DWORD dwConversion, dwSentence; 
			  hIMC = ImmGetContext(winState.appWindow);
			  ImmGetConversionStatus( hIMC, &dwConversion, &dwSentence );
				int g_nImeCursor;  
				g_nImeCursor = ImmGetCompositionString( hIMC, GCS_CURSORPOS, NULL, 0 );
				ImmReleaseContext(winState.appWindow,hIMC);
				
				if (g_nImeCursor>0)
					g_bImeInComposition=true;

				switch(wParam)
				{				
					case VK_ESCAPE:				
					case VK_RETURN:				
					case VK_LEFT:				
					case VK_RIGHT:				
					case VK_DELETE:				
					case VK_BACK:					
					g_bImeInComposition=false;

				}				
			}

               processKeyMessage(message, wParam, lParam);
               break;
         }
      }
  }
}

hope it is help for everybody that use chinese input.
#37
12/03/2006 (2:18 pm)
Thanks, David! I hope this is useful, too - can people confirm this fixes their problems, please?
#38
01/18/2007 (5:18 pm)
Yes, David's fix solved my previous reported "reverse display" problem.
Thanks David!

Now, I face another somewhat related problem. I need to handle Hebrew, a right-to-left language.
Wanted to find out from folks here if anyone has done anything similar? My problem lies in 2 parts
- the input phase , where the input should echo the typed chars from right to left order.
- the display of right-to-left language text. Yet to find if the existing GUIs is able to support anything like this.

Appreciate any help/pointers. Thanks.
#39
06/18/2007 (4:12 pm)
I do as above, but in the text field there is no chinese display at all.

I use torque game engine 1.5.2.
#40
08/28/2007 (4:27 am)
I tried David Tan's method, but the function ImmIsIME() always return TRUE no matter which keyboard layout (even us-english) i used. could it be Imm32.Lib comes with torgue 1.5.2 is broken?