From 6c2fc3716c9c6c68e982b243af5f7ed04fb35e86 Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Tue, 19 Nov 2024 15:16:16 +0100 Subject: button handling --- src/crepe/system/InputSystem.cpp | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src/crepe/system/InputSystem.cpp') diff --git a/src/crepe/system/InputSystem.cpp b/src/crepe/system/InputSystem.cpp index e69de29..b7a86f4 100644 --- a/src/crepe/system/InputSystem.cpp +++ b/src/crepe/system/InputSystem.cpp @@ -0,0 +1,52 @@ +#include "ComponentManager.h" +#include "../api/Button.h" +#include "../api/EventManager.h" +#include "../api/Transform.h" +#include "../api/Event.h" + +#include "system/InputSystem.h" + +using namespace crepe; + +InputSystem::InputSystem(ComponentManager &component_manager) + : System(component_manager) { + auto &event_manager = EventManager::get_instance(); + + event_manager.subscribe([this](const MouseClickEvent &event) { + return this->handle_click(event); + }); + + event_manager.subscribe([this](const MouseMoveEvent &event) { + return this->handle_move(event); + }); +} + +void InputSystem::update() { +} + +bool InputSystem::handle_click(const MouseClickEvent &event) { + ComponentManager &mgr = this->component_manager; + + std::vector> buttons = + mgr.get_components_by_type