MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / keyboardPress

Method keyboardPress

src/Engine/InteractiveSurface.cpp:362–378  ·  view source on GitHub ↗

* Called every time there's a keyboard press when the surface is focused. * Allows the surface to have custom functionality for this action, * and can be called externally to simulate the action. * @param action Pointer to an action. * @param state State that the action handlers belong to. */

Source from the content-addressed store, hash-verified

360 * @param state State that the action handlers belong to.
361 */
362void InteractiveSurface::keyboardPress(Action *action, State *state)
363{
364 std::map<SDLKey, ActionHandler>::iterator allHandler = _keyPress.find(SDLK_ANY);
365 std::map<SDLKey, ActionHandler>::iterator oneHandler = _keyPress.find(action->getDetails()->key.keysym.sym);
366 if (allHandler != _keyPress.end())
367 {
368 ActionHandler handler = allHandler->second;
369 (state->*handler)(action);
370 }
371 // Check if Ctrl, Alt and Shift aren't pressed
372 bool mod = ((action->getDetails()->key.keysym.mod & (KMOD_CTRL|KMOD_ALT|KMOD_SHIFT)) != 0);
373 if (oneHandler != _keyPress.end() && !mod)
374 {
375 ActionHandler handler = oneHandler->second;
376 (state->*handler)(action);
377 }
378}
379
380/**
381 * Called every time there's a keyboard release over the surface.

Callers

nothing calls this directly

Calls 1

getDetailsMethod · 0.80

Tested by

no test coverage detected