Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ImGuiKey enum usage #219

Merged
merged 1 commit into from
Sep 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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