Skip to content

Commit

Permalink
🩹 [Input]: Remove dependency that was added in error
Browse files Browse the repository at this point in the history
  • Loading branch information
HuxyUK committed Nov 18, 2021
1 parent 6177e74 commit fed6275
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 1 addition & 3 deletions engine/include/Engine/Input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <functional>
#include <memory>
#include <unordered_map>
#include <uuid.h>
#include "Gamepad.hpp"
#include "InputEvents.hpp"
#include "Mouse.hpp"
Expand Down Expand Up @@ -206,7 +205,7 @@ namespace ASGE {
private:
using InputFnc = std::function<void(SharedEventData)>;
using InputFncPair = std::tuple<EventType, InputFnc>;
using InputFncs = std::unordered_map<uuids::uuid, InputFncPair>;
using InputFncs = std::unordered_map<std::string, InputFncPair>;

/**
* Registers a callback function with an event.
Expand All @@ -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

Expand Down
13 changes: 7 additions & 6 deletions engine/src/Engine/Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#include "Engine/Input.hpp"
#include <future>
#include <uuid.h>


uuids::uuid_random_generator uuidGenerator() {
std::random_device rd;
Expand All @@ -24,7 +26,6 @@ uuids::uuid_random_generator uuidGenerator() {
}

ASGE::Input::Input()
: UUIDGen(uuidGenerator())
{
callback_funcs.reserve(50);
}
Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
}
callback_funcs.erase(id);
}

0 comments on commit fed6275

Please sign in to comment.