diff --git a/engine/src/cubos/engine/input/bindings.cpp b/engine/src/cubos/engine/input/bindings.cpp index 9ccb4dfc60..5bd0b210f3 100644 --- a/engine/src/cubos/engine/input/bindings.cpp +++ b/engine/src/cubos/engine/input/bindings.cpp @@ -1,7 +1,4 @@ -#include -#include #include - #include using cubos::core::io::Key; @@ -36,93 +33,3 @@ std::unordered_map& InputBindings::axes() { return mAxes; } - -template <> -void cubos::core::data::old::serialize(Serializer& ser, const InputBindings& obj, const char* name) -{ - ser.beginObject(name); - ser.beginDictionary(obj.actions().size(), "actions"); - for (const auto& [actionName, action] : obj.actions()) - { - ser.write(actionName, nullptr); - ser.beginObject(nullptr); - ser.write(action.keys(), "keys"); - ser.write(action.gamepadButtons(), "gamepad"); - ser.write(action.mouseButtons(), "mouse"); - ser.endObject(); - } - ser.endDictionary(); - ser.beginDictionary(obj.axes().size(), "axes"); - for (const auto& [axisName, axis] : obj.axes()) - { - ser.write(axisName, nullptr); - ser.beginObject(nullptr); - ser.write(axis.positive(), "pos"); - ser.write(axis.negative(), "neg"); - ser.write(axis.gamepadAxes(), "gamepad"); - ser.endObject(); - } - ser.endDictionary(); - ser.endObject(); -} - -template <> -void cubos::core::data::old::deserialize(Deserializer& des, InputBindings& obj) -{ - des.beginObject(); - - std::size_t actionsSz = des.beginDictionary(); - for (std::size_t i = 0; i < actionsSz; ++i) - { - std::string action; - des.read(action); - des.beginObject(); - des.read(obj.actions()[action].keys()); - des.read(obj.actions()[action].gamepadButtons()); - des.read(obj.actions()[action].mouseButtons()); - des.endObject(); - } - des.endDictionary(); - - std::size_t axesSz = des.beginDictionary(); - for (std::size_t i = 0; i < axesSz; ++i) - { - std::string axis; - des.read(axis); - des.beginObject(); - des.read(obj.axes()[axis].positive()); - des.read(obj.axes()[axis].negative()); - des.read(obj.axes()[axis].gamepadAxes()); - des.endObject(); - } - des.endDictionary(); - - des.endObject(); -} - -// This is a specialization of the serialize and deserialize functions for std::pair. -// Overloading these functions allows for human-readable serialization of the keybindings. - -template <> -void cubos::core::data::old::serialize(Serializer& ser, const std::pair& obj, - const char* name) -{ - ser.write(modifiersToString(obj.second) + keyToString(obj.first), name); -} - -template <> -void cubos::core::data::old::deserialize(Deserializer& des, std::pair& obj) -{ - std::string str; - des.readString(str); - - std::size_t split = str.find_last_of('-'); - if (split == std::string::npos) - { - obj = {stringToKey(str), Modifiers::None}; - } - else - { - obj = {stringToKey(str.substr(split + 1)), stringToModifiers(str.substr(0, split + 1))}; - } -}