mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Improve KeyPress handling (#15923)
* Pass KeyPress by value * TouchControls: add setting change callback for keybindings
This commit is contained in:
parent
ead44a27ca
commit
4ba438a7ec
7 changed files with 51 additions and 37 deletions
|
@ -367,7 +367,7 @@ bool KeyPress::loadFromScancode(const std::string &name)
|
|||
}
|
||||
|
||||
std::unordered_map<std::string, KeyPress> specialKeyCache;
|
||||
const KeyPress &KeyPress::getSpecialKey(const std::string &name)
|
||||
KeyPress KeyPress::getSpecialKey(const std::string &name)
|
||||
{
|
||||
auto &key = specialKeyCache[name];
|
||||
if (!key)
|
||||
|
@ -382,7 +382,7 @@ const KeyPress &KeyPress::getSpecialKey(const std::string &name)
|
|||
// A simple cache for quicker lookup
|
||||
static std::unordered_map<std::string, KeyPress> g_key_setting_cache;
|
||||
|
||||
const KeyPress &getKeySetting(const std::string &settingname)
|
||||
KeyPress getKeySetting(const std::string &settingname)
|
||||
{
|
||||
auto n = g_key_setting_cache.find(settingname);
|
||||
if (n != g_key_setting_cache.end())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue