begin to support text input

actorid
Jordan Milne 12 years ago
parent 5fa77da9d4
commit cb01df49c0

@ -413,6 +413,7 @@ namespace MWInput
}
#endif
*/
MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(arg.keysym.sym), text);
return true;

@ -27,8 +27,10 @@ namespace MWInput
MWSDLInputWrapper::~MWSDLInputWrapper()
{
SDL_DestroyWindow(mSDLWindow);
if(mSDLWindow != NULL)
SDL_DestroyWindow(mSDLWindow);
mSDLWindow = NULL;
SDL_StopTextInput();
SDL_Quit();
}
@ -52,6 +54,8 @@ namespace MWInput
if(mSDLWindow == NULL)
return false;
SDL_StartTextInput();
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
//linux-specific event-handling fixups
SDL_SysWMinfo wm_info;
@ -119,7 +123,7 @@ namespace MWInput
break;
case SDL_KEYDOWN:
mKeyboardListener->keyPressed(evt.key);
_handleKeyPress(evt.key);
break;
case SDL_KEYUP:
mKeyboardListener->keyReleased(evt.key);
@ -228,4 +232,23 @@ namespace MWInput
warpMouse(width / 2, height / 2);
}
}
void MWSDLInputWrapper::_handleKeyPress(SDL_KeyboardEvent &evt)
{
//SDL keyboard events are followed by the actual text those keys would generate
//to account for languages that require multiple keystrokes to produce a key.
//Look for an event immediately following ours, assuming each key produces exactly
//one character.
//TODO: This won't work for multibyte characters, but MyGUI is the only consumer
//of these, does it even support multibyte characters?
SDL_Event text_evts[1];
if(SDL_PeepEvents(text_evts, 1, SDL_GETEVENT, SDL_TEXTINPUT, SDL_TEXTINPUT) != 0)
{
evt.keysym.unicode = text_evts[0].text.text[0];
}
mKeyboardListener->keyPressed(evt);
}
}

@ -30,6 +30,8 @@ namespace MWInput
bool _handleWarpMotion(const SDL_MouseMotionEvent& evt);
void _wrapMousePointer(const SDL_MouseMotionEvent &evt);
void _handleKeyPress(SDL_KeyboardEvent& evt);
bool _start();
ICS::MWSDLMouseListener* mMouseListener;

Loading…
Cancel
Save