feuerkraft-cvs
[Top][All Lists]
Advanced

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

[Feuerkraft-CVS] rev 321 - in trunk/src: . input


From: Ingo Ruhnke
Subject: [Feuerkraft-CVS] rev 321 - in trunk/src: . input
Date: Thu, 11 Dec 2003 00:08:47 +0100

Author: grumbel
Date: 2003-12-11 00:08:47 +0100 (Thu, 11 Dec 2003)
New Revision: 321

Added:
   trunk/src/input/controller_def.cxx
   trunk/src/input/controller_def.hxx
Modified:
   trunk/src/
   trunk/src/game_session.cxx
   trunk/src/input/Makefile.am
   trunk/src/input/axis_factory.cxx
   trunk/src/input/button_factory.cxx
   trunk/src/input/controller.cxx
   trunk/src/input/controller.hxx
   trunk/src/input/input_event.hxx
   trunk/src/input/input_manager.cxx
   trunk/src/input/input_manager_custom.cxx
   trunk/src/input/input_manager_custom.hxx
   trunk/src/input/input_manager_impl.cxx
   trunk/src/input/input_manager_impl.hxx
   trunk/src/input/input_manager_player.cxx
Log:
- removed a bunch of hardcoded stuff from the input code, so it can be easier 
reused in, say Windstille
- disabled all the recording and video saving for the moment


Property changes on: trunk/src
___________________________________________________________________
Name: svn:ignore
   - feuerkraft
core
Makefile.in
Makefile
configure
autogen.sh
config.log
config.h
config.cache
config.status
stamp-h1
Makefile
stamp-h
Feuerkraft.ncb
Feuerkraft.opt
Feuerkraft.plg
Debug
Release
libs
.xvpics
.deps
*.a

   + feuerkraft
feuerkraft.static
feuerkraft.static.comp
core
Makefile.in
Makefile
configure
autogen.sh
config.log
config.h
config.cache
config.status
stamp-h1
Makefile
stamp-h
Feuerkraft.ncb
Feuerkraft.opt
Feuerkraft.plg
Debug
Release
libs
.xvpics
.deps
*.a


Modified: trunk/src/game_session.cxx
===================================================================
--- trunk/src/game_session.cxx  2003-12-10 12:11:31 UTC (rev 320)
+++ trunk/src/game_session.cxx  2003-12-10 23:08:47 UTC (rev 321)
@@ -233,7 +233,10 @@
 
   // Flip front and backbuffer. This makes the changes visible:
   CL_Display::flip ();
-  Screenshot::write_screenshot_pnm("/tmp/feuerkraft/" + to_string(frames));
+
+  if (0) // AVI
+    Screenshot::write_screenshot_pnm("/tmp/feuerkraft/" + to_string(frames));
+
   ++frames;
            
   // Update keyboard input and handle system events:

Modified: trunk/src/input/Makefile.am
===================================================================
--- trunk/src/input/Makefile.am 2003-12-10 12:11:31 UTC (rev 320)
+++ trunk/src/input/Makefile.am 2003-12-10 23:08:47 UTC (rev 321)
@@ -25,6 +25,8 @@
   axis_factory.hxx \
   axis_factory.cxx \
   input_recorder.hxx \
-  input_recorder.cxx
+  input_recorder.cxx \
+  controller_def.cxx \
+  controller_def.hxx
 
 # EOF #

