Fixed a few -Wconversion related warnings

This commit is contained in:
Ingo Ruhnke 2010-04-18 14:12:23 +02:00
parent 4e80df9fe0
commit 200795fe1a
7 changed files with 14 additions and 14 deletions

View file

@ -617,7 +617,7 @@ public:
int num_keycodes = max_keycode - min_keycode + 1;
int keysyms_per_keycode;
KeySym* keymap = XGetKeyboardMapping(dpy, min_keycode,
KeySym* keymap = XGetKeyboardMapping(dpy, static_cast<KeyCode>(min_keycode),
num_keycodes,
&keysyms_per_keycode);

View file

@ -188,8 +188,8 @@ FirestormDualController::read_vsb(XboxGenericMsg& msg, bool verbose, int timeout
msg.xbox360.lb = data.lb;
msg.xbox360.rb = data.rb;
msg.xbox360.lt = data.lt * 255;
msg.xbox360.rt = data.rt * 255;
msg.xbox360.lt = static_cast<unsigned char>(data.lt * 255);
msg.xbox360.rt = static_cast<unsigned char>(data.rt * 255);
msg.xbox360.start = data.start;
msg.xbox360.back = data.back;

View file

@ -45,7 +45,7 @@ std::string to_lower(const std::string &str)
i != lower_impl.end();
++i )
{
*i = tolower(*i);
*i = static_cast<char>(tolower(*i));
}
return lower_impl;

View file

@ -67,7 +67,7 @@ T clamp (const T& low, const T& v, const T& high)
inline int16_t negate_16(int16_t v)
{
if (v)
return ~v;
return static_cast<int16_t>(~v);
else // v == 0
return v;
}
@ -75,9 +75,9 @@ inline int16_t negate_16(int16_t v)
inline int16_t scale_8to16(int8_t a)
{
if (a > 0)
return a * 32767 / 127;
return static_cast<int16_t>(a * 32767 / 127);
else
return a * 32768 / 128;
return static_cast<int16_t>(a * 32768 / 128);
}
int get_terminal_width();

View file

@ -233,8 +233,8 @@ LinuxUinput::update(int msec_delta)
if (ff_callback)
{
ff_callback(ff_handler->get_strong_magnitude() / 128,
ff_handler->get_weak_magnitude() / 128);
ff_callback(static_cast<unsigned char>(ff_handler->get_strong_magnitude() / 128),
static_cast<unsigned char>(ff_handler->get_weak_magnitude() / 128));
}

View file

@ -270,12 +270,12 @@ void squarify_axis_(int16_t& x_inout, int16_t& y_inout)
if (x_inout != 0 || y_inout != 0)
{
// Convert values to float
float x = (x_inout < 0) ? x_inout / 32768.0f : x_inout / 32767.0f;
float y = (y_inout < 0) ? y_inout / 32768.0f : y_inout / 32767.0f;
float x = (x_inout < 0) ? static_cast<float>(x_inout) / 32768.0f : static_cast<float>(x_inout) / 32767.0f;
float y = (y_inout < 0) ? static_cast<float>(y_inout) / 32768.0f : static_cast<float>(y_inout) / 32767.0f;
// Transform values to square range
float l = sqrtf(x*x + y*y);
float v = fabs((fabsf(x) > fabsf(y)) ? l/x : l/y);
float v = fabsf((fabsf(x) > fabsf(y)) ? l/x : l/y);
x *= v;
y *= v;

View file

@ -525,11 +525,11 @@ float s16_to_float(int16_t value)
{
if (value >= 0)
{
return static_cast<float>(value) / 32767.0;
return static_cast<float>(value) / 32767.0f;
}
else
{
return static_cast<float>(value) / 32768.0;
return static_cast<float>(value) / 32768.0f;
}
}