pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r4037 - in trunk/pingus/src: display/opengl input/evdev inp


From: grumbel at BerliOS
Subject: [Pingus-CVS] r4037 - in trunk/pingus/src: display/opengl input/evdev input/usbmouse input/wiimote input/xinput
Date: Thu, 5 Nov 2009 20:22:48 +0100

Author: grumbel
Date: 2009-11-05 20:22:47 +0100 (Thu, 05 Nov 2009)
New Revision: 4037

Modified:
   trunk/pingus/src/display/opengl/opengl_framebuffer.cpp
   trunk/pingus/src/input/evdev/evdev_device.cpp
   trunk/pingus/src/input/evdev/evdev_device.hpp
   trunk/pingus/src/input/evdev/evdev_driver.cpp
   trunk/pingus/src/input/usbmouse/usbmouse_driver.cpp
   trunk/pingus/src/input/wiimote/wiimote.cpp
   trunk/pingus/src/input/wiimote/wiimote.hpp
   trunk/pingus/src/input/wiimote/wiimote_driver.cpp
   trunk/pingus/src/input/xinput/xinput_device.cpp
   trunk/pingus/src/input/xinput/xinput_device.hpp
   trunk/pingus/src/input/xinput/xinput_driver.cpp
   trunk/pingus/src/input/xinput/xinput_driver.hpp
Log:
#include, -Wconversion, -Weffc++ cleanup for optional source files


Modified: trunk/pingus/src/display/opengl/opengl_framebuffer.cpp
===================================================================
--- trunk/pingus/src/display/opengl/opengl_framebuffer.cpp      2009-11-05 
19:01:27 UTC (rev 4036)
+++ trunk/pingus/src/display/opengl/opengl_framebuffer.cpp      2009-11-05 
19:22:47 UTC (rev 4037)
@@ -14,11 +14,12 @@
 //  You should have received a copy of the GNU General Public License
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+#include "display/opengl/opengl_framebuffer.hpp"
+
 #include <sstream>
 #include <iostream>
 #include <stdexcept>
 
-#include "display/opengl/opengl_framebuffer.hpp"
 #include "display/opengl/opengl_framebuffer_surface_impl.hpp"
 #include "math/math.hpp"
 #include "pingus/surface.hpp"

Modified: trunk/pingus/src/input/evdev/evdev_device.cpp
===================================================================
--- trunk/pingus/src/input/evdev/evdev_device.cpp       2009-11-05 19:01:27 UTC 
(rev 4036)
+++ trunk/pingus/src/input/evdev/evdev_device.cpp       2009-11-05 19:22:47 UTC 
(rev 4037)
@@ -14,6 +14,8 @@
 //  You should have received a copy of the GNU General Public License
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+#include "input/evdev/evdev_device.hpp"
+
 #include <assert.h>
 #include <linux/input.h>
 #include <sys/ioctl.h>
@@ -24,8 +26,6 @@
 #include <errno.h>
 #include <stdio.h>
 
-#include "input/evdev/evdev_device.hpp"
-
 #define BITS_PER_LONG (sizeof(long) * 8)
 #define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
 #define OFF(x)  ((x)%BITS_PER_LONG)

Modified: trunk/pingus/src/input/evdev/evdev_device.hpp
===================================================================
--- trunk/pingus/src/input/evdev/evdev_device.hpp       2009-11-05 19:01:27 UTC 
(rev 4036)
+++ trunk/pingus/src/input/evdev/evdev_device.hpp       2009-11-05 19:22:47 UTC 
(rev 4037)
@@ -19,11 +19,12 @@
 
 #include <vector>
 #include <string.h>
