diff --git a/src/SFML/Window/Joystick.hpp b/src/SFML/Window/Joystick.hpp index 33e684e1a..6dd1b6e20 100644 --- a/src/SFML/Window/Joystick.hpp +++ b/src/SFML/Window/Joystick.hpp @@ -41,6 +41,18 @@ namespace priv //////////////////////////////////////////////////////////// struct JoystickState { + JoystickState() + { + // Default value for axes + for (int i = 0; i < Joy::AxisCount; ++i) + Axis[i] = 0.f; + Axis[Joy::AxisPOV] = -1.f; + + // Default value for buttons + for (int i = 0; i < Joy::ButtonCount; ++i) + Buttons[i] = false; + } + float Axis[Joy::AxisCount]; ///< Position on each axis in range [-100, 100] (except POV which is [0, 360]) bool Buttons[Joy::ButtonCount]; ///< Status of each button (true = pressed) }; diff --git a/src/SFML/Window/Linux/Joystick.cpp b/src/SFML/Window/Linux/Joystick.cpp index b14a292b0..e8267d482 100644 --- a/src/SFML/Window/Linux/Joystick.cpp +++ b/src/SFML/Window/Linux/Joystick.cpp @@ -145,7 +145,7 @@ JoystickState Joystick::UpdateState() { if (myPovY == 1) myState.Axis[Joy::AxisPOV] = 270.f; else if (myPovY == -1) myState.Axis[Joy::AxisPOV] = 90.f; - else myState.Axis[Joy::AxisPOV] = 0.f; // what is it supposed to be?? + else myState.Axis[Joy::AxisPOV] = -1.f; } } diff --git a/src/SFML/Window/Win32/Joystick.cpp b/src/SFML/Window/Win32/Joystick.cpp index 486bbb403..5d37e4c7b 100644 --- a/src/SFML/Window/Win32/Joystick.cpp +++ b/src/SFML/Window/Win32/Joystick.cpp @@ -118,7 +118,10 @@ JoystickState Joystick::UpdateState() State.Axis[Joy::AxisV] = (Pos.dwVpos - (Caps.wVmax + Caps.wVmin) / 2.f) * 200.f / (Caps.wVmax - Caps.wVmin); // POV - State.Axis[Joy::AxisPOV] = Pos.dwPOV / 100.f; + if (Pos.dwPOV != 0xFFFF) + State.Axis[Joy::AxisPOV] = Pos.dwPOV / 100.f; + else + State.Axis[Joy::AxisPOV] = -1.f; // Buttons for (unsigned int i = 0; i < GetButtonsCount(); ++i)