Game Development Community

Unicode input fixed

by Fyodor -bank- Osokin · in Torque Game Engine · 10/28/2007 (12:20 pm) · 2 replies

Hi.
While working with our game client for Linux I've found that I can type only English letters, and Torque does not want to understand that the language is switched to Russian (or any other).

Here is a fix (*hack*) forcing Torque to work with Unicode input:

x86UNIXFont.cc:
bool x86UNIXFont::isValidChar(const UTF16 str) const
{
  // we accept 0x20  == 32, and bigger
  [b]return (str > 0x19);[/b]
}
x86UNIXInputManager.cc:
inside void UInputManager::keyEvent(const SDL_Event& event):
...
   ievent.fValue = (action == SI_MAKE || action == SI_REPEAT) ? 1.0 : 0.0;

   [b]ievent.ascii = event.key.keysym.unicode;[/b]

   processKeyEvent(ievent);
   ...
inside bool UInputManager::processKeyEvent( InputEvent &event ):
comment out the ascii assignment:
...
   [b]//event.ascii = Input::getAscii( event.objInst, state );[/b]

   return modKey;

x86UNIXWindow.cc:
at the beginning of static bool InitSDL() change to:
if (SDL_Init(SDL_INIT_VIDEO) != 0)
      return false;
   [b]SDL_EnableUNICODE(1);[/b]
   atexit(SDL_Quit);
   ...

P.S. Confirmed to work on openSUSE and Gentoo.

#1
11/01/2007 (3:29 am)
Spaceba for sharing!
#2
11/07/2007 (8:14 am)
Great fix :) One more open issue less on my todo list. Thank you.