Game Development Community

TGE1.5.2 Unicode problems

by Hongtao Wang · in Torque Game Engine · 06/20/2007 (12:50 am) · 0 replies

As David Tan's mothod, Click Here

David Tan wrote:

1) after
Win32PlatState winState;

add:
static bool g_bImeInComposition = false;

2)find
void Platform::disableKeyboardTranslation(void)

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:
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() )      
    {            
     }
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;         
          }      
    }
I do as above, but the input chinese can not display in the text field at all!

Then I comment out two lines as below:
//ImmGetConversionStatus( hIMC, &dwConversion, &dwSentence );
           //ImmReleaseContext(winState.appWindow,hIMC);
It seems work, but with problems:

1) some charactors will be diplayed two times, such as 11 11,, 22 22 22,, 333333,,

2) without text input field, the IME window display also.