![]() |
Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
#include "precompiled.h"#include "Hotkey.h"#include <boost/tokenizer.hpp>#include "lib/external_libraries/libsdl.h"#include "ps/CConsole.h"#include "ps/CLogger.h"#include "ps/CStr.h"#include "ps/ConfigDB.h"#include "ps/Globals.h"#include "ps/KeyName.h"
Classes | |
| struct | anonymous_namespace{Hotkey.cpp}::PressedHotkey |
| struct | anonymous_namespace{Hotkey.cpp}::ReleasedHotkey |
Namespaces | |
| namespace | anonymous_namespace{Hotkey.cpp} |
Functions | |
| static void | LoadConfigBindings (CConfigDB &configDB) |
| void | LoadHotkeys (CConfigDB &configDB) |
| void | UnloadHotkeys () |
| bool | isPressed (const SKey &key) |
| InReaction | HotkeyStateChange (const SDL_Event_ *ev) |
| Updates g_HotkeyMap. More... | |
| InReaction | HotkeyInputPrepHandler (const SDL_Event_ *ev) |
| Detects hotkeys that should fire. More... | |
| InReaction | HotkeyInputActualHandler (const SDL_Event_ *ev) |
| Actually fires hotkeys. More... | |
| bool | EventWillFireHotkey (const SDL_Event_ *ev, const CStr &keyname) |
| void | ResetActiveHotkeys () |
| Resets all currently active hotkeys (and clears in-flight hotkeys). More... | |
| bool | HotkeyIsPressed (const CStr &keyname) |
Variables | |
| static bool | unified [UNIFIED_LAST - UNIFIED_SHIFT] |
| std::unordered_map< int, KeyMapping > | g_HotkeyMap |
| std::unordered_map< std::string, bool > | anonymous_namespace{Hotkey.cpp}::g_HotkeyStatus |
| std::vector< PressedHotkey > | anonymous_namespace{Hotkey.cpp}::newPressedHotkeys |
| size_t | anonymous_namespace{Hotkey.cpp}::closestMapMatch = 0 |
| const SDL_Event_ * | anonymous_namespace{Hotkey.cpp}::currentEvent |
| std::vector< PressedHotkey > | anonymous_namespace{Hotkey.cpp}::pressedHotkeys |
| std::vector< SDL_Scancode_ > | anonymous_namespace{Hotkey.cpp}::activeScancodes |
| bool EventWillFireHotkey | ( | const SDL_Event_ * | ev, |
| const CStr & | keyname | ||
| ) |
| ev | will fire the hotkey |
| keyname. |
| InReaction HotkeyInputActualHandler | ( | const SDL_Event_ * | ev | ) |
Actually fires hotkeys.
| InReaction HotkeyInputPrepHandler | ( | const SDL_Event_ * | ev | ) |
Detects hotkeys that should fire.
This allows using EventWillFireHotkey, (and then possibly preventing those hotkeys from firing by handling the event).
Hotkey behaviour spec (see also tests):
| bool HotkeyIsPressed | ( | const CStr & | keyname | ) |
| InReaction HotkeyStateChange | ( | const SDL_Event_ * | ev | ) |
Updates g_HotkeyMap.
| bool isPressed | ( | const SKey & | key | ) |
|
static |
| void LoadHotkeys | ( | CConfigDB & | configDB | ) |
| void ResetActiveHotkeys | ( | ) |
Resets all currently active hotkeys (and clears in-flight hotkeys).
You should call this when something grabs key input, e.g. an input box, as those prevent keydown/keyup messages from reaching the hotkey system, and can lead to hotkeys being stuck active. NB: active hotkeys are released immediately and "HotkeyUp" message sent.
| void UnloadHotkeys | ( | ) |
| std::unordered_map<int, KeyMapping> g_HotkeyMap |
|
static |