5a10a883fb
Currently implemented a 2D camera class that creates an orthographic projection matrix. TODO is implementing a 3D camera class and test program.
81 lines
1.5 KiB
C++
81 lines
1.5 KiB
C++
#include "InputManager.h"
|
|
|
|
InputManager::InputManager() {}
|
|
|
|
|
|
InputManager::~InputManager() {}
|
|
|
|
void InputManager::mark()
|
|
{
|
|
m_keys_pressed.clear();
|
|
m_mouse_delta = { 0, 0 };
|
|
m_scroll_distance = 0;
|
|
}
|
|
|
|
void InputManager::key_down(KeyCode key_code)
|
|
{
|
|
if (!m_keys_down[key_code])
|
|
{
|
|
m_keys_down[key_code] = true;
|
|
m_keys_pressed[key_code] = true;
|
|
}
|
|
}
|
|
|
|
void InputManager::key_up(KeyCode key_code)
|
|
{
|
|
m_keys_down[key_code] = false;
|
|
m_keys_pressed[key_code] = false;
|
|
}
|
|
|
|
void InputManager::mouse_move(const ivec2& position)
|
|
{
|
|
m_mouse_delta += position - m_mouse_position;
|
|
m_mouse_position = position;
|
|
}
|
|
|
|
void InputManager::mouse_scroll(int distance)
|
|
{
|
|
m_scroll_distance += distance;
|
|
}
|
|
|
|
bool InputManager::is_key_down(KeyCode key_code) const
|
|
{
|
|
auto iter = m_keys_down.find(key_code);
|
|
if (iter == m_keys_down.end())
|
|
return false;
|
|
else
|
|
return iter->second;
|
|
}
|
|
|
|
bool InputManager::is_key_pressed(KeyCode key_code) const
|
|
{
|
|
auto iter = m_keys_pressed.find(key_code);
|
|
if (iter == m_keys_pressed.end())
|
|
return false;
|
|
else
|
|
return iter->second;
|
|
}
|
|
|
|
bool InputManager::is_key_released(KeyCode key_code) const
|
|
{
|
|
auto iter = m_keys_pressed.find(key_code);
|
|
if (iter == m_keys_pressed.end())
|
|
return false;
|
|
else
|
|
return !iter->second;
|
|
}
|
|
|
|
const ivec2& InputManager::get_mouse_position() const
|
|
{
|
|
return m_mouse_position;
|
|
}
|
|
|
|
const ivec2& InputManager::get_mouse_delta() const
|
|
{
|
|
return m_mouse_delta;
|
|
}
|
|
|
|
const int& InputManager::get_scroll_distance() const
|
|
{
|
|
return m_scroll_distance;
|
|
} |