+#include <linux/input.h>
+
 #include "input/control.hpp"
 
 namespace Input {
 
-/** */
 class EvdevDevice
 {
 private:

Modified: trunk/pingus/src/input/evdev/evdev_driver.cpp
===================================================================
--- trunk/pingus/src/input/evdev/evdev_driver.cpp       2009-11-05 19:01:27 UTC 
(rev 4036)
+++ trunk/pingus/src/input/evdev/evdev_driver.cpp       2009-11-05 19:22:47 UTC 
(rev 4037)
@@ -14,9 +14,10 @@
 //  You should have received a copy of the GNU General Public License
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-#include "input/evdev/evdev_device.hpp"
 #include "input/evdev/evdev_driver.hpp"
 
+#include "input/evdev/evdev_device.hpp"
+
 namespace Input {
 
 EvdevDriver::EvdevDriver() :

Modified: trunk/pingus/src/input/usbmouse/usbmouse_driver.cpp
===================================================================
--- trunk/pingus/src/input/usbmouse/usbmouse_driver.cpp 2009-11-05 19:01:27 UTC 
(rev 4036)
+++ trunk/pingus/src/input/usbmouse/usbmouse_driver.cpp 2009-11-05 19:22:47 UTC 
(rev 4037)
@@ -14,6 +14,8 @@
 //  You should have received a copy of the GNU General Public License
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+#include "input/usbmouse/usbmouse_driver.hpp"
+
 #include <stdexcept>
 #include <sys/ioctl.h>
 #include <fcntl.h>
@@ -25,7 +27,6 @@
 #include "pingus/debug.hpp"
 #include "pingus/globals.hpp"
 #include "math/vector2i.hpp"
-#include "input/usbmouse/usbmouse_driver.hpp"
 #include "display/display.hpp"
 
 namespace Input {

Modified: trunk/pingus/src/input/wiimote/wiimote.cpp
===================================================================
--- trunk/pingus/src/input/wiimote/wiimote.cpp  2009-11-05 19:01:27 UTC (rev 
4036)
+++ trunk/pingus/src/input/wiimote/wiimote.cpp  2009-11-05 19:22:47 UTC (rev 
4037)
@@ -14,12 +14,14 @@
 //  You should have received a copy of the GNU General Public License
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+#include "input/wiimote/wiimote.hpp"
+
 #include <iostream>
 #include <assert.h>
 #include <pthread.h>
-#include "input/math.hpp"
-#include "input/wiimote.hpp"
 
+#include "math/math.hpp"
+
 Wiimote* wiimote = 0;
 
 std::string
@@ -110,21 +112,27 @@
   wiimote = 0;
 }
 
-Wiimote::Wiimote()
-  : m_wiimote(0),
-    m_rumble(false),
-    m_led_state(0),
-    m_nunchuk_btns(0),
-    m_nunchuk_stick_x(0),
-    m_nunchuk_stick_y(0),
-    m_buttons(0)
+Wiimote::Wiimote() :
+  mutex(),
+  m_wiimote(0),
+  m_rumble(false),
+  m_led_state(0),
+  m_nunchuk_btns(0),
+  m_nunchuk_stick_x(0),
+  m_nunchuk_stick_y(0),
+  m_buttons(0),
+  wiimote_zero(),
+  wiimote_one(),
+  nunchuk_zero(),
+  nunchuk_one(),
+  events()
 {
   pthread_mutex_init(&mutex, NULL);
 
   assert(wiimote == 0);
   wiimote = this;
   
-  cwiid_set_err(&Wiimote::err_callback);
+  cwiid_set_err(&Wiimote::err_callback_c);
 }
 
 Wiimote::~Wiimote()
@@ -139,7 +147,7 @@
   assert(m_wiimote == 0);
 
   /* Connect to any wiimote */
-  bdaddr_t bdaddr = *BDADDR_ANY;
+  bdaddr_t bdaddr = {{0, 0, 0, 0, 0, 0}};
 
   /* Connect to address in string WIIMOTE_BDADDR */
   /* str2ba(WIIMOTE_BDADDR, &bdaddr); */
@@ -154,7 +162,7 @@
   else 
     {
       std::cout << "Wiimote connected: " << m_wiimote << std::endl;
-      if (cwiid_set_mesg_callback(m_wiimote, &Wiimote::mesg_callback))
+      if (cwiid_set_mesg_callback(m_wiimote, &Wiimote::mesg_callback_c))
         {
           std::cerr << "Unable to set message callback" << std::endl;
         }
@@ -258,7 +266,7 @@
   else // (!state)
     new_led_state &= ~(1 << (num-1));
 
-  set_led(new_led_state);
+  set_led(static_cast<unsigned char>(new_led_state));
 }
 
 void
@@ -389,9 +397,9 @@
   //printf("Acc Report: x=%d, y=%d, z=%d\n", msg.acc[0], msg.acc[1], 
msg.acc[2]);
 
   add_acc_event(0, 0, 
-                (msg.acc[0] - wiimote_zero.x) / float(wiimote_one.x - 
wiimote_zero.x),
-                (msg.acc[1] - wiimote_zero.y) / float(wiimote_one.y - 
wiimote_zero.y),
-                (msg.acc[2] - wiimote_zero.z) / float(wiimote_one.z - 
wiimote_zero.z));
+                static_cast<float>(msg.acc[0] - wiimote_zero.x) / 
static_cast<float>(wiimote_one.x - wiimote_zero.x),
+                static_cast<float>(msg.acc[1] - wiimote_zero.y) / 
static_cast<float>(wiimote_one.y - wiimote_zero.y),
+                static_cast<float>(msg.acc[2] - wiimote_zero.z) / 
static_cast<float>(wiimote_one.z - wiimote_zero.z));
 }
 
 void
