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:
parent
db72c6e47c
commit
5eaec85d87
@ -41,6 +41,18 @@ namespace priv
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
struct JoystickState
|
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])
|
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)
|
bool Buttons[Joy::ButtonCount]; ///< Status of each button (true = pressed)
|
||||||
};
|
};
|
||||||
|
@ -145,7 +145,7 @@ JoystickState Joystick::UpdateState()
|
|||||||
{
|
{
|
||||||
if (myPovY == 1) myState.Axis[Joy::AxisPOV] = 270.f;
|
if (myPovY == 1) myState.Axis[Joy::AxisPOV] = 270.f;
|
||||||
else if (myPovY == -1) myState.Axis[Joy::AxisPOV] = 90.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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
State.Axis[Joy::AxisV] = (Pos.dwVpos - (Caps.wVmax + Caps.wVmin) / 2.f) * 200.f / (Caps.wVmax - Caps.wVmin);
|
||||||
|
|
||||||
// POV
|
// 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
|
// Buttons
|
||||||
for (unsigned int i = 0; i < GetButtonsCount(); ++i)
|
for (unsigned int i = 0; i < GetButtonsCount(); ++i)
|
||||||
|
Loading…
Reference in New Issue
Block a user