Fix compatibility with the SDL2.0 release.

SDL2.0 removed SDL_HAPTIC_SQUARE because of ABI issues (see comment #7 on issue
6491 by Ryan C. Gordon from the SDL project). It will be reintroduced again in
2.1, so keep the code and #ifdef it away.
This commit is contained in:
Pierre Bourdon 2013-08-15 22:18:40 +02:00
parent 10f6117905
commit c3065ecb66
2 changed files with 8 additions and 0 deletions

View File

@ -131,12 +131,14 @@ Joystick::Joystick(SDL_Joystick* const joystick, const int sdl_index, const unsi
AddOutput(new SineEffect(m_state_out.back())); AddOutput(new SineEffect(m_state_out.back()));
} }
#ifdef SDL_HAPTIC_SQUARE
// square effect // square effect
if (supported_effects & SDL_HAPTIC_SQUARE) if (supported_effects & SDL_HAPTIC_SQUARE)
{ {
m_state_out.push_back(EffectIDState()); m_state_out.push_back(EffectIDState());
AddOutput(new SquareEffect(m_state_out.back())); AddOutput(new SquareEffect(m_state_out.back()));
} }
#endif // defined(SDL_HAPTIC_SQUARE)
// triangle effect // triangle effect
if (supported_effects & SDL_HAPTIC_TRIANGLE) if (supported_effects & SDL_HAPTIC_TRIANGLE)
@ -187,10 +189,12 @@ std::string Joystick::SineEffect::GetName() const
return "Sine"; return "Sine";
} }
#ifdef SDL_HAPTIC_SQUARE
std::string Joystick::SquareEffect::GetName() const std::string Joystick::SquareEffect::GetName() const
{ {
return "Square"; return "Square";
} }
#endif // defined(SDL_HAPTIC_SQUARE)
std::string Joystick::TriangleEffect::GetName() const std::string Joystick::TriangleEffect::GetName() const
{ {
@ -255,6 +259,7 @@ void Joystick::SineEffect::SetState(const ControlState state)
m_effect.changed = true; m_effect.changed = true;
} }
#ifdef SDL_HAPTIC_SQUARE
void Joystick::SquareEffect::SetState(const ControlState state) void Joystick::SquareEffect::SetState(const ControlState state)
{ {
if (state) if (state)
@ -276,6 +281,7 @@ void Joystick::SquareEffect::SetState(const ControlState state)
if (old != m_effect.effect.periodic.magnitude) if (old != m_effect.effect.periodic.magnitude)
m_effect.changed = true; m_effect.changed = true;
} }
#endif // defined(SDL_HAPTIC_SQUARE)
void Joystick::TriangleEffect::SetState(const ControlState state) void Joystick::TriangleEffect::SetState(const ControlState state)
{ {

View File

@ -106,6 +106,7 @@ private:
EffectIDState& m_effect; EffectIDState& m_effect;
}; };
#ifdef SDL_HAPTIC_SQUARE
class SquareEffect : public Output class SquareEffect : public Output
{ {
public: public:
@ -115,6 +116,7 @@ private:
private: private:
EffectIDState& m_effect; EffectIDState& m_effect;
}; };
#endif // defined(SDL_HAPTIC_SQUARE)
class TriangleEffect : public Output class TriangleEffect : public Output
{ {