From c77f8baf99e75dea98900db6f3e823c5217435cb Mon Sep 17 00:00:00 2001 From: Simon Kamoza Date: Tue, 27 Sep 2022 20:42:00 +0300 Subject: [PATCH] Fix ImGuiKey enum usage (#219) ImGui changed how keyboard is handled. there's no ImGuiKey_ enum anymore --- imgui-SFML.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/imgui-SFML.cpp b/imgui-SFML.cpp index ef211e9..4fb3c1b 100644 --- a/imgui-SFML.cpp +++ b/imgui-SFML.cpp @@ -192,7 +192,7 @@ struct WindowContext { sf::Vector2i touchPos; unsigned int joystickId; - ImGuiKey_ joystickMapping[sf::Joystick::ButtonCount]; + ImGuiKey joystickMapping[sf::Joystick::ButtonCount]; StickInfo dPadInfo; StickInfo lStickInfo; StickInfo rStickInfo; @@ -848,7 +848,7 @@ void SetJoystickMapping(int key, unsigned int joystickButton) { assert(s_currWindowCtx); // This function now expects ImGuiKey_* values. // For partial backwards compatibility, also expect some ImGuiNavInput_* values. - ImGuiKey_ finalKey; + ImGuiKey finalKey; switch (key) { case ImGuiNavInput_Activate: finalKey = ImGuiKey_GamepadFaceDown; @@ -872,7 +872,7 @@ void SetJoystickMapping(int key, unsigned int joystickButton) { break; default: assert(key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END); - finalKey = static_cast(key); + finalKey = static_cast(key); } assert(joystickButton < sf::Joystick::ButtonCount); s_currWindowCtx->joystickMapping[joystickButton] = finalKey; @@ -1312,7 +1312,7 @@ void initDefaultJoystickMapping() { void updateJoystickButtonState(ImGuiIO& io) { for (int i = 0; i < sf::Joystick::ButtonCount; ++i) { - ImGuiKey_ key = s_currWindowCtx->joystickMapping[i]; + ImGuiKey key = s_currWindowCtx->joystickMapping[i]; if (key != ImGuiKey_None) { bool isPressed = sf::Joystick::isButtonPressed(s_currWindowCtx->joystickId, i); if (s_currWindowCtx->windowHasFocus || !isPressed) { @@ -1322,7 +1322,7 @@ void updateJoystickButtonState(ImGuiIO& io) { } } -void updateJoystickAxis(ImGuiIO& io, ImGuiKey_ key, sf::Joystick::Axis axis, float threshold, +void updateJoystickAxis(ImGuiIO& io, ImGuiKey key, sf::Joystick::Axis axis, float threshold, float maxThreshold, bool inverted) { float pos = sf::Joystick::getAxisPosition(s_currWindowCtx->joystickId, axis); if (inverted) { @@ -1336,7 +1336,7 @@ void updateJoystickAxis(ImGuiIO& io, ImGuiKey_ key, sf::Joystick::Axis axis, flo } } -void updateJoystickAxisPair(ImGuiIO& io, ImGuiKey_ key1, ImGuiKey_ key2, sf::Joystick::Axis axis, +void updateJoystickAxisPair(ImGuiIO& io, ImGuiKey key1, ImGuiKey key2, sf::Joystick::Axis axis, float threshold, bool inverted) { updateJoystickAxis(io, key1, axis, -threshold, -100, inverted); updateJoystickAxis(io, key2, axis, threshold, 100, inverted);