more warning fixes

This commit is contained in:
Jordan Cristiano
2013-11-14 02:19:15 -05:00
parent ca5b3b4773
commit 39a4d4329d
27 changed files with 89 additions and 70 deletions

View File

@ -154,12 +154,13 @@ Joystick::~Joystick()
{
// stop/destroy all effects
SDL_HapticStopAll(m_haptic);
std::list<EffectIDState>::iterator
i = m_state_out.begin(),
e = m_state_out.end();
for ( ; i != e; ++i)
if (i->id != -1)
SDL_HapticDestroyEffect(m_haptic, i->id);
for (auto &i : m_state_out)
{
if (i.id != -1)
{
SDL_HapticDestroyEffect(m_haptic, i.id);
}
}
// close haptic first
SDL_HapticClose(m_haptic);
}
@ -210,7 +211,7 @@ void Joystick::ConstantEffect::SetState(ControlState state)
}
const Sint16 old = m_effect.effect.constant.level;
m_effect.effect.constant.level = state * 0x7FFF;
m_effect.effect.constant.level = (Sint16)(state * 0x7FFF);
if (old != m_effect.effect.constant.level)
m_effect.changed = true;
}
@ -228,7 +229,7 @@ void Joystick::RampEffect::SetState(ControlState state)
}
const Sint16 old = m_effect.effect.ramp.start;
m_effect.effect.ramp.start = state * 0x7FFF;
m_effect.effect.ramp.start = (Sint16)(state * 0x7FFF);
if (old != m_effect.effect.ramp.start)
m_effect.changed = true;
}
@ -247,7 +248,7 @@ void Joystick::SineEffect::SetState(ControlState state)
const Sint16 old = m_effect.effect.periodic.magnitude;
m_effect.effect.periodic.period = 5;
m_effect.effect.periodic.magnitude = state * 0x5000;
m_effect.effect.periodic.magnitude = (Sint16)(state * 0x5000);
m_effect.effect.periodic.attack_length = 0;
m_effect.effect.periodic.fade_length = 500;
@ -293,7 +294,7 @@ void Joystick::TriangleEffect::SetState(ControlState state)
const Sint16 old = m_effect.effect.periodic.magnitude;
m_effect.effect.periodic.period = 5;
m_effect.effect.periodic.magnitude = state * 0x5000;
m_effect.effect.periodic.magnitude = (Sint16)(state * 0x5000);
m_effect.effect.periodic.attack_length = 0;
m_effect.effect.periodic.fade_length = 100;
@ -313,34 +314,35 @@ bool Joystick::UpdateInput()
bool Joystick::UpdateOutput()
{
#ifdef USE_SDL_HAPTIC
std::list<EffectIDState>::iterator
i = m_state_out.begin(),
e = m_state_out.end();
for ( ; i != e; ++i)
for (auto &i : m_state_out)
{
if (i->changed) // if SetState was called on this output
if (i.changed) // if SetState was called on this output
{
if (-1 == i->id) // effect isn't currently uploaded
if (-1 == i.id) // effect isn't currently uploaded
{
if (i->effect.type) // if outputstate is >0 this would be true
if ((i->id = SDL_HapticNewEffect( m_haptic, &i->effect )) > -1) // upload the effect
SDL_HapticRunEffect(m_haptic, i->id, 1); // run the effect
if (i.effect.type) // if outputstate is >0 this would be true
{
if ((i.id = SDL_HapticNewEffect(m_haptic, &i.effect)) > -1) // upload the effect
{
SDL_HapticRunEffect(m_haptic, i.id, 1); // run the effect
}
}
}
else // effect is already uploaded
{
if (i->effect.type) // if ouputstate >0
if (i.effect.type) // if ouputstate >0
{
SDL_HapticUpdateEffect(m_haptic, i->id, &i->effect); // update the effect
SDL_HapticUpdateEffect(m_haptic, i.id, &i.effect); // update the effect
}
else
{
SDL_HapticStopEffect(m_haptic, i->id); // else, stop and remove the effect
SDL_HapticDestroyEffect(m_haptic, i->id);
i->id = -1; // mark it as not uploaded
SDL_HapticStopEffect(m_haptic, i.id); // else, stop and remove the effect
SDL_HapticDestroyEffect(m_haptic, i.id);
i.id = -1; // mark it as not uploaded
}
}
i->changed = false;
i.changed = false;
}
}
#endif