diff --git a/inferno/src/inferno/application.cpp b/inferno/src/inferno/application.cpp index a0bd06c..2b73c11 100644 --- a/inferno/src/inferno/application.cpp +++ b/inferno/src/inferno/application.cpp @@ -24,8 +24,9 @@ namespace Inferno { ASSERT(!s_instance, "Application already exists!"); s_instance = this; - // Initialize Settings + // Initialize Settings::initialize(); + Input::initialize(); m_window = std::make_unique(); m_window->setEventCallback(NF_BIND_EVENT(Application::onEvent)); diff --git a/inferno/src/inferno/input.cpp b/inferno/src/inferno/input.cpp index c4ea365..b102009 100644 --- a/inferno/src/inferno/input.cpp +++ b/inferno/src/inferno/input.cpp @@ -3,6 +3,7 @@ #include "inferno/application.h" #include "inferno/event/mouseevent.h" #include "inferno/input.h" +#include "inferno/log.h" #include "inferno/window.h" namespace Inferno { @@ -13,8 +14,18 @@ namespace Inferno { float Input::m_xOffset = 0.0f; float Input::m_yOffset = 0.0f; + void Input::initialize() + { + // Set cursor in the middle of the screen + m_xPosLast = Application::get().getWindow().getWidth() / 2.0f; + m_yPosLast = Application::get().getWindow().getHeight() / 2.0f; + + dbg(Log::Info) << "Input initialized"; + } + void Input::update() { + // Stop infinite mouse movement m_xOffset = 0.0f; m_yOffset = 0.0f; } diff --git a/inferno/src/inferno/input.h b/inferno/src/inferno/input.h index ccafd1c..138a3d0 100644 --- a/inferno/src/inferno/input.h +++ b/inferno/src/inferno/input.h @@ -9,6 +9,7 @@ namespace Inferno { class Input { public: + static void initialize(); static void update(); static bool onMousePosition(MousePositionEvent& e);