Physics working
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
#include "HydraInputManager.h"
|
||||
#include "../windowmanager/HydraWindowManager.h"
|
||||
|
||||
void HydraInputManager::ProcessInput()
|
||||
void HydraInputManager::ProcessInput(bool reset)
|
||||
{
|
||||
bool quit = false;
|
||||
m_mouse_change = glm::vec2();
|
||||
m_key_down.clear();
|
||||
m_key_up.clear();
|
||||
if(reset)
|
||||
{
|
||||
std::fill(m_key_down, m_key_down+512, 0);
|
||||
std::fill(m_key_up, m_key_up+512, 0);
|
||||
}
|
||||
|
||||
while (!quit)
|
||||
{
|
||||
HydraKeyPressStuct key_press;
|
||||
@@ -18,13 +22,20 @@ void HydraInputManager::ProcessInput()
|
||||
{
|
||||
if (key_press.key_action == KEY_PRESS_ACTIONS::HYDRA_KEY_PRESSED)
|
||||
{
|
||||
m_keys[key_press.key_code] = 1;
|
||||
m_key_up.push_back(key_press.key_code);
|
||||
if(m_keys[key_press.key_code] == 0)
|
||||
{
|
||||
m_key_down[key_press.key_code] = 1;
|
||||
}
|
||||
m_keys[key_press.key_code] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
if(m_keys[key_press.key_code] == 1)
|
||||
{
|
||||
m_key_up[key_press.key_code] = 1;
|
||||
}
|
||||
m_keys[key_press.key_code] = 0;
|
||||
m_key_down.push_back(key_press.key_code);
|
||||
|
||||
}
|
||||
}
|
||||
if (m_key_presses.size() > 10000)
|
||||
@@ -78,5 +89,15 @@ void HydraInputManager::ProcessInput()
|
||||
|
||||
bool HydraInputManager::KeyPressed(HYDRA_KEY_CODES key)
|
||||
{
|
||||
return m_keys[(unsigned int)key] == 1;
|
||||
}
|
||||
return m_keys[static_cast<uint32_t>(key)] == 1;
|
||||
}
|
||||
|
||||
bool HydraInputManager::KeyDown(HYDRA_KEY_CODES key)
|
||||
{
|
||||
return m_key_down[static_cast<uint32_t>(key)] == 1;
|
||||
}
|
||||
|
||||
bool HydraInputManager::KeyUp(HYDRA_KEY_CODES key)
|
||||
{
|
||||
return m_key_up[static_cast<uint32_t>(key)] == 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user