Skip to content
This repository has been archived by the owner on Aug 31, 2020. It is now read-only.

Commit

Permalink
Added missing validation of Eight Way directions of stick - fixed #98
Browse files Browse the repository at this point in the history
  • Loading branch information
juliagoda committed May 20, 2020
1 parent 3d76964 commit 78d94f4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ if (UNIX)
find_package(Qt5Network REQUIRED)
find_package(Qt5LinguistTools REQUIRED)
find_package(Qt5Concurrent REQUIRED)
#find_package(Qt5Test REQUIRED)

if (WITH_X11)
find_package(Qt5X11Extras REQUIRED)
Expand Down Expand Up @@ -477,6 +478,7 @@ endif(UNIX)
${antimicroX_RESOURCES_RCC}
)

#target_link_libraries (antilib Qt5::Widgets Qt5::Core Qt5::Test Qt5::Gui Qt5::Network Qt5::Concurrent ${SDL_LIBRARY} ${LIBS})
target_link_libraries (antilib Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Network Qt5::Concurrent ${SDL_LIBRARY} ${LIBS})

if (WITH_X11)
Expand Down
20 changes: 19 additions & 1 deletion src/joycontrolstick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <QXmlStreamWriter>
#include <QLabel>
#include <QPointer>
//#include <QtTest/QTest>

const JoyControlStick::JoyMode JoyControlStick::DEFAULTMODE = JoyControlStick::StandardMode;

Expand Down Expand Up @@ -4508,7 +4509,13 @@ JoyControlStick::setDirButtonsUpdateInitAccel(JoyControlStick::JoyStickDirection
qInstallMessageHandler(MessageHandler::myMessageOutput);

QHash<JoyStickDirections, JoyControlStickButton*> apphash = getButtonsForDirection(direction);

// QVERIFY(apphash.isEmpty() == false);

QHashIterator<JoyStickDirections, JoyControlStickButton*> iter(apphash);

// QVERIFY(iter.hasNext() == true);

while (iter.hasNext())
{
JoyControlStickButton *button = iter.next().value();
Expand Down Expand Up @@ -4556,7 +4563,18 @@ JoyControlStick::getButtonsForDirection(JoyControlStick::JoyStickDirections dire
}
case EightWayMode:
{
temphash.insert(direction, buttons.value(direction));
if ((direction == JoyControlStick::StickUp) ||
(direction == JoyControlStick::StickDown) ||
(direction == JoyControlStick::StickLeft) ||
(direction == JoyControlStick::StickRight) ||
(direction == JoyControlStick::StickRightUp) ||
(direction == JoyControlStick::StickRightDown) ||
(direction == JoyControlStick::StickLeftDown) ||
(direction == JoyControlStick::StickLeftUp))
{
temphash.insert(direction, buttons.value(direction));
}

break;
}
case FourWayCardinal:
Expand Down

1 comment on commit 78d94f4

@Lycanite
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh awesome, thanks for this!

Please sign in to comment.