@@ -422,11 +430,11 @@
 {
   if (value < center)
     {
-      return Math::clamp(-1.0f, -(center - value) / float(center - min), 1.0f);
+      return Math::clamp(-1.0f, -static_cast<float>(center - value) / 
static_cast<float>(center - min), 1.0f);
     }
   else if (value > center)
     {
-      return Math::clamp(-1.0f, (value - center) / float(max - center), 1.0f);
+      return Math::clamp(-1.0f, static_cast<float>(value - center) / 
static_cast<float>(max - center), 1.0f);
     }
   else 
     {
@@ -462,9 +470,9 @@
     }
 
   add_acc_event(0, 1, 
-                (msg.acc[0] - nunchuk_zero.x) / float(nunchuk_one.x - 
nunchuk_zero.x),
-                (msg.acc[1] - nunchuk_zero.y) / float(nunchuk_one.y - 
nunchuk_zero.y),
-                (msg.acc[2] - nunchuk_zero.z) / float(nunchuk_one.z - 
nunchuk_zero.z));
+                static_cast<float>(msg.acc[0] - nunchuk_zero.x) / 
static_cast<float>(nunchuk_one.x - nunchuk_zero.x),
+                static_cast<float>(msg.acc[1] - nunchuk_zero.y) / 
static_cast<float>(nunchuk_one.y - nunchuk_zero.y),
+                static_cast<float>(msg.acc[2] - nunchuk_zero.z) / 
static_cast<float>(nunchuk_one.z - nunchuk_zero.z));
   if (0)
     printf("Nunchuk Report: btns=%.2X stick=(%3d,%3d) (%5.2f, %5.2f) acc.x=%d 
acc.y=%d acc.z=%d\n", 
            msg.buttons,
@@ -496,7 +504,7 @@
 
 // Callback function that get called by the Wiimote thread
 void
-Wiimote::err(cwiid_wiimote_t* w, const char *s, va_list ap)
+Wiimote::err_callback(cwiid_wiimote_t* w, const char *s, va_list ap)
 {
   pthread_mutex_lock(&mutex);
 
@@ -512,7 +520,7 @@
 }
 
 void
-Wiimote::mesg(cwiid_wiimote_t* w, int mesg_count, union cwiid_mesg mesg[])
+Wiimote::mesg_callback(cwiid_wiimote_t* w, int mesg_count, union cwiid_mesg 
mesg[])
 {
   pthread_mutex_lock(&mutex);
 
@@ -561,15 +569,15 @@
 // static callback functions
   
 void
-Wiimote::err_callback(cwiid_wiimote_t* w, const char *s, va_list ap)
+Wiimote::err_callback_c(cwiid_wiimote_t* w, const char *s, va_list ap)
 {
-  wiimote->err(w, s, ap);
+  wiimote->err_callback(w, s, ap);
 }
 
 void
-Wiimote::mesg_callback(cwiid_wiimote_t* w, int mesg_count, union cwiid_mesg 
mesg[], timespec*)
+Wiimote::mesg_callback_c(cwiid_wiimote_t* w, int mesg_count, union cwiid_mesg 
mesg[], timespec*)
 {
-  wiimote->mesg(w, mesg_count, mesg);
+  wiimote->mesg_callback(w, mesg_count, mesg);
 }
 
 /* EOF */

Modified: trunk/pingus/src/input/wiimote/wiimote.hpp
===================================================================
--- trunk/pingus/src/input/wiimote/wiimote.hpp  2009-11-05 19:01:27 UTC (rev 
4036)
+++ trunk/pingus/src/input/wiimote/wiimote.hpp  2009-11-05 19:22:47 UTC (rev 
4037)
@@ -18,6 +18,9 @@
 #define HEADER_PINGUS_INPUT_WIIMOTE_HPP
 
 #include <vector>
+#include <string>
+#include <pthread.h>
+
 #include "cwiid.h"
 
 struct WiimoteButtonEvent
@@ -64,8 +67,8 @@
 class Wiimote
 {
 public:
-  static void err_callback(cwiid_wiimote_t*, const char *s, va_list ap);
-  static void mesg_callback(cwiid_wiimote_t*, int mesg_count, union cwiid_mesg 
mesg[], timespec*);
+  static void err_callback_c(cwiid_wiimote_t*, const char *s, va_list ap);
+  static void mesg_callback_c(cwiid_wiimote_t*, int mesg_count, union 
cwiid_mesg mesg[], timespec*);
 
   static void init();
   static void deinit();
@@ -161,8 +164,8 @@
   void on_nunchuk(const cwiid_nunchuk_mesg& msg);
   void on_classic (const cwiid_classic_mesg& msg);
   
-  void mesg(cwiid_wiimote_t*, int mesg_count, union cwiid_mesg mesg[]);
-  void err(cwiid_wiimote_t*, const char *s, va_list ap);
+  void mesg_callback(cwiid_wiimote_t*, int mesg_count, union cwiid_mesg 
mesg[]);
+  void err_callback(cwiid_wiimote_t*, const char *s, va_list ap);
 
 private:
   Wiimote(const Wiimote&);

Modified: trunk/pingus/src/input/wiimote/wiimote_driver.cpp
===================================================================
--- trunk/pingus/src/input/wiimote/wiimote_driver.cpp   2009-11-05 19:01:27 UTC 
(rev 4036)
+++ trunk/pingus/src/input/wiimote/wiimote_driver.cpp   2009-11-05 19:22:47 UTC 
(rev 4037)
@@ -14,15 +14,18 @@
 //  You should have received a copy of the GNU General Public License
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-#include "input/debug.hpp"
-#include "input/globals.hpp"
-#include "input/string_util.hpp"
-#include "input/wiimote.hpp"
-#include "input/wiimote_driver.hpp"
+#include "input/wiimote/wiimote_driver.hpp"
 
+#include "input/wiimote/wiimote.hpp"
+#include "pingus/debug.hpp"
+#include "pingus/globals.hpp"
+#include "util/string_util.hpp"
+
 namespace Input {
 
-WiimoteDriver::WiimoteDriver()
+WiimoteDriver::WiimoteDriver() :
+  button_bindings(),
+  axis_bindings()
 {
   Wiimote::init();
   wiimote->connect();

Modified: trunk/pingus/src/input/xinput/xinput_device.cpp
===================================================================
--- trunk/pingus/src/input/xinput/xinput_device.cpp     2009-11-05 19:01:27 UTC 
(rev 4036)
+++ trunk/pingus/src/input/xinput/xinput_device.cpp     2009-11-05 19:22:47 UTC 
(rev 4037)
@@ -14,30 +14,35 @@
 //  You should have received a copy of the GNU General Public License
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+#include "input/xinput/xinput_device.hpp"
+
 #include "SDL_syswm.h"
 
-#include "input/debug.hpp"
-#include "input/globals.hpp"
+#include "pingus/debug.hpp"
+#include "pingus/globals.hpp"
+#include "input/xinput/xinput_driver.hpp"
 
-#include "input/xinput_driver.hpp"
-#include "input/xinput_device.hpp"
-
 namespace Input {
 
 #define INVALID_EVENT_TYPE -1
 
-XInputDevice::XInputDevice(XInputDriver* owner_, XDeviceInfo* info)
-  : owner(owner_),
-    name(info->name),
-    absolute(false),
-    num_keys   (0),
-    motion_type        (INVALID_EVENT_TYPE),
-    button_press_type  (INVALID_EVENT_TYPE),
-    button_release_type(INVALID_EVENT_TYPE),
-    key_press_type     (INVALID_EVENT_TYPE),
-    key_release_type   (INVALID_EVENT_TYPE),
-    proximity_in_type  (INVALID_EVENT_TYPE),
-    proximity_out_type (INVALID_EVENT_TYPE)
+XInputDevice::XInputDevice(XInputDriver* owner_, XDeviceInfo* info) :
+  owner(owner_),
+  name(info->name),
+  absolute(false),
+  buttons(),
+  axis(),
+  num_keys   (0),
+  mouse_pos(),
+  time_at_last_press(),
+  last_press_id(),
+  motion_type        (INVALID_EVENT_TYPE),
+  button_press_type  (INVALID_EVENT_TYPE),
+  button_release_type(INVALID_EVENT_TYPE),
+  key_press_type     (INVALID_EVENT_TYPE),
+  key_release_type   (INVALID_EVENT_TYPE),
+  proximity_in_type  (INVALID_EVENT_TYPE),
+  proximity_out_type (INVALID_EVENT_TYPE)
 {
   //info = find_device_info(owner->get_display(), name.c_str(), True);
   //if (!info)
@@ -46,13 +51,13 @@
   get_info(info);
 
   if (!register_events(owner->get_syswminfo().info.x11.display, info, 
name.c_str(), True))
-    {
-      std::cout << "debug: CL_InputDeviceXInput: Couldn't find device: " << 
name << std::endl;
-    }
+  {
+    std::cout << "debug: CL_InputDeviceXInput: Couldn't find device: " << name 
<< std::endl;
+  }
   else
-    {
-      //slot_xevent = owner->sig_unknown_xevent.connect(this, 
&CL_InputDevice_XInput::on_xevent);
-    }
+  {
+    //slot_xevent = owner->sig_unknown_xevent.connect(this, 
&CL_InputDevice_XInput::on_xevent);
+  }
 }
 
 void
@@ -74,100 +79,100 @@
   std::vector<bool>     old_buttons = buttons;
 
   if (event.type == motion_type)
-    {
-      XDeviceMotionEvent *motion = (XDeviceMotionEvent *) &event;
+  {
+    XDeviceMotionEvent *motion = (XDeviceMotionEvent *) &event;
 
-      //printf("motion ");
+    //printf("motion ");
 
-      for(int loop=0; loop<motion->axes_count; loop++) {
-        //printf("a[%d]=%d ", motion->first_axis + loop, 
motion->axis_data[loop]);
-        axis[loop + motion->first_axis].pos = motion->axis_data[loop];
-      }
-      //printf("\n");
+    for(int loop=0; loop<motion->axes_count; loop++) {
+      //printf("a[%d]=%d ", motion->first_axis + loop, 
motion->axis_data[loop]);
+      axis[loop + motion->first_axis].pos = motion->axis_data[loop];
     }
+    //printf("\n");
+  }
   else if ((event.type == button_press_type) ||
            (event.type == button_release_type))
-    {
-      int loop;
-      XDeviceButtonEvent *button = (XDeviceButtonEvent *) &event;
+  {
+    int loop;
+    XDeviceButtonEvent *button = (XDeviceButtonEvent *) &event;
 
-      //printf("button %s %d ", (event.type == button_release_type) ? 
"release" : "press  ", button->button);
+    //printf("button %s %d ", (event.type == button_release_type) ? "release" 
: "press  ", button->button);
 
-      buttons[button->button] = (event.type == button_press_type);
+    buttons[button->button] = (event.type == button_press_type);
 
-      for(loop=0; loop<button->axes_count; loop++) {
-        //printf("a[%d]=%d ", button->first_axis + loop, 
button->axis_data[loop]);
-        axis[loop + button->first_axis].pos = button->axis_data[loop];
-      }
-      //printf("\n");
+    for(loop=0; loop<button->axes_count; loop++) {
+      //printf("a[%d]=%d ", button->first_axis + loop, 
button->axis_data[loop]);
+      axis[loop + button->first_axis].pos = button->axis_data[loop];
     }
+    //printf("\n");
+  }
   else if ((event.type == key_press_type) ||
            (event.type == key_release_type))
