fixed occasional NoType mappings being saved and loaded

This commit is contained in:
thrust26 2021-04-30 14:00:30 +02:00
parent f4d135fc6e
commit 4d784d4a5b
2 changed files with 10 additions and 2 deletions

View File

@ -218,7 +218,7 @@ json JoyMap::saveMapping(const EventMode mode) const
json eventMappings = json::array();
for (const auto& [_mapping, _event]: sortedMap) {
if (_mapping.mode != mode) continue;
if(_mapping.mode != mode || _event == Event::NoType) continue;
json eventMapping = json::object();
@ -255,6 +255,10 @@ int JoyMap::loadMapping(const json& eventMappings, const EventMode mode)
JoyHatDir hatDirection = eventMapping.contains("hat") ? eventMapping.at("hatDirection").get<JoyHatDir>() : JoyHatDir::CENTER;
try {
// avoid blocking mappings for NoType events
if(eventMapping.at("event").get<Event::Type>() == Event::NoType)
continue;
add(
eventMapping.at("event").get<Event::Type>(),
mode,

View File

@ -241,7 +241,7 @@ json KeyMap::saveMapping(const EventMode mode) const
json mappings = json::array();
for (const auto& [_mapping, _event]: sortedMap) {
if (_mapping.mode != mode) continue;
if (_mapping.mode != mode || _event == Event::NoType) continue;
json mapping = json::object();
@ -264,6 +264,10 @@ int KeyMap::loadMapping(const json& mappings, const EventMode mode) {
for(const json& mapping : mappings)
{
try {
// avoid blocking mappings for NoType events
if(mapping.at("event").get<Event::Type>() == Event::NoType)
continue;
add(
mapping.at("event").get<Event::Type>(),
mode,