Modified: trunk/src/input/axis_factory.cxx
===================================================================
--- trunk/src/input/axis_factory.cxx    2003-12-10 12:11:31 UTC (rev 320)
+++ trunk/src/input/axis_factory.cxx    2003-12-10 23:08:47 UTC (rev 321)
@@ -29,8 +29,8 @@
 {
   while(gh_pair_p(lst))
     {
-      SCM sym  = gh_caar(lst);
-      SCM data = gh_cdar(lst);
+      SCM sym  = gh_car(lst);
+      SCM data = gh_cdr(lst);
       
       if (gh_equal_p(sym, gh_symbol2scm("joystick-axis")))
         {

Modified: trunk/src/input/button_factory.cxx
===================================================================
--- trunk/src/input/button_factory.cxx  2003-12-10 12:11:31 UTC (rev 320)
+++ trunk/src/input/button_factory.cxx  2003-12-10 23:08:47 UTC (rev 321)
@@ -39,7 +39,8 @@
     }
   else
     {
-      std::cout << "ButtonFactory::create: parse error: ";
+      std::cout << "ButtonFactory::create: parse error: " << std::flush;
+      scm_flush_all_ports();
       gh_display(lst); std::cout << std::endl;
     }
       
@@ -64,7 +65,7 @@
 InputButton*
 ButtonFactory::create_keyboard_button(SCM lst)
 {
-  gh_display(lst);
+  //gh_display(lst);
   std::string key_str = Guile::scm2string(gh_car(lst));
   int key_num = CL_Keyboard::get_device().keyid_to_string(key_str);
 

Modified: trunk/src/input/controller.cxx
===================================================================
--- trunk/src/input/controller.cxx      2003-12-10 12:11:31 UTC (rev 320)
+++ trunk/src/input/controller.cxx      2003-12-10 23:08:47 UTC (rev 321)
@@ -22,93 +22,41 @@
 
 Controller::Controller()
 {
-  orientation_axis = 0.0f;
-  accelerate_axis  = 0.0f;
-  strafe_axis      = 0.0f;
-  
-  primary_fire_button   = false;
-  secondary_fire_button = false;
-  use_button  = false;
-  menu_button = false;
+  buttons.resize(ControllerDef::get_button_count());
+  axes.resize(ControllerDef::get_axis_count());
 }
 
 float
-Controller::get_axis_state(AxisName name) const
+Controller::get_axis_state(int name) const
 {
-  switch(name)
-    {
-    case ORIENTATION_AXIS:
-      return orientation_axis;
-    case ACCELERATE_AXIS:
-      return accelerate_axis;
-    case STRAFE_AXIS:
-      return strafe_axis;
-     
-    default:
-      AssertMsg(0, "Controllor: Unknown AxisName");
-      return 0;
-    }
+  AssertMsg(name < int(axes.size()), "Controllor: Unknown AxisName");  
+  return axes[name];
 }
+        
 
 bool
-Controller::get_button_state(ButtonName name) const
+Controller::get_button_state(int name) const
 {
-  switch(name)
-    {
-    case PRIMARY_FIRE_BUTTON:
-      return primary_fire_button;
-    case SECONDARY_FIRE_BUTTON:
-      return secondary_fire_button;
-
-    default:
-      AssertMsg(0, "Controller: Unknown ButtonName");
-      return false;
-    }
+  AssertMsg(name < int(buttons.size()), "Controllor: Unknown ButtonName");  
+  return buttons[name];
 }
 
 void
-Controller::set_axis_state(AxisName name, float pos)
+Controller::set_axis_state(int name, float pos)
 {
-  switch(name)
-    {
-    case ORIENTATION_AXIS:
-      orientation_axis = pos;
-      break;
-    case ACCELERATE_AXIS:
-      accelerate_axis = pos;
-      break;
-    case STRAFE_AXIS:
-      strafe_axis = pos;
-      break;
-    default:
-      AssertMsg(0, "Controllor: Unknown AxisName");
-    }
+  AssertMsg(name < static_cast<int>(axes.size()), "Controllor: Unknown 
AxisName");
+  axes[name] = pos;
 }
 
 void
-Controller::set_button_state(ButtonName name, bool down)
+Controller::set_button_state(int name, bool down)
 {
-  switch(name)
-    {
-    case PRIMARY_FIRE_BUTTON:
-      primary_fire_button = down;
-      break;
-    case SECONDARY_FIRE_BUTTON:
-      secondary_fire_button = down;
-      break;
-    case USE_BUTTON:
-      use_button = down;
-      break;
-    case MENU_BUTTON:
-      menu_button = down;
-      break;
-    default:
-      AssertMsg(0, "Controller: Unknown ButtonName");
-    }  
+  AssertMsg(name < static_cast<int>(buttons.size()), "Controller: Unknown 
ButtonName");
+  buttons[name] = down;
 }
 
 void
-Controller::add_axis_event(AxisName name, float pos)
+Controller::add_axis_event(int name, float pos)
 {
   InputEvent event;
   event.type = AXIS_EVENT;
@@ -118,7 +66,7 @@
 }
 
 void
-Controller::add_button_event(ButtonName name, bool down)
+Controller::add_button_event(int name, bool down)
 {
   InputEvent event;
   event.type = BUTTON_EVENT;
@@ -133,4 +81,10 @@
   return events;
 }
 
+void
+Controller::set_events(const InputEventLst& lst)
+{
+  events = lst;
+}
+
 /* EOF */

Modified: trunk/src/input/controller.hxx
===================================================================
--- trunk/src/input/controller.hxx      2003-12-10 12:11:31 UTC (rev 320)
+++ trunk/src/input/controller.hxx      2003-12-10 23:08:47 UTC (rev 321)
@@ -20,6 +20,8 @@
 #ifndef HEADER_CONTROLLER_HXX
 #define HEADER_CONTROLLER_HXX
 
+#include <vector>
+#include "controller_def.hxx"
 #include "input_event.hxx"
 
 /** The Controller class presents the current state of the controller
@@ -27,31 +29,29 @@
     last update */
 class Controller
 {
-public:
-  float orientation_axis;
-  float accelerate_axis;
-  float strafe_axis;
+private:
+  /** State of all buttons, indexed by ButtonName */
+  std::vector<bool> buttons;
+  
+  /** State of all axis, indexed by AxisName */
+  std::vector<float> axes;
 
-  bool primary_fire_button;
-  bool secondary_fire_button;
-  bool use_button;
-  bool menu_button;
-
   InputEventLst events;
 
 public:
   Controller();
 
-  float get_axis_state(AxisName name) const;
-  bool  get_button_state(ButtonName name) const;
+  float get_axis_state  (int name) const;
+  bool  get_button_state(int name) const;
 
-  void  set_axis_state(AxisName name, float pos);
-  void  set_button_state(ButtonName name, bool down);
+  void  set_axis_state  (int name, float pos);
+  void  set_button_state(int name, bool down);
 
-  void add_axis_event(AxisName name, float pos);
-  void add_button_event(ButtonName name, bool down);
+  void add_axis_event  (int name, float pos);
+  void add_button_event(int name, bool down);
 
   InputEventLst get_events() const;
+  void set_events(const InputEventLst& lst);
 };
 
 #endif

Added: trunk/src/input/controller_def.cxx
===================================================================
--- trunk/src/input/controller_def.cxx  2003-12-10 12:11:31 UTC (rev 320)
+++ trunk/src/input/controller_def.cxx  2003-12-10 23:08:47 UTC (rev 321)
@@ -0,0 +1,96 @@
+//  $Id$
+//
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2002 Ingo Ruhnke <address@hidden>
+//
+//  This program is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU General Public License
+//  as published by the Free Software Foundation; either version 2
+//  of the License, or (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+#include "controller_def.hxx"
+
+int
+ControllerDef::get_button_count()
+{
+  return 4;
+}
+
+int
+ControllerDef::get_axis_count()
+{
+  return 3;
+}
+
+std::string
+ControllerDef::button_id2name(int id)
+{
+  switch (id)
+    {
+    case PRIMARY_FIRE_BUTTON:
+      return "primary-button";
+    case SECONDARY_FIRE_BUTTON:
+      return "secondary-button";
+    case USE_BUTTON:
+      return "use-button";
+    case MENU_BUTTON:
+      return "menu-button";
+    default:
+      return "unknown";
+    }
+}
+
+int
+ControllerDef::button_name2id(const std::string& name)
+{
+  if      (name == "primary-button")
+    return PRIMARY_FIRE_BUTTON;
+  else if (name == "secondary-button")
+    return SECONDARY_FIRE_BUTTON;
+  else if (name == "use-button")
+    return USE_BUTTON;
+  else if (name == "menu-button")
+    return MENU_BUTTON;
+  else
+    return -1;
+}
+
+std::string
+ControllerDef::axis_id2name(int id)
+{
+  switch (id)
+    {
+    case ORIENTATION_AXIS:
+      return "orientation-axis";
+    case ACCELERATE_AXIS:
+      return "accelerate-axis";
+    case STRAFE_AXIS:
+      return "strafe-axis";
+    default:
+      return "unknown";
+    }
+}
+
+int 
+ControllerDef::axis_name2id(const std::string& name)
+{
+  if (name == "orientation-axis")
+    return ORIENTATION_AXIS;
+  else if (name == "accelerate-axis")
+    return ACCELERATE_AXIS;
+  else if (name == "strafe-axis")
+    return STRAFE_AXIS;
+  else
+    return -1;
+}
+
+/* EOF */

Added: trunk/src/input/controller_def.hxx
===================================================================
--- trunk/src/input/controller_def.hxx  2003-12-10 12:11:31 UTC (rev 320)
+++ trunk/src/input/controller_def.hxx  2003-12-10 23:08:47 UTC (rev 321)
@@ -0,0 +1,45 @@
+//  $Id$
+// 
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2002 Ingo Ruhnke <address@hidden>
+//
+//  This program is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU General Public License
+//  as published by the Free Software Foundation; either version 2
+//  of the License, or (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+// 
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+#ifndef HEADER_CONTROLLER_DEF_HXX
+#define HEADER_CONTROLLER_DEF_HXX
+
+#include <string>
+
+enum AxisName       { ORIENTATION_AXIS, ACCELERATE_AXIS, STRAFE_AXIS };
+enum ButtonName     { PRIMARY_FIRE_BUTTON, SECONDARY_FIRE_BUTTON, USE_BUTTON, 
MENU_BUTTON };
+
+/** */
+class ControllerDef
+{
+private:
+public:
+  static int         get_button_count();
+  static int         get_axis_count();
+
+  static std::string button_id2name(int id);
+  static int         button_name2id(const std::string& name);
+
+  static std::string axis_id2name(int id);
+  static int         axis_name2id(const std::string& name);
+};
+
+#endif
+
+/* EOF */

Modified: trunk/src/input/input_event.hxx
===================================================================
--- trunk/src/input/input_event.hxx     2003-12-10 12:11:31 UTC (rev 320)
+++ trunk/src/input/input_event.hxx     2003-12-10 23:08:47 UTC (rev 321)
@@ -23,12 +23,10 @@
 #include <vector>
 
 enum InputEventType { BUTTON_EVENT, AXIS_EVENT };
-enum AxisName       { ORIENTATION_AXIS, ACCELERATE_AXIS, STRAFE_AXIS };
-enum ButtonName     { PRIMARY_FIRE_BUTTON, SECONDARY_FIRE_BUTTON, USE_BUTTON, 
MENU_BUTTON };
 
 struct ButtonEvent
 {
-  ButtonName name;
+  int name;
 
   /** true if down, false if up */
   bool down;
@@ -39,7 +37,7 @@
 
 struct AxisEvent
 {
-  AxisName name;
+  int name;
 
   /** Pos can be in range from [-1.0, 1.0], some axis will only use [0,1.0] */
   float pos;

Modified: trunk/src/input/input_manager.cxx
===================================================================
--- trunk/src/input/input_manager.cxx   2003-12-10 12:11:31 UTC (rev 320)
+++ trunk/src/input/input_manager.cxx   2003-12-10 23:08:47 UTC (rev 321)
@@ -48,7 +48,7 @@
       recorder = 0;
     }
 
-  if (!recorder)
+  if (0)
     {
       recorder = new InputRecorder("/tmp/feuerkraft.rec");
     }
@@ -83,21 +83,25 @@
       
       if (!impl)
         { 
-#if 1
-          impl = new InputManagerPlayer("/tmp/feuerkraft1.rec");
-#else
-          // Set default configuration
-          impl = new InputManagerCustom
-            (gh_eval_str("'("
-                         "(primary-button   (joystick-button 1 1))"
-                         "(secondary-button (joystick-button 1 0))"
-                         "(use-button       (joystick-button 1 3))"
-                         "(menu-button      (joystick-button 1 2))"
-                         "(orientation-axis (joystick-axis 1 0))"
-                         "(accelerate-axis  (joystick-axis 1 1))"
-                         "(strafe-axis      (joystick-axis 1 2))"
-                         ")"));
-#endif
+          if (0)
+            { // AVI
+              impl = new InputManagerPlayer("/tmp/feuerkraft1.rec");
+            }
+          else
+            {
+              // FIXME: Default to keyboard would be better
+              // Set default configuration
+              impl = new InputManagerCustom
+                (gh_eval_str("'("
+                             "(primary-button   (joystick-button 1 9))"
+                             "(secondary-button (joystick-button 1 8))"
+                             "(use-button       (joystick-button 1 3))"
+                             "(menu-button      (joystick-button 1 2))"
+                             "(orientation-axis (joystick-axis 1 0))"
+                             "(accelerate-axis  (joystick-axis 1 1))"
+                             "(strafe-axis      (joystick-axis 1 2))"
+                             ")"));
+            }
         }     
     }
 }
@@ -113,7 +117,8 @@
 {
   assert(impl);
   impl->update(delta);
-  recorder->record(get_controller());
+  if (recorder)
+    recorder->record(get_controller());
 }
 
 InputEventLst

Modified: trunk/src/input/input_manager_custom.cxx
===================================================================
--- trunk/src/input/input_manager_custom.cxx    2003-12-10 12:11:31 UTC (rev 
320)
+++ trunk/src/input/input_manager_custom.cxx    2003-12-10 23:08:47 UTC (rev 
321)
@@ -24,10 +24,12 @@
 #include <ClanLib/Display/keys.h>
 
 #include "../guile.hxx"
+#include "../assert.hxx"
 #include "input_button_input_device.hxx"
 #include "input_axis_input_device.hxx"
 #include "button_factory.hxx"
 #include "axis_factory.hxx"
+#include "controller_def.hxx"
 
 #include "input_manager_custom.hxx"
 
@@ -35,86 +37,87 @@
 {
   init(lst);
 
-  slots.push_back(primary_button->on_key_down().connect  (this, 
&InputManagerCustom::on_button_down, PRIMARY_FIRE_BUTTON));
-  slots.push_back(secondary_button->on_key_down().connect(this, 
&InputManagerCustom::on_button_down, SECONDARY_FIRE_BUTTON));
-  slots.push_back(use_button->on_key_down().connect      (this, 
&InputManagerCustom::on_button_down, USE_BUTTON));
-  slots.push_back(menu_button->on_key_down().connect     (this, 
&InputManagerCustom::on_button_down, MENU_BUTTON));
+  for (int i = 0; i < (int)buttons.size(); ++i)
+    {
+      if (buttons[i])
+        {
+          slots.push_back(buttons[i]->on_key_down().connect(this, 
&InputManagerCustom::on_button_down, i));
+          slots.push_back(buttons[i]->on_key_up().connect  (this, 
&InputManagerCustom::on_button_up,   i));
+        }
+      else
+        {
+          std::cout << "Button " << i << " not configured" << std::endl;
+        }
+    }
 
-  slots.push_back(primary_button->on_key_up().connect  (this, 
&InputManagerCustom::on_button_up, PRIMARY_FIRE_BUTTON));
-  slots.push_back(secondary_button->on_key_up().connect(this, 
&InputManagerCustom::on_button_up, SECONDARY_FIRE_BUTTON));
-  slots.push_back(use_button->on_key_up().connect      (this, 
&InputManagerCustom::on_button_up, USE_BUTTON));
-  slots.push_back(menu_button->on_key_up().connect     (this, 
&InputManagerCustom::on_button_up, MENU_BUTTON));
-  
-  slots.push_back(orientation_axis->on_move().connect(this, 
&InputManagerCustom::on_axis_move, ORIENTATION_AXIS));
-  slots.push_back(accelerate_axis->on_move().connect(this, 
&InputManagerCustom::on_axis_move, ACCELERATE_AXIS));
-  slots.push_back(strafe_axis->on_move().connect(this, 
&InputManagerCustom::on_axis_move, STRAFE_AXIS));
+  for (int i = 0; i < (int)buttons.size(); ++i)
+    {
+      if (axes[i])
+        {
+          slots.push_back(axes[i]->on_move().connect(this, 
&InputManagerCustom::on_axis_move, i));
+        }
+      else
+        {
+          std::cout << "Axis " << i << " not configured" << std::endl;
+        }
+    }
 }
 
 void 
 InputManagerCustom::init(SCM lst)
 {
+  buttons.resize(ControllerDef::get_button_count());
+  axes.resize(ControllerDef::get_axis_count());
+  
   std::cout << "InputManagerCustom::init" << std::endl;
   while (gh_pair_p(lst))
     {
-      gh_display(gh_car(lst)); gh_newline();
+      //gh_display(gh_car(lst)); gh_newline();
       SCM sym  = gh_caar(lst);
-      SCM data = gh_cdar(lst);
+      SCM data = gh_cadar(lst);
 
-      gh_display(sym); gh_newline();
+      //gh_display(sym); gh_newline();
+      
+      std::string name = Guile::symbol2string(sym);
 
-      if (gh_equal_p(sym, gh_symbol2scm("primary-button")))
+      int id = ControllerDef::button_name2id(name);
+      if (id != -1)
         {
-          primary_button = ButtonFactory::create(gh_car(data));
+          buttons[id] = ButtonFactory::create(data);
         }
-      else if (gh_equal_p(sym, gh_symbol2scm("secondary-button")))
-        {
-          secondary_button =  ButtonFactory::create(gh_car(data));
-        }
-      else if (gh_equal_p(sym, gh_symbol2scm("use-button")))
-        {
-          use_button = ButtonFactory::create(gh_car(data));
-        }
-      else if (gh_equal_p(sym, gh_symbol2scm("menu-button")))
-        {
-          menu_button = ButtonFactory::create(gh_car(data));
-        }
-      else if (gh_equal_p(sym, gh_symbol2scm("orientation-axis")))
-        {
-          orientation_axis = AxisFactory::create(data);
-        }
-      else if (gh_equal_p(sym, gh_symbol2scm("accelerate-axis")))
-        {
-          accelerate_axis = AxisFactory::create(data);
-        }
-      else if (gh_equal_p(sym, gh_symbol2scm("strafe-axis")))
-        {
-          strafe_axis = AxisFactory::create(data);
-        }
       else
         {
-          std::cout << "InputManagerCustom::init: Error unknown tag: " << 
Guile::symbol2string(sym) << std::endl;
+          id = ControllerDef::axis_name2id(name);
+          if (id != -1)
+            {
+              axes[id] = AxisFactory::create(data);
+            }
+          else
+            {
+              std::cout << "InputManagerCustom::init: Error unknown tag: " << 
Guile::symbol2string(sym) << std::endl;
+            }
         }
-      
+
       lst = gh_cdr(lst);
     }
 }  
 
 void
-InputManagerCustom::on_axis_move(float pos, AxisName name)
+InputManagerCustom::on_axis_move(float pos, int name)
 {
   add_axis_event(name, pos);
   controller.set_axis_state(name, pos);
 }
 
 void
-InputManagerCustom::on_button_up(ButtonName name)
+InputManagerCustom::on_button_up(int name)
 {
   add_button_event(name, false);
   controller.set_button_state(name, false);
 }
 
 void
-InputManagerCustom::on_button_down(ButtonName name)
+InputManagerCustom::on_button_down(int name)
 {
   add_button_event(name, true);
   controller.set_button_state(name, true);
@@ -123,14 +126,17 @@
 void
 InputManagerCustom::update(float delta)
 {
-  primary_button->update(delta);
-  secondary_button->update(delta);
-  use_button->update(delta);
-  menu_button->update(delta);
+  for (int i = 0; i < (int)buttons.size(); ++i)
+    {
+      if (buttons[i])
+        buttons[i]->update(delta);
+    }
 
-  orientation_axis->update(delta);
-  accelerate_axis->update(delta);
-  strafe_axis->update(delta);
+  for (int i = 0; i < (int)axes.size(); ++i)
+    {
+      if (axes[i])
+        axes[i]->update(delta);
+    }
 }
 
 /* EOF */

Modified: trunk/src/input/input_manager_custom.hxx
===================================================================
--- trunk/src/input/input_manager_custom.hxx    2003-12-10 12:11:31 UTC (rev 
320)
+++ trunk/src/input/input_manager_custom.hxx    2003-12-10 23:08:47 UTC (rev 
321)
@@ -34,23 +34,20 @@
 private:
   std::vector<CL_Slot> slots;
 
-  InputButton* primary_button;
-  InputButton* secondary_button;
-  InputButton* use_button;
-  InputButton* menu_button;
+  typedef std::vector<InputAxis*>   Axes;
+  typedef std::vector<InputButton*> Buttons;
+  
+  Axes    axes;
+  Buttons buttons;
 
-  InputAxis* orientation_axis;
-  InputAxis* accelerate_axis;
-  InputAxis* strafe_axis;
-
 public:
   InputManagerCustom(SCM lst);
   
   void update(float delta);
 
-  void on_button_up(ButtonName name);
-  void on_button_down(ButtonName name);
-  void on_axis_move(float pos, AxisName name);
+  void on_button_up(int name);
+  void on_button_down(int name);
+  void on_axis_move(float pos, int name);
 private:
   void init(SCM lst);
 

Modified: trunk/src/input/input_manager_impl.cxx
===================================================================
--- trunk/src/input/input_manager_impl.cxx      2003-12-10 12:11:31 UTC (rev 
320)
+++ trunk/src/input/input_manager_impl.cxx      2003-12-10 23:08:47 UTC (rev 
321)
@@ -28,12 +28,12 @@
 Controller
 InputManagerImpl::get_controller()
 {
-  controller.events = events;
+  controller.set_events(events);
   return controller;
 }
 
 void
-InputManagerImpl::add_axis_event(AxisName name, float pos)
+InputManagerImpl::add_axis_event(int name, float pos)
 {
   InputEvent event;
   event.type = AXIS_EVENT;
@@ -43,7 +43,7 @@
 }
 
 void
-InputManagerImpl::add_button_event(ButtonName name, bool down)
+InputManagerImpl::add_button_event(int name, bool down)
 {
   InputEvent event;
   event.type = BUTTON_EVENT;

Modified: trunk/src/input/input_manager_impl.hxx
===================================================================
--- trunk/src/input/input_manager_impl.hxx      2003-12-10 12:11:31 UTC (rev 
320)
+++ trunk/src/input/input_manager_impl.hxx      2003-12-10 23:08:47 UTC (rev 
321)
@@ -37,11 +37,12 @@
   virtual void update(float delta) =0;
   
   InputEventLst get_events();
+
   Controller get_controller();
   void clear();
 
-  void add_axis_event(AxisName name, float pos);
-  void add_button_event(ButtonName name, bool down);
+  void add_axis_event  (int name, float pos);
+  void add_button_event(int name, bool down);
 private:
   InputManagerImpl(const InputManagerImpl&);
   InputManagerImpl& operator=(const InputManagerImpl&);

Modified: trunk/src/input/input_manager_player.cxx
===================================================================
--- trunk/src/input/input_manager_player.cxx    2003-12-10 12:11:31 UTC (rev 
320)
+++ trunk/src/input/input_manager_player.cxx    2003-12-10 23:08:47 UTC (rev 
321)
@@ -42,7 +42,7 @@
       std::cout << "Entry: " << entry_num << " events: " << lst.size() << 
std::endl;
       entries.push(Entry(entry_num, lst));
     }
-  gh_display(entry);gh_newline();
+  //gh_display(entry);gh_newline();
   scm_close_port(port);
 }
 
@@ -56,19 +56,20 @@
   if (gh_equal_p(gh_symbol2scm("axis"), sym)) 
     {
       event.type = AXIS_EVENT;
-      event.axis.name = (AxisName)gh_scm2int(gh_car(data));
+      event.axis.name = gh_scm2int(gh_car(data));
       event.axis.pos  = gh_scm2double(gh_cadr(data));
     } 
   else if (gh_equal_p(gh_symbol2scm("button"), sym))
     {
       event.type = BUTTON_EVENT;
-      event.button.name = (ButtonName)gh_scm2int(gh_car(data));
+      event.button.name = gh_scm2int(gh_car(data));
       event.button.down = gh_scm2int(gh_cadr(data));
     } 
   else 
     {
-      std::cout << "scm2event: Unknown sym: ";
+      std::cout << "scm2event: Unknown sym: " << std::flush;
       gh_display(sym);
+      scm_flush_all_ports();
       std::cout << std::endl;
     }
   return event;





reply via email to

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