diff --git a/src/input/controller.cpp b/src/input/controller.cpp index aea78275..38ecff1f 100644 --- a/src/input/controller.cpp +++ b/src/input/controller.cpp @@ -68,10 +68,8 @@ Array Controller::controllers; Controller::Controller(int nb_keys, int nb_axis) { m_gamegroup = GAMEGROUP_BEFORE; - m_nb_keys = nb_keys; - m_nb_axis = nb_axis; - m_keys = new KeyBinding[m_nb_keys]; - m_axis = new AxisBinding[m_nb_axis]; + m_keys.Resize(nb_keys); + m_axis.Resize(nb_axis); m_activate_nextframe = false; m_deactivate_nextframe = false; m_active = false; @@ -94,15 +92,11 @@ void Controller::TickGame(float seconds) { Entity::TickGame(seconds); - for (int i = 0; i < m_nb_keys; ++i) - { + for (int i = 0; i < m_keys.Count(); ++i) m_keys[i].Update(); - } - for (int i = 0; i < m_nb_axis; ++i) - { + for (int i = 0; i < m_axis.Count(); ++i) m_axis[i].Update(); - } if (m_activate_nextframe) m_active = true; diff --git a/src/input/controller.h b/src/input/controller.h index cece1542..af173ce8 100644 --- a/src/input/controller.h +++ b/src/input/controller.h @@ -82,14 +82,12 @@ public: /** Deactivate every active controller on next frame and return an array of deactivated (previously active) controllers */ static Array DeactivateAll(); - KeyBinding& GetKey(int index) { ASSERT(index >= 0 && index < m_nb_keys); return m_keys[index]; } - AxisBinding& GetAxis(int index) { ASSERT(index >= 0 && index < m_nb_axis); return m_axis[index]; } + KeyBinding& GetKey(int index) { return m_keys[index]; } + AxisBinding& GetAxis(int index) { return m_axis[index]; } protected: - KeyBinding* m_keys; - AxisBinding* m_axis; - int m_nb_keys; - int m_nb_axis; + Array m_keys; + Array m_axis; private: static Array controllers;