pingus-cvs
[Top][All Lists]
Advanced

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

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


From: grumbel at BerliOS
Subject: [Pingus-CVS] r2767 - in branches/pingus_sdl/src: . input
Date: Thu, 2 Aug 2007 03:49:56 +0200

Author: grumbel
Date: 2007-08-02 03:49:53 +0200 (Thu, 02 Aug 2007)
New Revision: 2767

Modified:
   branches/pingus_sdl/src/SConscript
   branches/pingus_sdl/src/global_event.cpp
   branches/pingus_sdl/src/global_event.hpp
   branches/pingus_sdl/src/input/controller.cpp
Log:
- fixed GlobalEvent (include global_event.cpp in your build files if you are 
not using SCons)
- press 'Ctrl+m' for maintainer-mode and then 'c' to see the collision map of a 
level

Modified: branches/pingus_sdl/src/SConscript
===================================================================
--- branches/pingus_sdl/src/SConscript  2007-08-02 01:18:50 UTC (rev 2766)
+++ branches/pingus_sdl/src/SConscript  2007-08-02 01:49:53 UTC (rev 2767)
@@ -148,7 +148,7 @@
 'game_session_result.cpp', 
 'game_time.cpp', 
 'gettext.cpp', 
-# 'global_event.cpp', 
+'global_event.cpp', 
 'globals.cpp', 
 'goal_manager.cpp', 
 'graphic_context_state.cpp', 

Modified: branches/pingus_sdl/src/global_event.cpp
===================================================================
--- branches/pingus_sdl/src/global_event.cpp    2007-08-02 01:18:50 UTC (rev 
2766)
+++ branches/pingus_sdl/src/global_event.cpp    2007-08-02 01:49:53 UTC (rev 
2767)
@@ -20,17 +20,12 @@
 #include <config.h>
 #include <stdio.h>
 #include <algorithm>
-#include <ClanLib/Display/keyboard.h>
-#include <ClanLib/Display/display.h>
-#include <ClanLib/Display/input_event.h>
-#include <ClanLib/Display/keys.h>
-#include "screenshot.hpp"
+//#include "screenshot.hpp"
 #include "console.hpp"
 #include "fps_counter.hpp"
 #include "global_event.hpp"
 #include "globals.hpp"
 
-
 GlobalEvent global_event;
 
 GlobalEvent::GlobalEvent ()
@@ -38,70 +33,65 @@
 }
 
 void
-GlobalEvent::on_button_press(const CL_InputEvent& event)
+GlobalEvent::on_button_press(const SDL_KeyboardEvent& event)
 {
-  if (event.device.get_type() == CL_InputDevice::keyboard)
+  Uint8 *keystate = SDL_GetKeyState(NULL);
+
+  std::cout << "GlobalEvent: " << event.keysym.sym << std::endl;
+  switch (event.keysym.sym)
     {
-      switch (event.id)
-       {
-       case CL_KEY_F1:
-         console.toggle_display();
-         break;
+    case SDLK_F1:
+      console.toggle_display();
+      break;
 
-       case CL_KEY_F10:
-         fps_counter.toggle_display();
-         console << "Toggling fps counter display" << std::endl;
-          break;
+    case SDLK_F10:
+      fps_counter.toggle_display();
+      console << "Toggling fps counter display" << std::endl;
+      break;
 
-       case CL_KEY_F11:
-          if (CL_Display::is_fullscreen())
-            CL_Display::set_windowed();
-          else
-            CL_Display::set_fullscreen(CL_Display::get_width(),
-                                       CL_Display::get_height(),
-                                       32);
-          break;
+#if 0
+    case SDLK_F11:
+      if (CL_Display::is_fullscreen())
+        CL_Display::set_windowed();
+      else
+        CL_Display::set_fullscreen(CL_Display::get_width(),
+                                   CL_Display::get_height(),
+                                   32);
+      break;
 
-       case CL_KEY_F12:
-         {
-           std::string filename;
-           std::cout << "GlobalEvent::Making screenshot..." << std::endl;
-           filename = Screenshot::make_screenshot();
-           console << "GlobalEvent: Saved screenshot to \"" << filename << 
"\"" << std::endl;
-           //console << "!\"#$%&'()*+,-./0123456789:;<=>?@";
-           console.newline();
-         }
-         break;
+    case SDLK_F12:
+      {
+        std::string filename;
+        std::cout << "GlobalEvent::Making screenshot..." << std::endl;
+        filename = Screenshot::make_screenshot();
+        console << "GlobalEvent: Saved screenshot to \"" << filename << "\"" 
<< std::endl;
+        //console << "!\"#$%&'()*+,-./0123456789:;<=>?@";
+        console.newline();
+      }
+      break;
+#endif 
 
-       case CL_KEY_C:
-          if (maintainer_mode)
-            draw_collision_map = !draw_collision_map;
-         break;
+    case SDLK_c:
+      if (maintainer_mode)
+        draw_collision_map = !draw_collision_map;
+      break;
 
-        case CL_KEY_M:
-          if (CL_Keyboard::get_keycode(CL_KEY_LCONTROL) || 
CL_Keyboard::get_keycode(CL_KEY_RCONTROL) )
-            {
-              std::cout << "Maintainer Mode: " << maintainer_mode << std::endl;
-              maintainer_mode = !maintainer_mode;
-            }
-          break;
+    case SDLK_m:
+      if (keystate[SDLK_LCTRL] || keystate[SDLK_RCTRL])
+        {
+          std::cout << "Maintainer Mode: " << maintainer_mode << std::endl;
+          maintainer_mode = !maintainer_mode;
+        }
+      break;
 
-       case CL_KEY_END:
-         if (CL_Keyboard::get_keycode(CL_KEY_LCONTROL))
-           {
-             puts ("---:: Emergency exit ::---");
-             exit (0);
-           }
-
-       default:
-         // console << "GlobalEvent: Unknown key pressed: " << key.id;
-         break;
-       }
+    default:
+      // console << "GlobalEvent: Unknown key pressed: " << key.id;
+      break;
     }
 }
 
 void
