From 200795fe1af02d9dd4663bceeadef0be9d179628 Mon Sep 17 00:00:00 2001
From: Ingo Ruhnke <grumbel@gmx.de>
Date: Sun, 18 Apr 2010 14:12:23 +0200
Subject: [PATCH] Fixed a few -Wconversion related warnings

---
 src/evdev_helper.cpp              | 2 +-
 src/firestorm_dual_controller.cpp | 4 ++--
 src/helper.cpp                    | 2 +-
 src/helper.hpp                    | 6 +++---
 src/linux_uinput.cpp              | 4 ++--
 src/modifier.cpp                  | 6 +++---
 src/xboxmsg.cpp                   | 4 ++--
 7 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/evdev_helper.cpp b/src/evdev_helper.cpp
index 166293f..d0c034b 100644
--- a/src/evdev_helper.cpp
+++ b/src/evdev_helper.cpp
@@ -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);
 
diff --git a/src/firestorm_dual_controller.cpp b/src/firestorm_dual_controller.cpp
index fa7cb9d..c407632 100644
--- a/src/firestorm_dual_controller.cpp
+++ b/src/firestorm_dual_controller.cpp
@@ -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;
diff --git a/src/helper.cpp b/src/helper.cpp
index 2eec338..db2c82b 100644
--- a/src/helper.cpp
+++ b/src/helper.cpp
@@ -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;
diff --git a/src/helper.hpp b/src/helper.hpp
index 2fb0e73..931531d 100644
--- a/src/helper.hpp
+++ b/src/helper.hpp
@@ -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();
diff --git a/src/linux_uinput.cpp b/src/linux_uinput.cpp
index 28ec632..a31b2b6 100644
--- a/src/linux_uinput.cpp
+++ b/src/linux_uinput.cpp
@@ -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));
                       
         }
       
diff --git a/src/modifier.cpp b/src/modifier.cpp
index ff01bcb..ceb7c0f 100644
--- a/src/modifier.cpp
+++ b/src/modifier.cpp
@@ -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;
 
diff --git a/src/xboxmsg.cpp b/src/xboxmsg.cpp
index 5ab0782..5fe9f11 100644
--- a/src/xboxmsg.cpp
+++ b/src/xboxmsg.cpp
@@ -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;
   }
 }