Change ControlState typedef to double, and change all related floats/doubles to use it.

Fixes an off by 1 issue related to double->float->double conversion, and eliminates numerous warnings.
This commit is contained in:
Rachel Bryk
2014-08-11 13:43:26 -04:00
parent 64575d565a
commit 5adbc83453
16 changed files with 99 additions and 97 deletions

View File

@ -266,7 +266,7 @@ std::string Joystick::Hat::GetName() const
ControlState Joystick::Axis::GetState() const
{
return std::max(0.0f, ControlState(m_axis - m_base) / m_range);
return std::max(0.0, ControlState(m_axis - m_base) / m_range);
}
ControlState Joystick::Button::GetState() const

View File

@ -298,12 +298,12 @@ ControlState KeyboardMouse::Button::GetState() const
ControlState KeyboardMouse::Axis::GetState() const
{
return std::max(0.0f, ControlState(m_axis) / m_range);
return std::max(0.0, ControlState(m_axis) / m_range);
}
ControlState KeyboardMouse::Cursor::GetState() const
{
return std::max(0.0f, ControlState(m_axis) / (m_positive ? 1.0f : -1.0f));
return std::max(0.0, ControlState(m_axis) / (m_positive ? 1.0 : -1.0));
}
void KeyboardMouse::Light::SetState(const ControlState state)

View File

@ -10,7 +10,7 @@
#include "Common/Common.h"
// idk in case I wanted to change it to double or something, idk what's best
typedef float ControlState;
typedef double ControlState;
namespace ciface
{

View File

@ -273,7 +273,7 @@ public:
case TOK_OR:
return std::max(lhsValue, rhsValue);
case TOK_ADD:
return std::min(lhsValue + rhsValue, 1.0f);
return std::min(lhsValue + rhsValue, 1.0);
default:
assert(false);
return 0;

View File

@ -253,7 +253,7 @@ ControlState Keyboard::Key::GetState() const
ControlState Keyboard::Cursor::GetState() const
{
return std::max(0.0f, ControlState(m_axis) / (m_positive ? 1.0f : -1.0f));
return std::max(0.0, ControlState(m_axis) / (m_positive ? 1.0 : -1.0));
}
ControlState Keyboard::Button::GetState() const

View File

@ -407,7 +407,7 @@ ControlState Joystick::Button::GetState() const
ControlState Joystick::Axis::GetState() const
{
return std::max(0.0f, ControlState(SDL_JoystickGetAxis(m_js, m_index)) / m_range);
return std::max(0.0, ControlState(SDL_JoystickGetAxis(m_js, m_index)) / m_range);
}
ControlState Joystick::Hat::GetState() const

View File

@ -256,7 +256,7 @@ ControlState Device::Trigger::GetState() const
ControlState Device::Axis::GetState() const
{
return std::max( 0.0f, ControlState(m_axis) / m_range );
return std::max( 0.0, ControlState(m_axis) / m_range );
}
void Device::Motor::SetState(ControlState state)