pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r2684 - in branches/pingus_sdl/src: components gui input ma


From: grumbel at BerliOS
Subject: [Pingus-CVS] r2684 - in branches/pingus_sdl/src: components gui input math
Date: Wed, 17 Jan 2007 23:19:42 +0100

Author: grumbel
Date: 2007-01-17 23:19:41 +0100 (Wed, 17 Jan 2007)
New Revision: 2684

Modified:
   branches/pingus_sdl/src/components/playfield.cxx
   branches/pingus_sdl/src/gui/screen_manager.cxx
   branches/pingus_sdl/src/gui/screen_manager.hxx
   branches/pingus_sdl/src/input/controller.cxx
   branches/pingus_sdl/src/math/vector2f.hpp
Log:
- added basic input support

Modified: branches/pingus_sdl/src/components/playfield.cxx
===================================================================
--- branches/pingus_sdl/src/components/playfield.cxx    2007-01-17 21:37:42 UTC 
(rev 2683)
+++ branches/pingus_sdl/src/components/playfield.cxx    2007-01-17 22:19:41 UTC 
(rev 2684)
@@ -127,7 +127,6 @@
 void
 Playfield::update(float delta)
 {
-#if 0
   // FIXME: This should be delta dependant
   if (!mouse_scrolling)
     {
@@ -171,7 +170,6 @@
          state.set_pos(state.get_pos() + Vector2i(0, scroll_speed));    
        }
     }
-#endif
 }
 
 void
@@ -189,6 +187,7 @@
 void
 Playfield::on_secondary_button_press (int x, int y)
 {
+  std::cout << "on_secondary_button_press" << std::endl;
   mouse_scrolling = true;
   scroll_center.x = x;
   scroll_center.y = y;
@@ -199,6 +198,8 @@
 void
 Playfield::on_secondary_button_release (int x, int y)
 {
+  std::cout << "on_secondary_button_release" << std::endl;
+
   UNUSED_ARG(x);
   UNUSED_ARG(y);
 

Modified: branches/pingus_sdl/src/gui/screen_manager.cxx
===================================================================
--- branches/pingus_sdl/src/gui/screen_manager.cxx      2007-01-17 21:37:42 UTC 
(rev 2683)
+++ branches/pingus_sdl/src/gui/screen_manager.cxx      2007-01-17 22:19:41 UTC 
(rev 2684)
@@ -45,7 +45,6 @@
 void
 ScreenManager::display()
 {
-#if 0
   Input::Controller* input_controller = 0;
 
   if (controller_file.empty())
@@ -61,7 +60,6 @@
       Display::add_flip_screen_hook(cursor);
       //CL_MouseCursor::hide();
     }
-#endif
 
   DeltaManager delta_manager;
 
@@ -78,25 +76,21 @@
          continue;
        }
 
-      process_events();
-
       // Get new events from ClanLib
-      ////input_controller->update(time_delta);
+      input_controller->update(time_delta);
 
       // Fill the delta with values
-      GameDelta delta(time_delta, delta_manager.get_absolute(), 
Input::EventLst()); 
-      ////input_controller->get_events());
-      //// input_controller->clear();
+      GameDelta delta(time_delta, delta_manager.get_absolute(),  
+                      input_controller->get_events());
+      input_controller->clear();
 
       last_screen = get_current_screen();
 
       // Most likly the screen will get changed in this update call
       get_current_screen()->update (delta);
 
-#if 0
       if (cursor)
         cursor->update(time_delta);
-#endif
 
       // Last screen has poped, so we are going to end here
       if (screens.empty())
@@ -145,33 +139,11 @@
       SDL_Delay(10);
     }
 
-#if 0
-////  Display::remove_flip_screen_hook(cursor);
-////  delete cursor;
+  Display::remove_flip_screen_hook(cursor);
+  delete cursor;
   delete input_controller;
-#endif 
 }
 
