diff --git a/src/common/KeyMap.cxx b/src/common/KeyMap.cxx index 1113976fa..e80d951ae 100644 --- a/src/common/KeyMap.cxx +++ b/src/common/KeyMap.cxx @@ -70,6 +70,20 @@ Event::Type KeyMap::get(const int mode, const int key, const int mod) const return get(Mapping(mode, key, mod)); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool KeyMap::check(const Mapping& mapping) const +{ + auto find = myMap.find(convertMod(mapping)); + + return (find != myMap.end()); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool KeyMap::check(const int mode, const int key, const int mod) const +{ + return check(Mapping(mode, key, mod)); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string KeyMap::getDesc(const Mapping& mapping) const { @@ -137,6 +151,8 @@ std::vector KeyMap::getEventMapping(const Event::Type event, co if (item.second == event && item.first.mode == mode) map.push_back(item.first); + int i = 0; + return map; } diff --git a/src/common/KeyMap.hxx b/src/common/KeyMap.hxx index 7b8454e69..3b2e4129e 100644 --- a/src/common/KeyMap.hxx +++ b/src/common/KeyMap.hxx @@ -69,6 +69,10 @@ class KeyMap Event::Type get(const Mapping& mapping) const; Event::Type get(const int mode, const int key, const int mod) const; + /** Check if a mapping exists */ + bool check(const Mapping& mapping) const; + bool check(const int mode, const int key, const int mod) const; + /** Get mapping description */ string getDesc(const Mapping& mapping) const; string getDesc(const int mode, const int key, const int mod) const; diff --git a/src/common/PKeyboardHandler.cxx b/src/common/PKeyboardHandler.cxx index 5c7a7749e..0503bc7aa 100644 --- a/src/common/PKeyboardHandler.cxx +++ b/src/common/PKeyboardHandler.cxx @@ -67,10 +67,10 @@ void PhysicalKeyboardHandler::setDefaultMapping(Event::Type event, EventMode mod { if (updateDefaults) { - // if there is no existing mapping for the event and + // if there is no existing mapping for the event or // the default mapping for the event is unused, set default key for event - if (myKeyMap.getEventMapping(k_event, mode).size() == 0 && - myKeyMap.get(mode, key, mod) == Event::Type::NoType) + if (myKeyMap.getEventMapping(k_event, mode).size() == 0 || + !myKeyMap.check(mode, key, mod)) { myKeyMap.add(k_event, mode, key, mod); } @@ -200,6 +200,7 @@ void PhysicalKeyboardHandler::setDefaultMapping(Event::Type event, EventMode mod setDefaultKey(Event::UITabNext , KBDK_TAB, KBDM_CTRL); setDefaultKey(Event::UIPrevDir , KBDK_BACKSPACE); + setDefaultKey(Event::ToggleFullScreen, KBDK_RETURN, KBDM_ALT); // FIXME - use the R77 define in the final release // use the '1' define for testing