Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
delroth committed Aug 15, 2013
1 parent 10f6117 commit c3065ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp
Expand Up @@ -131,12 +131,14 @@ Joystick::Joystick(SDL_Joystick* const joystick, const int sdl_index, const unsi
AddOutput(new SineEffect(m_state_out.back()));
}

#ifdef SDL_HAPTIC_SQUARE
// square effect
if (supported_effects & SDL_HAPTIC_SQUARE)
{
m_state_out.push_back(EffectIDState());
AddOutput(new SquareEffect(m_state_out.back()));
}
#endif // defined(SDL_HAPTIC_SQUARE)

// triangle effect
if (supported_effects & SDL_HAPTIC_TRIANGLE)
Expand Down Expand Up @@ -187,10 +189,12 @@ std::string Joystick::SineEffect::GetName() const
return "Sine";
}

#ifdef SDL_HAPTIC_SQUARE
std::string Joystick::SquareEffect::GetName() const
{
return "Square";
}
#endif // defined(SDL_HAPTIC_SQUARE)

std::string Joystick::TriangleEffect::GetName() const
{
Expand Down Expand Up @@ -255,6 +259,7 @@ void Joystick::SineEffect::SetState(const ControlState state)
m_effect.changed = true;
}

#ifdef SDL_HAPTIC_SQUARE
void Joystick::SquareEffect::SetState(const ControlState state)
{
if (state)
Expand All @@ -276,6 +281,7 @@ void Joystick::SquareEffect::SetState(const ControlState state)
if (old != m_effect.effect.periodic.magnitude)
m_effect.changed = true;
}
#endif // defined(SDL_HAPTIC_SQUARE)

void Joystick::TriangleEffect::SetState(const ControlState state)
{
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.h
Expand Up @@ -106,6 +106,7 @@ class Joystick : public Core::Device
EffectIDState& m_effect;
};

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

class TriangleEffect : public Output
{
Expand Down

0 comments on commit c3065ec

Please sign in to comment.