-    {
-      int loop;
-      XDeviceKeyEvent *key = (XDeviceKeyEvent *) &event;
+  {
+    int loop;
+    XDeviceKeyEvent *key = (XDeviceKeyEvent *) &event;
 
-      printf("key %s %d ", (event.type == key_release_type) ? "release" : 
"press  ", key->keycode);
+    printf("key %s %d ", (event.type == key_release_type) ? "release" : "press 
 ", key->keycode);
 
-      for(loop=0; loop<key->axes_count; loop++) {
-        printf("a[%d]=%d ", key->first_axis + loop, key->axis_data[loop]);
-        axis[loop + key->first_axis].pos = key->axis_data[loop];
-      }
-      printf("\n");
+    for(loop=0; loop<key->axes_count; loop++) {
+      printf("a[%d]=%d ", key->first_axis + loop, key->axis_data[loop]);
+      axis[loop + key->first_axis].pos = key->axis_data[loop];
     }
+    printf("\n");
+  }
   else if ((event.type == proximity_out_type) ||
            (event.type == proximity_in_type))
-    {
-      int loop;
-      XProximityNotifyEvent *prox = (XProximityNotifyEvent *) &event;
+  {
+    int loop;
+    XProximityNotifyEvent *prox = (XProximityNotifyEvent *) &event;
 
-      printf("proximity %s ", (event.type == proximity_in_type) ? "in " : 
"out");
+    printf("proximity %s ", (event.type == proximity_in_type) ? "in " : "out");
 
-      for(loop=0; loop<prox->axes_count; loop++) {
-        printf("a[%d]=%d ", prox->first_axis + loop, prox->axis_data[loop]);
-        axis[loop + prox->first_axis].pos = prox->axis_data[loop];
-      }
-      printf("\n");
+    for(loop=0; loop<prox->axes_count; loop++) {
+      printf("a[%d]=%d ", prox->first_axis + loop, prox->axis_data[loop]);
+      axis[loop + prox->first_axis].pos = prox->axis_data[loop];
     }
+    printf("\n");
+  }
   else
-    {
-      printf("CL_InputDevice_XInput: what's that %d\n", event.type);
-    }
+  {
+    printf("CL_InputDevice_XInput: what's that %d\n", event.type);
+  }
 
 
   for (std::vector<bool>::size_type i = 0; i < buttons.size(); ++i)
+  {
+    if (buttons[i] != old_buttons[i])
     {
-      if (buttons[i] != old_buttons[i])
-        {
-//           CL_InputEvent ie;
+      //           CL_InputEvent ie;
 
-//           ie.id           = i;
-//           ie.type         = CL_InputEvent::pressed;
-//           ie.device       = CL_InputDevice(this);
-//           ie.mouse_pos    = CL_Point(0, 0);
-//           ie.axis_pos     = 0;
-//           ie.repeat_count = false;
+      //           ie.id           = i;
+      //           ie.type         = CL_InputEvent::pressed;
+      //           ie.device       = CL_InputDevice(this);
+      //           ie.mouse_pos    = CL_Point(0, 0);
+      //           ie.axis_pos     = 0;
+      //           ie.repeat_count = false;
 
-//           sig_axis_move(ie);
-        }
+      //           sig_axis_move(ie);
     }
+  }
 
   for (std::vector<AxisInfo>::size_type i = 0; i < axis.size(); ++i)
+  {
+    if (axis[i].pos != old_axis[i].pos)
     {
-      if (axis[i].pos != old_axis[i].pos)
-        {
-//           CL_InputEvent ie;
+      //           CL_InputEvent ie;
           
-//           ie.id           = i;
-//           ie.type         = CL_InputEvent::axis_moved;
-//           ie.device       = CL_InputDevice(this);
-//           ie.mouse_pos    = CL_Point(0, 0);
-//           ie.axis_pos     = get_axis(i);
-//           ie.repeat_count = false;
+      //           ie.id           = i;
+      //           ie.type         = CL_InputEvent::axis_moved;
+      //           ie.device       = CL_InputDevice(this);
+      //           ie.mouse_pos    = CL_Point(0, 0);
+      //           ie.axis_pos     = get_axis(i);
+      //           ie.repeat_count = false;
           
-//           sig_axis_move(ie);
-        }
+      //           sig_axis_move(ie);
     }
+  }
 }
 
 int
@@ -190,63 +195,63 @@
   device = XOpenDevice(dpy, info->id);
 
   if (!device) 
-    {
-      fprintf(stderr, "unable to open device %s\n", dev_name);
-      return 0;
-    }
+  {
+    fprintf(stderr, "unable to open device %s\n", dev_name);
+    return 0;
+  }
 
   if (device->num_classes > 0) 
+  {
+    for (ip = device->classes, i=0; i<info->num_classes; ip++, i++) 
     {
-      for (ip = device->classes, i=0; i<info->num_classes; ip++, i++) 
-        {
-          switch (ip->input_class) 
-            {
-              case KeyClass:
-                DeviceKeyPress  (device, key_press_type,   
event_list[number]); number++;
-                DeviceKeyRelease(device, key_release_type, 
event_list[number]); number++;
-                break;
+      switch (ip->input_class) 
+      {
+        case KeyClass:
+          DeviceKeyPress  (device, key_press_type,   event_list[number]); 
number++;
+          DeviceKeyRelease(device, key_release_type, event_list[number]); 
number++;
+          break;
 
-              case ButtonClass:
-                DeviceButtonPress  (device, button_press_type,   
event_list[number]); number++;
-                DeviceButtonRelease(device, button_release_type, 
event_list[number]); number++;
-                break;
+        case ButtonClass:
+          DeviceButtonPress  (device, button_press_type,   
event_list[number]); number++;
+          DeviceButtonRelease(device, button_release_type, 
event_list[number]); number++;
+          break;
 
-              case ValuatorClass:
-                DeviceMotionNotify(device, motion_type, event_list[number]); 
number++;
-                if (handle_proximity) {
-                  ProximityIn (device, proximity_in_type,  
event_list[number]); number++;
-                  ProximityOut(device, proximity_out_type, 
event_list[number]); number++;
-                }
-                break;
+        case ValuatorClass:
+          DeviceMotionNotify(device, motion_type, event_list[number]); 
number++;
+          if (handle_proximity) {
+            ProximityIn (device, proximity_in_type,  event_list[number]); 
number++;
+            ProximityOut(device, proximity_out_type, event_list[number]); 
number++;
+          }
+          break;
 
-              case FeedbackClass:
-                std::cout << "Error: XInputDevice: register_events: unhandled 
class: FeedbackClass" << std::endl;
-                break;
+        case FeedbackClass:
+          std::cout << "Error: XInputDevice: register_events: unhandled class: 
FeedbackClass" << std::endl;
+          break;
 
-              case ProximityClass:
-                std::cout << "Error: XInputDevice: register_events: unhandled 
class: ProximityClass" << std::endl;
-                break;
+        case ProximityClass:
+          std::cout << "Error: XInputDevice: register_events: unhandled class: 
ProximityClass" << std::endl;
+          break;
 
-              case FocusClass:
-                std::cout << "Error: XInputDevice: register_events: unhandled 
class: FocusClass" << std::endl;
-                break;
+        case FocusClass:
+          std::cout << "Error: XInputDevice: register_events: unhandled class: 
FocusClass" << std::endl;
+          break;
 
-              case OtherClass:
-                std::cout << "Error: XInputDevice: register_events: unhandled 
class: OtherClass" << std::endl;
-                break;
+        case OtherClass:
+          std::cout << "Error: XInputDevice: register_events: unhandled class: 
OtherClass" << std::endl;
+          break;
 
-              default:
-                std::cout << "Error: XInputDevice: register_events: unknown 
class: " << ip->input_class << std::endl;
-                break;
-            }
-        }
-
-      if (XSelectExtensionEvent(dpy, root_win, event_list, number)) {
-        fprintf(stderr, "error selecting extended events\n");
-        return 0;
+        default:
+          std::cout << "Error: XInputDevice: register_events: unknown class: " 
<< ip->input_class << std::endl;
+          break;
       }
     }
 
+    if (XSelectExtensionEvent(dpy, root_win, event_list, number)) {
+      fprintf(stderr, "error selecting extended events\n");
+      return 0;
+    }
+  }
+
   //std::cout << "### Registered events: " << number << std::endl;
   return number;
 }
@@ -261,78 +266,78 @@
   XAnyClassPtr any = (XAnyClassPtr)(info->inputclassinfo);
   std::cout << "Info->num_classes: " << info->num_classes << std::endl;
   for (int i = 0; i < info->num_classes; ++i) 
+  {
+    switch (any->c_class) 
     {
-      switch (any->c_class) 
-        {
-          case KeyClass:
-            {
-              XKeyInfoPtr k = (XKeyInfoPtr)any;
+      case KeyClass:
+      {
+        XKeyInfoPtr k = (XKeyInfoPtr)any;
   
-              printf("\tNum_keys is %d\n", k->num_keys);
-              printf("\tMin_keycode is %d\n", k->min_keycode);
-              printf("\tMax_keycode is %d\n", k->max_keycode);
+        printf("\tNum_keys is %d\n", k->num_keys);
+        printf("\tMin_keycode is %d\n", k->min_keycode);
+        printf("\tMax_keycode is %d\n", k->max_keycode);
 
-              num_keys = k->num_keys;
-            }
-            break;
+        num_keys = k->num_keys;
+      }
+      break;
 
-          case ButtonClass:
-            {
-              XButtonInfoPtr b = (XButtonInfoPtr)any;
-              printf("\tNum_buttons is %d\n", b->num_buttons);
+      case ButtonClass:
+      {
+        XButtonInfoPtr b = (XButtonInfoPtr)any;
+        printf("\tNum_buttons is %d\n", b->num_buttons);
 
-              buttons.resize(b->num_buttons, false);
-            }
-            break;
+        buttons.resize(b->num_buttons, false);
+      }
+      break;
 
-          case ValuatorClass:
-            {
-              XValuatorInfoPtr v = (XValuatorInfoPtr)any;
-              XAxisInfoPtr a = (XAxisInfoPtr) ((char*)v +
-                                               sizeof (XValuatorInfo));
+      case ValuatorClass:
+      {
+        XValuatorInfoPtr v = (XValuatorInfoPtr)any;
+        XAxisInfoPtr a = (XAxisInfoPtr) ((char*)v +
+                                         sizeof (XValuatorInfo));
 
-              printf("\tNum_axes is %d\n", v->num_axes);
-              printf("\tMode is %s\n", (v->mode == Absolute) ? "Absolute" : 
"Relative");
-              printf("\tMotion_buffer is %ld\n", v->motion_buffer);
+        printf("\tNum_axes is %d\n", v->num_axes);
+        printf("\tMode is %s\n", (v->mode == Absolute) ? "Absolute" : 
"Relative");
+        printf("\tMotion_buffer is %ld\n", v->motion_buffer);
 
-              absolute = (v->mode == Absolute);
+        absolute = (v->mode == Absolute);
 
-              for (int j = 0; j < v->num_axes; ++j, ++a)
-                {
-                  printf("\tAxis %d :\n", j);
-                  printf("\t\tMin_value is %d\n", a->min_value);
-                  printf("\t\tMax_value is %d\n", a->max_value);
-                  printf ("\t\tResolution is %d\n", a->resolution);
+        for (int j = 0; j < v->num_axes; ++j, ++a)
+        {
+          printf("\tAxis %d :\n", j);
+          printf("\t\tMin_value is %d\n", a->min_value);
+          printf("\t\tMax_value is %d\n", a->max_value);
+          printf ("\t\tResolution is %d\n", a->resolution);
 
-                  axis.push_back(AxisInfo(a->min_value, a->max_value, 
a->resolution));
-                }
-            }
-            break;
+          axis.push_back(AxisInfo(a->min_value, a->max_value, a->resolution));
+        }
+      }
+      break;
 
-          case FeedbackClass:
-            std::cout << "Error: XInputDevice: get_info: unhandled class: 
FeedbackClass" << std::endl;
-            break;
+      case FeedbackClass:
+        std::cout << "Error: XInputDevice: get_info: unhandled class: 
FeedbackClass" << std::endl;
+        break;
 
-          case ProximityClass:
-            std::cout << "Error: XInputDevice: get_info: unhandled class: 
ProximityClass" << std::endl;
-            break;
+      case ProximityClass:
+        std::cout << "Error: XInputDevice: get_info: unhandled class: 
ProximityClass" << std::endl;
+        break;
 
-          case FocusClass:
-            std::cout << "Error: XInputDevice: get_info: unhandled class: 
FocusClass" << std::endl;
-            break;
+      case FocusClass:
+        std::cout << "Error: XInputDevice: get_info: unhandled class: 
FocusClass" << std::endl;
+        break;
 
-          case OtherClass:
-            std::cout << "Error: XInputDevice: get_info: unhandled class: 
OtherClass" << std::endl;
-            break;
+      case OtherClass:
+        std::cout << "Error: XInputDevice: get_info: unhandled class: 
OtherClass" << std::endl;
+        break;
 
-          default:
-            std::cout << "Error: XInputDevice: get_info: unknown class: " << 
any->c_class << std::endl;
-            break;
-        }
+      default:
+        std::cout << "Error: XInputDevice: get_info: unknown class: " << 
any->c_class << std::endl;
+        break;
+    }
 
-      std::cout << "AnyClass ptr: " << any->length << std::endl;
-      any = (XAnyClassPtr)((char*)any + any->length);
-    }
+    std::cout << "AnyClass ptr: " << any->length << std::endl;
+    any = (XAnyClassPtr)((char*)any + any->length);
+  }
 }
 
 } // namespace Input

