mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Unconnected joysticks are no longer updated (on Windows)
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1195 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
953c73c5a6
commit
b5a17a832f
@ -45,6 +45,7 @@ void Joystick::Initialize(unsigned int Index)
|
|||||||
myIndex = JOYSTICKID1;
|
myIndex = JOYSTICKID1;
|
||||||
myNbAxes = 0;
|
myNbAxes = 0;
|
||||||
myNbButtons = 0;
|
myNbButtons = 0;
|
||||||
|
myIsConnected = false;
|
||||||
|
|
||||||
// Get the Index-th connected joystick
|
// Get the Index-th connected joystick
|
||||||
MMRESULT Error;
|
MMRESULT Error;
|
||||||
@ -60,6 +61,7 @@ void Joystick::Initialize(unsigned int Index)
|
|||||||
if (NbFound == Index)
|
if (NbFound == Index)
|
||||||
{
|
{
|
||||||
// Ok : store its parameters and return
|
// Ok : store its parameters and return
|
||||||
|
myIsConnected = true;
|
||||||
JOYCAPS Caps;
|
JOYCAPS Caps;
|
||||||
joyGetDevCaps(myIndex, &Caps, sizeof(Caps));
|
joyGetDevCaps(myIndex, &Caps, sizeof(Caps));
|
||||||
myNbAxes = Caps.wNumAxes;
|
myNbAxes = Caps.wNumAxes;
|
||||||
@ -84,6 +86,8 @@ JoystickState Joystick::UpdateState()
|
|||||||
{
|
{
|
||||||
JoystickState State = {0};
|
JoystickState State = {0};
|
||||||
|
|
||||||
|
if (myIsConnected)
|
||||||
|
{
|
||||||
// Get the joystick caps (for range conversions)
|
// Get the joystick caps (for range conversions)
|
||||||
JOYCAPS Caps;
|
JOYCAPS Caps;
|
||||||
if (joyGetDevCaps(myIndex, &Caps, sizeof(Caps)) == JOYERR_NOERROR)
|
if (joyGetDevCaps(myIndex, &Caps, sizeof(Caps)) == JOYERR_NOERROR)
|
||||||
@ -110,6 +114,7 @@ JoystickState Joystick::UpdateState()
|
|||||||
State.Buttons[i] = (Pos.dwButtons & (1 << i)) != 0;
|
State.Buttons[i] = (Pos.dwButtons & (1 << i)) != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return State;
|
return State;
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,7 @@ private :
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
bool myIsConnected; ///< Is there a joystick connected?
|
||||||
unsigned int myIndex; ///< Windows ID of the joystick
|
unsigned int myIndex; ///< Windows ID of the joystick
|
||||||
unsigned int myNbAxes; ///< Number of axis supported by the joystick
|
unsigned int myNbAxes; ///< Number of axis supported by the joystick
|
||||||
unsigned int myNbButtons; ///< Number of buttons supported by the joystick
|
unsigned int myNbButtons; ///< Number of buttons supported by the joystick
|
||||||
|
Loading…
Reference in New Issue
Block a user