fix default key mappings

This commit is contained in:
thrust26 2019-05-26 20:41:34 +02:00
parent 54decb2cdf
commit b45b192445
3 changed files with 24 additions and 3 deletions

View File

@ -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::Mapping> 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;
}

View File

@ -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;

View File

@ -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