-GlobalEvent::on_button_release(const CL_InputEvent& event)
+GlobalEvent::on_button_release(const SDL_KeyboardEvent& event)
 {
 }
 

Modified: branches/pingus_sdl/src/global_event.hpp
===================================================================
--- branches/pingus_sdl/src/global_event.hpp    2007-08-02 01:18:50 UTC (rev 
2766)
+++ branches/pingus_sdl/src/global_event.hpp    2007-08-02 01:49:53 UTC (rev 
2767)
@@ -20,20 +20,17 @@
 #ifndef HEADER_PINGUS_GLOBAL_EVENT_HXX
 #define HEADER_PINGUS_GLOBAL_EVENT_HXX
 
+#include "SDL.h"
 #include "pingus.hpp"
 
-class CL_Key;
-class CL_InputDevice;
-
-
 class GlobalEvent
 {
 public:
   GlobalEvent ();
   virtual ~GlobalEvent() {}
 
-  virtual void on_button_press(const CL_InputEvent& event);
-  virtual void on_button_release(const CL_InputEvent& event);
+  virtual void on_button_press(const   SDL_KeyboardEvent& event);
+  virtual void on_button_release(const SDL_KeyboardEvent& event);
 
 private:
    GlobalEvent (const GlobalEvent&);

Modified: branches/pingus_sdl/src/input/controller.cpp
===================================================================
--- branches/pingus_sdl/src/input/controller.cpp        2007-08-02 01:18:50 UTC 
(rev 2766)
+++ branches/pingus_sdl/src/input/controller.cpp        2007-08-02 01:49:53 UTC 
(rev 2767)
@@ -34,6 +34,7 @@
 #include "buttons/key_button.hpp"
 #include "buttons/mouse_button.hpp"
 #include "scrollers/axis_scroller.hpp"
+#include "../global_event.hpp"
 
 namespace Input {
 
@@ -268,6 +269,8 @@
           
         case SDL_KEYDOWN:
           {
+            global_event.on_button_press(event.key);
+ 
             std::vector<key_callback_info>::iterator i;
             for (i = key_callbacks.begin(); i != key_callbacks.end(); ++i)
               {
@@ -280,6 +283,8 @@
 
         case SDL_KEYUP:
           {
+            global_event.on_button_release(event.key);
+      
             std::vector<key_callback_info>::iterator i;
             for (i = key_callbacks.begin(); i != key_callbacks.end(); ++i)
               {





reply via email to

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