diff --git a/engine/include/Engine/Input.hpp b/engine/include/Engine/Input.hpp index ef24edc..d01869c 100755 --- a/engine/include/Engine/Input.hpp +++ b/engine/include/Engine/Input.hpp @@ -19,7 +19,6 @@ #include #include #include -#include #include "Gamepad.hpp" #include "InputEvents.hpp" #include "Mouse.hpp" @@ -206,7 +205,7 @@ namespace ASGE { private: using InputFnc = std::function; using InputFncPair = std::tuple; - using InputFncs = std::unordered_map; + using InputFncs = std::unordered_map; /** * Registers a callback function with an event. @@ -216,7 +215,6 @@ namespace ASGE { */ std::string registerCallback(EventType eventType, InputFnc inputFnc); InputFncs callback_funcs; //!< The registered callbacks. - uuids::uuid_random_generator UUIDGen; //!< The UUID random generator. }; } // namespace ASGE diff --git a/engine/src/Engine/Input.cpp b/engine/src/Engine/Input.cpp index 117dd82..3e38880 100644 --- a/engine/src/Engine/Input.cpp +++ b/engine/src/Engine/Input.cpp @@ -12,6 +12,8 @@ #include "Engine/Input.hpp" #include +#include + uuids::uuid_random_generator uuidGenerator() { std::random_device rd; @@ -24,7 +26,6 @@ uuids::uuid_random_generator uuidGenerator() { } ASGE::Input::Input() -: UUIDGen(uuidGenerator()) { callback_funcs.reserve(50); } @@ -36,8 +37,9 @@ ASGE::Input::~Input() ASGE::Input::CallbackID ASGE::Input::registerCallback(EventType type, InputFnc fnc) { - auto uuid = UUIDGen(); - callback_funcs[uuid] = InputFncPair(type, fnc); + static auto uuid_gen = uuidGenerator(); + auto uuid = uuid_gen(); + callback_funcs[uuids::to_string(uuid)] = InputFncPair(type, fnc); return to_string(uuid); } @@ -66,6 +68,5 @@ void ASGE::Input::sendEvent(EventType type, SharedEventData data) void ASGE::Input::unregisterCallback(CallbackID id) { - auto uuid = uuids::uuid::from_string(id).value(); - callback_funcs.erase(uuid); -} \ No newline at end of file + callback_funcs.erase(id); +}