-void
-ScreenManager::process_events()
-{
-  // Let SDL fetch events
-  SDL_Event event;
-  while(SDL_PollEvent(&event))
-    {
-      switch(event.type)
-        {
-        case SDL_QUIT:
-          pop_screen();
-          break;
-
-        default:
-          // FIXME: feed other events to the input manager
-          break;
-        }
-    }
-}
-
 ScreenPtr&
 ScreenManager::get_current_screen()
 {

Modified: branches/pingus_sdl/src/gui/screen_manager.hxx
===================================================================
--- branches/pingus_sdl/src/gui/screen_manager.hxx      2007-01-17 21:37:42 UTC 
(rev 2683)
+++ branches/pingus_sdl/src/gui/screen_manager.hxx      2007-01-17 22:19:41 UTC 
(rev 2684)
@@ -80,8 +80,6 @@
   /** FadeOver test*/
   void fade_over (ScreenPtr& old_screen, ScreenPtr& new_screen);
 
-  void process_events();
-
   /** @return a pointer to the current Screen */
   ScreenPtr& get_current_screen();
 

Modified: branches/pingus_sdl/src/input/controller.cxx
===================================================================
--- branches/pingus_sdl/src/input/controller.cxx        2007-01-17 21:37:42 UTC 
(rev 2683)
+++ branches/pingus_sdl/src/input/controller.cxx        2007-01-17 22:19:41 UTC 
(rev 2684)
@@ -17,6 +17,9 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include "SDL.h"
+#include "../gui/screen_manager.hxx"
+
 #include "../debug.hxx"
 #include "../pingus_error.hxx"
 
@@ -212,6 +215,50 @@
 void
 Controller::update (float delta)
 {
+  // Let SDL fetch events
+  SDL_Event event;
+  while(SDL_PollEvent(&event))
+    {
+      switch(event.type)
+        {
+        case SDL_QUIT:
+          ScreenManager::instance()->pop_screen();
+          break;
+
+        case SDL_MOUSEMOTION:
+          events.push_back(makePointerEvent(Input::standard, event.motion.x, 
event.motion.y));
+          break;
+
+        case SDL_MOUSEBUTTONDOWN:
+          if (event.button.button == SDL_BUTTON_LEFT)
+            events.push_back(makeButtonEvent(Input::primary, Input::pressed));
+          else if (event.button.button == SDL_BUTTON_MIDDLE)
+            events.push_back(makeButtonEvent(Input::pause, Input::pressed));
+          else if (event.button.button == SDL_BUTTON_RIGHT)
+            events.push_back(makeButtonEvent(Input::secondary, 
Input::pressed));
+          break;
+
+        case SDL_MOUSEBUTTONUP:
+          if (event.button.button == SDL_BUTTON_LEFT)
+            events.push_back(makeButtonEvent(Input::primary, Input::released));
+          else if (event.button.button == SDL_BUTTON_MIDDLE)
+            events.push_back(makeButtonEvent(Input::pause, Input::released));
+          else if (event.button.button == SDL_BUTTON_RIGHT)
+            events.push_back(makeButtonEvent(Input::secondary, 
Input::released));
+          break;
+          
+        case SDL_KEYDOWN:
+          break;
+
+        case SDL_KEYUP:
+          break;          
+
+        default:
+          // FIXME: feed other events to the input manager
+          break;
+        }
+    }
+
 #if 0
   scroller        ->update(delta);
   standard_pointer->update(delta);

Modified: branches/pingus_sdl/src/math/vector2f.hpp
===================================================================
--- branches/pingus_sdl/src/math/vector2f.hpp   2007-01-17 21:37:42 UTC (rev 
2683)
+++ branches/pingus_sdl/src/math/vector2f.hpp   2007-01-17 22:19:41 UTC (rev 
2684)
@@ -21,6 +21,7 @@
 #define SUPERTUX_VECTOR_H
 
 #include <iosfwd>
+#include "vector2i.hpp"
 
 /** Simple two dimensional vector. */
 class Vector2f
@@ -32,6 +33,9 @@
   Vector2f(const Vector2f& other)
       : x(other.x), y(other.y)
   { }
+  Vector2f(const Vector2i& other)
+    : x(other.x), y(other.y)
+  {}
   Vector2f()
       : x(0), y(0)
   { }





reply via email to

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