Added a special value of -1 for centered joystick POV position

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1329 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2010-01-06 08:51:25 +00:00
parent db72c6e47c
commit 5eaec85d87
3 changed files with 17 additions and 2 deletions

View File

@ -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)
};

View File

@ -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;
}
}

View File

@ -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)