Migration fixes.

This commit is contained in:
Christian Speckner 2020-11-28 21:04:26 +01:00
parent 730932355f
commit e3e0fc5a47
4 changed files with 17 additions and 8 deletions

View File

@ -269,11 +269,18 @@ json JoyMap::convertLegacyMapping(string list)
json eventMapping = json::object();
eventMapping["event"] = Event::Type(event);
eventMapping["button"] = button;
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);
}

View File

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

View File

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

View File

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