Skip to content

Commit

Permalink
Fix ImGuiKey enum usage (#219)
Browse files Browse the repository at this point in the history
ImGui changed how keyboard is handled. there's no ImGuiKey_ enum anymore
  • Loading branch information
hulakdar committed Sep 27, 2022
1 parent e0bf635 commit c77f8ba
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions imgui-SFML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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<ImGuiKey_>(key);
finalKey = static_cast<ImGuiKey>(key);
}
assert(joystickButton < sf::Joystick::ButtonCount);
s_currWindowCtx->joystickMapping[joystickButton] = finalKey;
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit c77f8ba

Please sign in to comment.