Changeset View
Changeset View
Standalone View
Standalone View
source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp
Show First 20 Lines • Show All 192 Lines • ▼ Show 20 Lines | MESSAGEHANDLER(GuiKeyEvent) | ||||
SDL_Event_ ev = { { 0 } }; | SDL_Event_ ev = { { 0 } }; | ||||
ev.ev.type = msg->pressed ? SDL_KEYDOWN : SDL_KEYUP; | ev.ev.type = msg->pressed ? SDL_KEYDOWN : SDL_KEYUP; | ||||
ev.ev.key.keysym.sym = (SDL_Keycode)(int)msg->sdlkey; | ev.ev.key.keysym.sym = (SDL_Keycode)(int)msg->sdlkey; | ||||
in_dispatch_event(&ev); | in_dispatch_event(&ev); | ||||
} | } | ||||
MESSAGEHANDLER(GuiCharEvent) | MESSAGEHANDLER(GuiCharEvent) | ||||
{ | { | ||||
// wxWidgets has special Char events but SDL doesn't, so convert it to | // Simulate special 'text input' events in the SDL | ||||
// a keydown+keyup sequence. (We do the conversion here instead of on | // This isn't quite compatible with WXWidget's handling, | ||||
// the wx side to avoid nondeterministic behaviour caused by async messaging.) | // so to avoid trouble we only send 'letter-like' ASCII input. | ||||
SDL_Event_ ev = { { 0 } }; | SDL_Event_ ev = { { 0 } }; | ||||
ev.ev.type = SDL_KEYDOWN; | ev.ev.type = SDL_TEXTEDITING; | ||||
ev.ev.key.keysym.sym = (SDL_Keycode)(int)msg->sdlkey; | ev.ev.text.type = SDL_TEXTEDITING; | ||||
ev.ev.text.text[0] = (char)msg->sdlkey; | |||||
ev.ev.text.text[1] = (char)0; | |||||
in_dispatch_event(&ev); | in_dispatch_event(&ev); | ||||
ev.ev.type = SDL_KEYUP; | ev.ev.type = SDL_TEXTINPUT; | ||||
ev.ev.text.type = SDL_TEXTINPUT; | |||||
ev.ev.text.text[0] = (char)msg->sdlkey; | |||||
ev.ev.text.text[1] = (char)0; | |||||
in_dispatch_event(&ev); | in_dispatch_event(&ev); | ||||
} | } | ||||
} | } |
Wildfire Games · Phabricator