Modified: trunk/pingus/src/input/xinput/xinput_device.hpp
===================================================================
--- trunk/pingus/src/input/xinput/xinput_device.hpp     2009-11-05 19:01:27 UTC 
(rev 4036)
+++ trunk/pingus/src/input/xinput/xinput_device.hpp     2009-11-05 19:22:47 UTC 
(rev 4037)
@@ -78,6 +78,10 @@
                        XDeviceInfo* info,
                        const char* dev_name,
                        Bool handle_proximity);
+
+private:
+  XInputDevice(const XInputDevice&);
+  XInputDevice & operator=(const XInputDevice&);
 };
 
 } // namespace Input

Modified: trunk/pingus/src/input/xinput/xinput_driver.cpp
===================================================================
--- trunk/pingus/src/input/xinput/xinput_driver.cpp     2009-11-05 19:01:27 UTC 
(rev 4036)
+++ trunk/pingus/src/input/xinput/xinput_driver.cpp     2009-11-05 19:22:47 UTC 
(rev 4037)
@@ -14,17 +14,19 @@
 //  You should have received a copy of the GNU General Public License
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+#include "input/xinput/xinput_driver.hpp"
+
 #include <iostream>
 
-#include "input/debug.hpp"
-#include "input/globals.hpp"
+#include "pingus/debug.hpp"
+#include "pingus/globals.hpp"
+#include "input/xinput/xinput_device.hpp"
 
