pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r2755 - in branches/pingus_sdl: . src/input src/input/butto


From: jsalmon3
Subject: [Pingus-CVS] r2755 - in branches/pingus_sdl: . src/input src/input/buttons src/input/pointers
Date: Wed, 18 Jul 2007 07:27:49 +0200

Author: jsalmon3
Date: 2007-07-18 07:27:33 +0200 (Wed, 18 Jul 2007)
New Revision: 2755

Modified:
   branches/pingus_sdl/pingus.vcproj
   branches/pingus_sdl/src/input/buttons/mouse_button.cpp
   branches/pingus_sdl/src/input/controller.cpp
   branches/pingus_sdl/src/input/pointers/mouse_pointer.cpp
   branches/pingus_sdl/src/input/pointers/mouse_pointer.hpp
Log:
Implemented mouse pointer

Modified: branches/pingus_sdl/pingus.vcproj
===================================================================
--- branches/pingus_sdl/pingus.vcproj   2007-07-18 04:49:34 UTC (rev 2754)
+++ branches/pingus_sdl/pingus.vcproj   2007-07-18 05:27:33 UTC (rev 2755)
@@ -1649,6 +1649,10 @@
                                                >
                                        </File>
                                        <File
+                                               
RelativePath=".\src\input\pointers\mouse_pointer.hpp"
+                                               >
+                                       </File>
+                                       <File
                                                
RelativePath=".\src\input\pointers\multiple_pointer.cpp"
                                                >
                                        </File>

Modified: branches/pingus_sdl/src/input/buttons/mouse_button.cpp
===================================================================
--- branches/pingus_sdl/src/input/buttons/mouse_button.cpp      2007-07-18 
04:49:34 UTC (rev 2754)
+++ branches/pingus_sdl/src/input/buttons/mouse_button.cpp      2007-07-18 
05:27:33 UTC (rev 2755)
@@ -38,6 +38,9 @@
 void
 MouseButton::mouse_handler(const SDL_Event& event, void* userdata)
 {
+  if (event.type != SDL_MOUSEBUTTONDOWN && event.type != SDL_MOUSEBUTTONUP)
+    return;
+
   MouseButton* mb = (MouseButton*)userdata;
   switch (mb->button)
     {

Modified: branches/pingus_sdl/src/input/controller.cpp
===================================================================
--- branches/pingus_sdl/src/input/controller.cpp        2007-07-18 04:49:34 UTC 
(rev 2754)
+++ branches/pingus_sdl/src/input/controller.cpp        2007-07-18 05:27:33 UTC 
(rev 2755)
@@ -59,8 +59,6 @@
     }
   else
     {
-      FileReader head;
-
       const std::vector<FileReader>& sections = reader.get_sections();
       for (std::vector<FileReader>::const_iterator i = sections.begin();
           i != sections.end(); ++i)
@@ -239,8 +237,14 @@
           break;
 
         case SDL_MOUSEMOTION:
-          events.push_back(makePointerEvent(Input::standard, event.motion.x, 
event.motion.y));
-          break;
+         {
+            std::vector<mouse_callback_info>::iterator i;
+            for (i = mouse_callbacks.begin(); i != mouse_callbacks.end(); ++i)
+              {
+                i->callback(event, i->userdata);
+              }
+            break;
+         }
 
         case SDL_MOUSEBUTTONDOWN:
          {
@@ -299,7 +303,6 @@
       it != buttons.end(); ++it)
     it->second->update(delta);
 
-#if 0
   // FIXME: Busy checking of button status and other events is *VERY EVIL*
   if (std_pointer_x != standard_pointer->get_x_pos()
       || std_pointer_y != standard_pointer->get_y_pos())
@@ -309,7 +312,6 @@
 
       events.push_back(makePointerEvent(standard, std_pointer_x, 
std_pointer_y));
     }
-#endif
 
   // FIXME: Busy checking of button status and other events is *VERY EVIL*
   if (scroller->get_x_delta() || scroller->get_y_delta())

Modified: branches/pingus_sdl/src/input/pointers/mouse_pointer.cpp
===================================================================
--- branches/pingus_sdl/src/input/pointers/mouse_pointer.cpp    2007-07-18 
04:49:34 UTC (rev 2754)
+++ branches/pingus_sdl/src/input/pointers/mouse_pointer.cpp    2007-07-18 
05:27:33 UTC (rev 2755)
@@ -25,8 +25,8 @@
 MousePointer::MousePointer() 
   : x_pos(0),
     y_pos(0)
-//    move_slot(CL_Mouse::sig_move().connect(this, 
&Input::Pointers::MousePointer::move_signal))
 {
+  Controller::add_mouse_callback(MousePointer::move_signal, this);
 }
 
 const float&
@@ -44,10 +44,7 @@
 void
 MousePointer::set_pos(float new_x, float new_y)
 {
-#if 0
-  CL_Mouse::set_position(static_cast<int>(new_x),
-                         static_cast<int>(new_y));
-#endif
+  SDL_WarpMouse(static_cast<int>(new_x), static_cast<int>(new_y));
 }
 
 void
@@ -55,14 +52,16 @@
 {
 }
 
-#if 0
 void
-MousePointer::move_signal(const CL_InputEvent& event)
+MousePointer::move_signal(const SDL_Event& event, void* userdata)
 {
-  x_pos = (float)event.mouse_pos.x;
-  y_pos = (float)event.mouse_pos.y;
+  if (event.type != SDL_MOUSEMOTION)
+    return;
+
+  MousePointer* mp = (MousePointer*)userdata;
+  mp->x_pos = (float)event.motion.x;
+  mp->y_pos = (float)event.motion.y;
 }
-#endif
 
 } // namespace Pointers
 } // namespace Input

Modified: branches/pingus_sdl/src/input/pointers/mouse_pointer.hpp
===================================================================
--- branches/pingus_sdl/src/input/pointers/mouse_pointer.hpp    2007-07-18 
04:49:34 UTC (rev 2754)
+++ branches/pingus_sdl/src/input/pointers/mouse_pointer.hpp    2007-07-18 
05:27:33 UTC (rev 2755)
@@ -21,6 +21,7 @@
 #define HEADER_PINGUS_INPUT_MOUSE_POINTER_HXX
 
 #include "../pointer.hpp"
+#include "../controller.hpp"
 
 namespace Input {
 namespace Pointers {
@@ -35,7 +36,6 @@
 private:
   float x_pos;
   float y_pos;
-//  CL_Slot move_slot;
 
 public:
   MousePointer();
@@ -48,7 +48,7 @@
   virtual void update(float);
 
 private:
-//  void move_signal(const CL_InputEvent& event);
+  static void move_signal(const SDL_Event&, void*);
       
   MousePointer(const MousePointer&);
   MousePointer& operator= (const MousePointer&);





reply via email to

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