diff --git a/src/common/JoyMap.cxx b/src/common/JoyMap.cxx index 409d2677c..6b8c95b42 100644 --- a/src/common/JoyMap.cxx +++ b/src/common/JoyMap.cxx @@ -269,11 +269,18 @@ json JoyMap::convertLegacyMapping(string list) json eventMapping = json::object(); eventMapping["event"] = Event::Type(event); - eventMapping["button"] = button; - eventMapping["axis"] = JoyAxis(axis); - eventMapping["axisDirection"] = JoyDir(adir); - eventMapping["hat"] = hat; - eventMapping["hatDirection"] = JoyHatDir(hdir); + + if (button != JOY_CTRL_NONE) eventMapping["button"] = button; + + if (JoyAxis(axis) != JoyAxis::NONE) { + eventMapping["axis"] = JoyAxis(axis); + eventMapping["axisDirection"] = JoyDir(adir); + } + + if (hat != -1) { + eventMapping["hat"] = hat; + eventMapping["hatDirection"] = JoyHatDir(hdir); + } eventMappings.push_back(eventMapping); } diff --git a/src/common/KeyMap.cxx b/src/common/KeyMap.cxx index 69ecd7593..2e493b331 100644 --- a/src/common/KeyMap.cxx +++ b/src/common/KeyMap.cxx @@ -234,7 +234,8 @@ json KeyMap::convertLegacyMapping(string list) mapping["event"] = Event::Type(event); mapping["key"] = StellaKey(key); - mapping["mod"] = StellaMod(mod); + + if (StellaMod(mod) != StellaMod::KBDM_NONE) mapping["mod"] = StellaMod(mod); convertedMapping.push_back(mapping); } diff --git a/src/common/PJoystickHandler.cxx b/src/common/PJoystickHandler.cxx index 206c98c4c..323caea1c 100644 --- a/src/common/PJoystickHandler.cxx +++ b/src/common/PJoystickHandler.cxx @@ -48,7 +48,7 @@ PhysicalJoystickHandler::PhysicalJoystickHandler( try { mappings = json::parse(serializedMapping); } catch (json::exception) { - Logger::info("converting legacy joystrick mappings"); + Logger::info("converting legacy joystick mappings"); mappings = convertLegacyMapping(serializedMapping); } diff --git a/src/common/PhysicalJoystick.cxx b/src/common/PhysicalJoystick.cxx index 6310c8e4d..488d1f318 100644 --- a/src/common/PhysicalJoystick.cxx +++ b/src/common/PhysicalJoystick.cxx @@ -129,11 +129,12 @@ json PhysicalJoystick::convertLegacyMapping(const string& mapping, const string& map.erase(0, 2); json mappingForMode = JoyMap::convertLegacyMapping(map); - mappingForMode["name"] = name; convertedMapping[jsonName(EventMode(mode))] = mappingForMode; } + convertedMapping["name"] = name; + return convertedMapping; }