-#include "input/xinput_driver.hpp"
-#include "input/xinput_device.hpp"
-
 namespace Input {
 
-XInputDriver::XInputDriver()
+XInputDriver::XInputDriver() :
+  sys(),
+  devices()
 {
   SDL_VERSION(&sys.version); // this is important!
   if (!SDL_GetWMInfo(&sys))
@@ -90,7 +92,7 @@
 {
   // FIXME: Not really needed could simply pass XDeviceInfo to the
   // constructor, might however make a nicer interface
-  XDeviceInfo *devices;
+  XDeviceInfo* x_devices;
   int  num_devices;
   int  len = strlen(name);
   Bool is_id = True;
@@ -109,14 +111,14 @@
     id = atoi(name);
   }
 
-  devices = XListInputDevices(display, &num_devices);
+  x_devices = XListInputDevices(display, &num_devices);
 
   for(int i = 0; i < num_devices; ++i) 
     {
-      if ((!only_extended || (devices[i].use == IsXExtensionDevice)) &&
-          ((!is_id && strcmp(devices[i].name, name) == 0) ||
-           (is_id && devices[i].id == id))) {
-        return &devices[i];
+      if ((!only_extended || (x_devices[i].use == IsXExtensionDevice)) &&
+          ((!is_id && strcmp(x_devices[i].name, name) == 0) ||
+           (is_id && x_devices[i].id == id))) {
+        return &x_devices[i];
       }
     }
   return NULL;

Modified: trunk/pingus/src/input/xinput/xinput_driver.hpp
===================================================================
--- trunk/pingus/src/input/xinput/xinput_driver.hpp     2009-11-05 19:01:27 UTC 
(rev 4036)
+++ trunk/pingus/src/input/xinput/xinput_driver.hpp     2009-11-05 19:22:47 UTC 
(rev 4037)
@@ -34,13 +34,12 @@
 {
 private:
   SDL_SysWMinfo sys;
+  std::vector<XInputDevice*> devices;
 
+private:
   void setup_xinput();
   Bool xinput_is_present();
 
-  std::vector<XInputDevice*> devices;
-
-
   XDeviceInfo* find_device_info(Display *display,
                                 const char* name,
                                 Bool only_extended);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]