diff options
Diffstat (limited to 'backends')
-rw-r--r-- | backends/keymapper/keymap.h | 2 | ||||
-rw-r--r-- | backends/keymapper/keymapper.cpp | 21 | ||||
-rw-r--r-- | backends/keymapper/keymapper.h | 14 | ||||
-rw-r--r-- | backends/keymapper/remap-dialog.cpp | 20 |
4 files changed, 23 insertions, 34 deletions
diff --git a/backends/keymapper/keymap.h b/backends/keymapper/keymap.h index ae8748c37d..35ad732bdc 100644 --- a/backends/keymapper/keymap.h +++ b/backends/keymapper/keymap.h @@ -49,7 +49,7 @@ template<> struct Hash<KeyState> : public UnaryFunction<KeyState, uint> { uint operator()(const KeyState &val) const { - return (uint)(val.keycode * (val.flags << 1)); + return (uint)val.keycode | ((uint)val.flags << 24); } }; diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index c64732a618..500c2b031b 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -32,22 +32,21 @@ namespace Common { void Keymapper::Domain::addKeymap(Keymap *map) { - KeymapMap::iterator it = _keymaps.find(map->getName()); - if (it != _keymaps.end()) - delete _keymaps[map->getName()]; - _keymaps[map->getName()] = map; + iterator it = find(map->getName()); + if (it != end()) + delete it->_value; + setVal(map->getName(), map); } void Keymapper::Domain::deleteAllKeyMaps() { - KeymapMap::iterator it; - for (it = _keymaps.begin(); it != _keymaps.end(); it++) + for (iterator it = begin(); it != end(); it++) delete it->_value; - _keymaps.clear(); + clear(); } Keymap *Keymapper::Domain::getKeymap(const String& name) { - KeymapMap::iterator it = _keymaps.find(name); - if (it != _keymaps.end()) + iterator it = find(name); + if (it != end()) return it->_value; else return 0; @@ -149,8 +148,8 @@ bool Keymapper::mapKeyUp(const KeyState& key) { } bool Keymapper::mapKey(const KeyState& key, bool keyDown) { - if (!_enabled) return false; - if (_activeMaps.empty()) return false; + if (!_enabled || _activeMaps.empty()) + return false; Action *action = 0; if (keyDown) { diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index 74a9432ef7..3c6cd5bc36 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -49,10 +49,8 @@ public: }; /* Nested class that represents a set of keymaps */ - class Domain { - typedef HashMap<String, Keymap*, - IgnoreCase_Hash, IgnoreCase_EqualTo> KeymapMap; - + class Domain : public HashMap<String, Keymap*, + IgnoreCase_Hash, IgnoreCase_EqualTo> { public: Domain() : _configDomain(0) {} ~Domain() { @@ -72,16 +70,8 @@ public: Keymap *getKeymap(const String& name); - typedef KeymapMap::iterator iterator; - typedef KeymapMap::const_iterator const_iterator; - iterator begin() { return _keymaps.begin(); } - const_iterator begin() const { return _keymaps.begin(); } - iterator end() { return _keymaps.end(); } - const_iterator end() const { return _keymaps.end(); } - uint32 count() { return _keymaps.size(); } private: ConfigManager::Domain *_configDomain; - KeymapMap _keymaps; }; Keymapper(EventManager *eventMan); diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 8a7f5df35d..2c40904be9 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -67,17 +67,17 @@ void RemapDialog::open() { Keymapper::Domain *_gameKeymaps = 0; int keymapCount = 0; - if (_globalKeymaps->count() == 0) + if (_globalKeymaps->empty()) _globalKeymaps = 0; else - keymapCount += _globalKeymaps->count(); + keymapCount += _globalKeymaps->size(); if (ConfMan.getActiveDomain() != 0) { _gameKeymaps = &_keymapper->getGameDomain(); - if (_gameKeymaps->count() == 0) + if (_gameKeymaps->empty()) _gameKeymaps = 0; else - keymapCount += _gameKeymaps->count(); + keymapCount += _gameKeymaps->size(); } _keymapTable = (Keymap **)malloc(sizeof(Keymap*) * keymapCount); @@ -85,7 +85,8 @@ void RemapDialog::open() { Keymapper::Domain::iterator it; uint32 idx = 0; if (_globalKeymaps) { - if (divider) _kmPopUp->appendEntry(""); + if (divider) + _kmPopUp->appendEntry(""); for (it = _globalKeymaps->begin(); it != _globalKeymaps->end(); it++) { _kmPopUp->appendEntry(it->_value->getName() + " (Global)", idx); _keymapTable[idx++] = it->_value; @@ -93,7 +94,8 @@ void RemapDialog::open() { divider = true; } if (_gameKeymaps) { - if (divider) _kmPopUp->appendEntry(""); + if (divider) + _kmPopUp->appendEntry(""); for (it = _gameKeymaps->begin(); it != _gameKeymaps->end(); it++) { _kmPopUp->appendEntry(it->_value->getName() + " (Game)", idx); _keymapTable[idx++] = it->_value; @@ -110,10 +112,8 @@ void RemapDialog::open() { void RemapDialog::close() { _kmPopUp->clearEntries(); - if (_keymapTable) { - free(_keymapTable); - _keymapTable = 0; - } + free(_keymapTable); + _keymapTable = 0; if (_changes) ConfMan.flushToDisk(); Dialog::close(); |