diff --git a/src/input/controller.cpp b/src/input/controller.cpp index 262c83d5..7d31bf71 100644 --- a/src/input/controller.cpp +++ b/src/input/controller.cpp @@ -211,10 +211,10 @@ float AxisBinding::RetrieveCurrentValue() for (int i = 0; i < m_keybindings.count(); ++i) { float value = 0.0f; - m_keybindings[i].m1->GetKey(m_keybindings[i].m2); - value += m_keybindings[i].m1->GetKey(m_keybindings[i].m3) ? 1.0f : 0.0f; + m_keybindings[i].m1->key(m_keybindings[i].m2); + value += m_keybindings[i].m1->key(m_keybindings[i].m3) ? 1.0f : 0.0f; if (m_keybindings[i].m2 != -1) - value += m_keybindings[i].m1->GetKey(m_keybindings[i].m2) ? -1.0f : 0.0f; + value += m_keybindings[i].m1->key(m_keybindings[i].m2) ? -1.0f : 0.0f; if (value > max_positive) max_positive = value; diff --git a/src/input/controller.h b/src/input/controller.h index 39eb86c2..27401239 100644 --- a/src/input/controller.h +++ b/src/input/controller.h @@ -66,7 +66,7 @@ protected: m_current = false; for (int i = 0; i < m_keybindings.count(); ++i) { - m_current = m_current || m_keybindings[i].m1->GetKey(m_keybindings[i].m2); + m_current = m_current || m_keybindings[i].m1->key(m_keybindings[i].m2); } } diff --git a/src/input/input.cpp b/src/input/input.cpp index 45418a10..b0dae634 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -52,29 +52,29 @@ void InputDevice::SetTextInputActive(bool status) void InputDeviceInternal::AddKey(int index, const char* name) { if (index == -1) - index = m_keynames.count(); + index = (int)m_key_names.size(); - while (index >= m_keynames.count()) + while (index >= (int)m_key_names.size()) { - m_keynames.push(name); - m_keys.push(false); + m_key_names.push_back(name); + m_keys.push_back(false); } - m_keynames[index] = name; + m_key_names[index] = name; } void InputDeviceInternal::AddAxis(int index, const char* name, float sensitivity) { if (index == -1) - index = m_axisnames.count(); + index = (int)m_axis_names.size(); - while (index >= m_axisnames.count()) + while (index >= (int)m_axis_names.size()) { - m_axisnames.push(name); + m_axis_names.push_back(name); m_axis.push(0.0f, 1.0f); } - m_axisnames[index] = name; + m_axis_names[index] = name; m_axis[index].m1 = 0.0f; m_axis[index].m2 = sensitivity; } @@ -82,15 +82,15 @@ void InputDeviceInternal::AddAxis(int index, const char* name, float sensitivity void InputDeviceInternal::AddCursor(int index, const char* name) { if (index == -1) - index = m_cursornames.count(); + index = (int)m_cursor_names.size(); - while (index >= m_cursornames.count()) + while (index >= (int)m_cursor_names.size()) { - m_cursornames.push(name); + m_cursor_names.push_back(name); m_cursors.push(vec2::zero, ivec2::zero); } - m_cursornames[index] = name; + m_cursor_names[index] = name; } InputDeviceInternal* InputDeviceInternal::CreateStandardKeyboard() diff --git a/src/input/input.h b/src/input/input.h index ad906f9a..57da07b5 100644 --- a/src/input/input.h +++ b/src/input/input.h @@ -77,27 +77,30 @@ public: /** Gets the index of the corresponding key, needed to call GetKey */ ptrdiff_t GetKeyIndex(std::string const &name) const { - return GetItemIndex(name, m_keynames); + return GetItemIndex(name, m_key_names); } /** Gets the index of the corresponding axis, needed to call GetAxis */ ptrdiff_t GetAxisIndex(std::string const &name) const { - return GetItemIndex(name, m_axisnames); + return GetItemIndex(name, m_axis_names); } /** Gets the index of the corresponding cursor, needed to call GetCursor */ ptrdiff_t GetCursorIndex(std::string const &name) const { - return GetItemIndex(name, m_cursornames); + return GetItemIndex(name, m_cursor_names); } - /** Gets the current state of the given key, true being pressed and + /** Get the names of all available keys on this device */ + std::vector const& key_names() const { return m_key_names; } + + /** Get the current state of all keys */ + std::vector const &keys() const { return m_keys; } + + /** Get the current state of the given key, true being pressed and * false being released */ - bool GetKey(ptrdiff_t index) const - { - return m_keys[index]; - } + bool key(ptrdiff_t index) const { return m_keys[index]; } /** Gets the latest contents of text input. */ std::string GetText(); @@ -141,20 +144,15 @@ public: return m_axis[index].m2; } - /** Gets a list of the name of all available keys in this device */ - const array& GetAllKeys() const - { - return m_keynames; - } /** Gets a list of the name of all available axis in this device */ - const array& GetAllAxis() const + const std::vector& GetAllAxis() const { - return m_axisnames; + return m_axis_names; } /** Gets a list of the name of all available cursors in this device */ - const array& GetAllCursors() const + const std::vector& GetAllCursors() const { - return m_cursornames; + return m_cursor_names; } /** Gets a list of the name of all available input devices */ @@ -195,12 +193,12 @@ protected: std::string m_name; - array m_keynames; - array m_axisnames; - array m_cursornames; + std::vector m_key_names; + std::vector m_axis_names; + std::vector m_cursor_names; /** Key states (pressed/released) */ - array m_keys; + std::vector m_keys; /** Text input state */ std::string m_text; @@ -238,13 +236,11 @@ private: static int joystick_count; template - ptrdiff_t GetItemIndex(std::string const &name, const array& a) const + size_t GetItemIndex(std::string const &name, std::vector const& a) const { - for (int i = 0; i < a.count(); ++i) - { + for (size_t i = 0; i < a.size(); ++i) if (a[i] == name) return i; - } return -1; }