Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp
/* Copyright (C) 2019 Wildfire Games. | /* Copyright (C) 2020 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 183 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