feuerkraft-cvs
[Top][All Lists]
Advanced

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

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


From: Ingo Ruhnke
Subject: [Feuerkraft-CVS] rev 314 - in trunk/src: . input
Date: Tue, 09 Dec 2003 12:05:12 +0100

Author: grumbel
Date: 2003-12-09 12:05:11 +0100 (Tue, 09 Dec 2003)
New Revision: 314

Added:
   trunk/src/input/axis_factory.cxx
   trunk/src/input/axis_factory.hxx
   trunk/src/input/button_factory.cxx
   trunk/src/input/button_factory.hxx
   trunk/src/input/input_axis.hxx
   trunk/src/input/input_axis_input_device.cxx
   trunk/src/input/input_axis_input_device.hxx
   trunk/src/input/input_button.hxx
   trunk/src/input/input_button_input_device.cxx
   trunk/src/input/input_button_input_device.hxx
Modified:
   trunk/src/input/Makefile.am
   trunk/src/input/input_manager.cxx
   trunk/src/input/input_manager.hxx
   trunk/src/input/input_manager_custom.cxx
   trunk/src/input/input_manager_custom.hxx
   trunk/src/system.cxx
Log:
- added framework for configurable controlls

Modified: trunk/src/input/Makefile.am
===================================================================
--- trunk/src/input/Makefile.am 2003-12-09 00:01:14 UTC (rev 313)
+++ trunk/src/input/Makefile.am 2003-12-09 11:05:11 UTC (rev 314)
@@ -13,6 +13,16 @@
   input_manager_joystick.hxx \
   input_manager_joystick.cxx \
   input_manager_keyboard.hxx \
-  input_manager_keyboard.cxx
+  input_manager_keyboard.cxx \
+  input_button.hxx \
+  input_axis.hxx \
+  input_button_input_device.hxx \
+  input_button_input_device.cxx \
+  input_axis_input_device.hxx \
+  input_axis_input_device.cxx \
+  button_factory.hxx \
+  button_factory.cxx \
+  axis_factory.hxx \
+  axis_factory.cxx
 
 # EOF #

Added: trunk/src/input/axis_factory.cxx
===================================================================
--- trunk/src/input/axis_factory.cxx    2003-12-09 00:01:14 UTC (rev 313)
+++ trunk/src/input/axis_factory.cxx    2003-12-09 11:05:11 UTC (rev 314)
@@ -0,0 +1,62 @@
+//  $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 <iostream>
+#include <ClanLib/Display/joystick.h>
+#include "input_axis_input_device.hxx"
+#include "axis_factory.hxx"
+
+InputAxis* 
+AxisFactory::create(SCM lst)
+{
+  while(gh_pair_p(lst))
+    {
+      SCM sym  = gh_caar(lst);
+      SCM data = gh_cdar(lst);
+      
+      if (gh_equal_p(sym, gh_symbol2scm("joystick-axis")))
+        {
+          return create_joystick_axis(data);
+        }
+      else
+        {
+          std::cout << "AxisFactory::create: parse error" << std::endl;
+        }
+
+      lst = gh_cdr(lst);
+    }
+  return 0;
+}
+
+InputAxis*
+AxisFactory::create_joystick_axis(SCM lst)
+{
+  int device_num = gh_scm2int(gh_car(lst));
+  int axis_num   = gh_scm2int(gh_cadr(lst));
+
+  if (device_num >= 0 && device_num < CL_Joystick::get_device_count())
+    return new InputAxisInputDevice(CL_Joystick::get_device(device_num), 
axis_num);
+  else
+    {
+      std::cout << "Error: AxisFactory::create_joystick_axis(SCM lst)" << 
std::endl;
+      return 0;
+    }
+}
+
+/* EOF */

Added: trunk/src/input/axis_factory.hxx
===================================================================
--- trunk/src/input/axis_factory.hxx    2003-12-09 00:01:14 UTC (rev 313)
+++ trunk/src/input/axis_factory.hxx    2003-12-09 11:05:11 UTC (rev 314)
@@ -0,0 +1,37 @@
+//  $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_AXIS_FACTORY_HXX
+#define HEADER_AXIS_FACTORY_HXX
+
+#include <guile/gh.h>
+#include "input_axis.hxx"
+
+/** */
+class AxisFactory
+{
+public:
+  static InputAxis* create(SCM lst);
+private:
+  static InputAxis* create_joystick_axis(SCM lst);
+};
+
+#endif
+
+/* EOF */

Added: trunk/src/input/button_factory.cxx
===================================================================
--- trunk/src/input/button_factory.cxx  2003-12-09 00:01:14 UTC (rev 313)
+++ trunk/src/input/button_factory.cxx  2003-12-09 11:05:11 UTC (rev 314)
@@ -0,0 +1,76 @@
+//  $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 <ClanLib/Display/joystick.h>
+#include <ClanLib/Display/keyboard.h>
+#include "../guile.hxx"
+#include "input_button.hxx"
+#include "input_button_input_device.hxx"
+#include "button_factory.hxx"
+
+InputButton* 
+ButtonFactory::create(SCM lst)
+{
+  while (!gh_null_p(lst))
+    {
+      SCM sym = gh_caar(lst);
+
+      if (gh_equal_p(sym, gh_symbol2scm("joystick-button")))
+        {
+          return create_joystick_button(gh_cdar(lst));
+        }
+      else if (gh_equal_p(sym, gh_symbol2scm("keyboard-button")))
+        {
+          return create_joystick_button(gh_cdar(lst));
+        }
+      else
+        {
+          std::cout << "ButtonFactory::create: parse error" << std::endl;
+        }
+      
+      lst = gh_cdr(lst);
+    }
+  return 0;
+}
+
+InputButton*
+ButtonFactory::create_joystick_button(SCM lst)
+{
+  int device_num = gh_scm2int(gh_car(lst));
+  int button_num = gh_scm2int(gh_cadr(lst));
+  
+  if (device_num >= 0 && device_num < CL_Joystick::get_device_count())
+    return new InputButtonInputDevice(CL_Joystick::get_device(device_num), 
button_num);
+  else
+    {
+      std::cout << "Error: ButtonFactory::create_joystick_button(SCM lst)" << 
std::endl;
+      return 0;
+    }
+}
+
+InputButton*
+ButtonFactory::create_keyboard_button(SCM lst)
+{
+  std::string key_str = Guile::symbol2string(gh_cadr(lst));
+  int key_num = CL_Keyboard::get_device().keyid_to_string(key_str);
+  // FIXME: No error checking
+  return new InputButtonInputDevice(CL_Keyboard::get_device(), key_num);
+}
+
+/* EOF */

Added: trunk/src/input/button_factory.hxx
===================================================================
--- trunk/src/input/button_factory.hxx  2003-12-09 00:01:14 UTC (rev 313)
+++ trunk/src/input/button_factory.hxx  2003-12-09 11:05:11 UTC (rev 314)
@@ -0,0 +1,44 @@
+//  $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_BUTTON_FACTORY_HXX
+#define HEADER_BUTTON_FACTORY_HXX
+
+#include <guile/gh.h>
+
+class InputButton;
+
+/** */
+class ButtonFactory
+{
+private:
+public:
+  static InputButton* create(SCM lst);
+
+private:
+  static InputButton* create_joystick_button(SCM lst);
+  static InputButton* create_keyboard_button(SCM lst);
+
+  ButtonFactory (const ButtonFactory&);
+  ButtonFactory& operator= (const ButtonFactory&);
+};
+
+#endif
+
+/* EOF */

Added: trunk/src/input/input_axis.hxx
===================================================================
--- trunk/src/input/input_axis.hxx      2003-12-09 00:01:14 UTC (rev 313)
+++ trunk/src/input/input_axis.hxx      2003-12-09 11:05:11 UTC (rev 314)
@@ -0,0 +1,40 @@
+//  $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_INPUT_AXIS_HXX
+#define HEADER_INPUT_AXIS_HXX
+
+#include <vector>
+#include <ClanLib/Signals/slot.h>
+#include <ClanLib/Signals/signal_v1.h>
+
+class InputAxis
+{
+protected:
+  std::vector<CL_Slot> slots;
+  CL_Signal_v1<float> move;  
+public:
+  InputAxis() {}
+  void update(float delta) {}
+  CL_Signal_v1<float>& on_move() { return move; }
+};
+
+#endif
+
+/* EOF */

Added: trunk/src/input/input_axis_input_device.cxx
===================================================================
--- trunk/src/input/input_axis_input_device.cxx 2003-12-09 00:01:14 UTC (rev 
313)
+++ trunk/src/input/input_axis_input_device.cxx 2003-12-09 11:05:11 UTC (rev 
314)
@@ -0,0 +1,38 @@
+//  $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 <ClanLib/Display/input_event.h>
+#include "input_axis_input_device.hxx"
+
+InputAxisInputDevice::InputAxisInputDevice(CL_InputDevice& dev, int num)
+  : dev(dev), axis_num(num)
+{
+  slots.push_back(dev.sig_axis_move().connect(this, 
&InputAxisInputDevice::on_axis_move));
+}
+
+void
+InputAxisInputDevice::on_axis_move(const CL_InputEvent& event)
+{
+  if (event.id == axis_num)
+    {
+      move(event.axis_pos);
+    }
+}
+
+/* EOF */

Added: trunk/src/input/input_axis_input_device.hxx
===================================================================
--- trunk/src/input/input_axis_input_device.hxx 2003-12-09 00:01:14 UTC (rev 
313)
+++ trunk/src/input/input_axis_input_device.hxx 2003-12-09 11:05:11 UTC (rev 
314)
@@ -0,0 +1,41 @@
+//  $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_INPUT_AXIS_INPUT_DEVICE_HXX
+#define HEADER_INPUT_AXIS_INPUT_DEVICE_HXX
+
+#include <ClanLib/Display/input_device.h>
+#include "input_axis.hxx"
+
+class InputAxisInputDevice : public InputAxis
+{
+private:
+  CL_InputDevice dev;
+  int axis_num;
+
+  void on_axis_move(const CL_InputEvent& event); 
+
+public:
+  InputAxisInputDevice(CL_InputDevice& dev, int num);
+  void update(float delta) {}
+};
+
+#endif
+
+/* EOF */

Added: trunk/src/input/input_button.hxx
===================================================================
--- trunk/src/input/input_button.hxx    2003-12-09 00:01:14 UTC (rev 313)
+++ trunk/src/input/input_button.hxx    2003-12-09 11:05:11 UTC (rev 314)
@@ -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_INPUT_BOTTON_HXX
+#define HEADER_INPUT_BOTTON_HXX
+
+#include <vector>
+#include <ClanLib/Signals/slot.h>
+#include <ClanLib/Signals/signal_v0.h>
+
+class InputButton
+{
+protected:
+  std::vector<CL_Slot> slots;
+  CL_Signal_v0 button_down;
+  CL_Signal_v0 button_up;
+
+public:
+  InputButton() {}
+  
+  void update(float delta) {}
+
+  CL_Signal_v0& on_key_down() { return button_down; }
+  CL_Signal_v0& on_key_up()   { return button_up; }
+};
+
+#endif
+
+/* EOF */

Added: trunk/src/input/input_button_input_device.cxx
===================================================================
--- trunk/src/input/input_button_input_device.cxx       2003-12-09 00:01:14 UTC 
(rev 313)
+++ trunk/src/input/input_button_input_device.cxx       2003-12-09 11:05:11 UTC 
(rev 314)
@@ -0,0 +1,48 @@
+//  $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 <ClanLib/Display/input_event.h>
+#include "input_button_input_device.hxx"
+
+InputButtonInputDevice::InputButtonInputDevice(CL_InputDevice& dev_, int 
keycode_)
+  : dev(dev_), keycode(keycode_)
+{
+  slots.push_back(dev.sig_key_down().connect(this, 
&InputButtonInputDevice::on_key_down));
+  slots.push_back(dev.sig_key_up().connect(this, 
&InputButtonInputDevice::on_key_up));
+}
+
+void
+InputButtonInputDevice::on_key_down(const CL_InputEvent& event)
+{
+  if (keycode == event.id)
+    {
+      button_down();
+    }
+}
+
+void
+InputButtonInputDevice::on_key_up(const CL_InputEvent& event)
+{
+  if (keycode == event.id)
+    {
+      button_up();
+    }
+}
+
+/* EOF */

Added: trunk/src/input/input_button_input_device.hxx
===================================================================
--- trunk/src/input/input_button_input_device.hxx       2003-12-09 00:01:14 UTC 
(rev 313)
+++ trunk/src/input/input_button_input_device.hxx       2003-12-09 11:05:11 UTC 
(rev 314)
@@ -0,0 +1,43 @@
+//  $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_INPUT_BOTTON_INPUT_DEVICE_HXX
+#define HEADER_INPUT_BOTTON_INPUT_DEVICE_HXX
+
+#include <ClanLib/Display/input_device.h>
+#include "input_button.hxx"
+
+class InputButtonInputDevice : public InputButton
+{
+private:
+  CL_InputDevice dev;
+  int keycode;
+
+  void on_key_down(const CL_InputEvent& event);
+  void on_key_up(const CL_InputEvent& event);
+
+public:
+  InputButtonInputDevice(CL_InputDevice& dev, int keycode);
+  
+  void update(float delta) {}
+};
+
+#endif
+
+/* EOF */

Modified: trunk/src/input/input_manager.cxx
===================================================================
--- trunk/src/input/input_manager.cxx   2003-12-09 00:01:14 UTC (rev 313)
+++ trunk/src/input/input_manager.cxx   2003-12-09 11:05:11 UTC (rev 314)
@@ -47,7 +47,16 @@
     }
   else
     {
-      impl = new InputManagerCustom();
+      impl = new InputManagerCustom
+        (gh_eval_str("'("
+                     "(primary-button   (joystick-button 1 1))"
+                     "(secondary-button (joystick-button 1 2))"
+                     "(use-button       (joystick-button 1 3))"
+                     "(menu-button      (joystick-button 1 4))"
+                     "(orientation-axis (joystick-axis 1 2))"
+                     "(accelerate-axis  (joystick-axis 1 3))"
+                     "(strafe-axis      (joystick-axis 1 0))"
+                     ")"));
     }
   /*
   else if (args->joystick != -1)

Modified: trunk/src/input/input_manager.hxx
===================================================================
--- trunk/src/input/input_manager.hxx   2003-12-09 00:01:14 UTC (rev 313)
+++ trunk/src/input/input_manager.hxx   2003-12-09 11:05:11 UTC (rev 314)
@@ -42,7 +42,7 @@
 private:
   InputManager(const InputManager&);
   InputManager& operator=(const InputManager&);
-};        
+};
 
 #endif
 

Modified: trunk/src/input/input_manager_custom.cxx
===================================================================
--- trunk/src/input/input_manager_custom.cxx    2003-12-09 00:01:14 UTC (rev 
313)
+++ trunk/src/input/input_manager_custom.cxx    2003-12-09 11:05:11 UTC (rev 
314)
@@ -22,69 +22,19 @@
 #include <ClanLib/Display/joystick.h>
 #include <ClanLib/Display/display_iostream.h>
 #include <ClanLib/Display/keys.h>
-#include "input_manager_custom.hxx"
 
-InputAxis::InputAxis(CL_InputDevice& dev, int num)
-  : dev(dev), axis_num(num)
-{
-  slots.push_back(dev.sig_axis_move().connect(this, &InputAxis::on_axis_move));
-}
+#include "../guile.hxx"
+#include "input_button_input_device.hxx"
+#include "input_axis_input_device.hxx"
+#include "button_factory.hxx"
+#include "axis_factory.hxx"
 
-void
-InputAxis::on_axis_move(const CL_InputEvent& event)
-{
-  if (event.id == axis_num)
-    {
-      move(event.axis_pos);
-    }
-}
+#include "input_manager_custom.hxx"
 
-InputButton::InputButton(CL_InputDevice& dev_, int keycode_)
-  : dev(dev_), keycode(keycode_)
+InputManagerCustom::InputManagerCustom(SCM lst)
 {
-  slots.push_back(dev.sig_key_down().connect(this, &InputButton::on_key_down));
-  slots.push_back(dev.sig_key_up().connect(this, &InputButton::on_key_up));
-}
+  init(lst);
 
-void
-InputButton::on_key_down(const CL_InputEvent& event)
-{
-  if (keycode == event.id)
-    {
-      button_down();
-    }
-}
-
-void
-InputButton::on_key_up(const CL_InputEvent& event)
-{
-  if (keycode == event.id)
-    {
-      button_up();
-    }
-}
-
-InputManagerCustom::InputManagerCustom()
-{
-  if (0)
-    {
-      primary_button   = new InputButton(CL_Keyboard::get_device(), CL_KEY_E);
-      secondary_button = new InputButton(CL_Keyboard::get_device(), CL_KEY_P);
-      use_button       = new InputButton(CL_Keyboard::get_device(), CL_KEY_K);
-      menu_button      = new InputButton(CL_Keyboard::get_device(), CL_KEY_A);
-    }
-  else
-    {
-      primary_button   = new InputButton(CL_Joystick::get_device(1), 9);
-      secondary_button = new InputButton(CL_Joystick::get_device(1), 8);
-      use_button       = new InputButton(CL_Joystick::get_device(1), 3);
-      menu_button      = new InputButton(CL_Joystick::get_device(1), 2);
-
-      orientation_axis = new InputAxis(CL_Joystick::get_device(1), 0);
-      accelerate_axis  = new InputAxis(CL_Joystick::get_device(1), 1);
-      strafe_axis      = new InputAxis(CL_Joystick::get_device(1), 2);
-    }
-
   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));
@@ -98,6 +48,51 @@
   slots.push_back(strafe_axis->on_move().connect(this, 
&InputManagerCustom::on_axis_move, STRAFE_AXIS));
 }
 
+void 
+InputManagerCustom::init(SCM lst)
+{
+  while (gh_pair_p(lst))
+    {
+      SCM sym  = gh_caar(lst);
+      SCM data = gh_cdar(lst);
+
+      if (gh_equal_p(sym, gh_symbol2scm("primary-button")))
+        {
+          primary_button = ButtonFactory::create(data);
+        }
+      else if (gh_equal_p(sym, gh_symbol2scm("secondary-button")))
+        {
+          secondary_button =  ButtonFactory::create(data);
+        }
+      else if (gh_equal_p(sym, gh_symbol2scm("use-button")))
+        {
+          use_button = ButtonFactory::create(data);
+        }
+      else if (gh_equal_p(sym, gh_symbol2scm("menu-button")))
+        {
+          menu_button = ButtonFactory::create(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;
+        }
+      
+      lst = gh_cdr(lst);
+    }
+}  
+
 void
 InputManagerCustom::on_axis_move(float pos, AxisName name)
 {

Modified: trunk/src/input/input_manager_custom.hxx
===================================================================
--- trunk/src/input/input_manager_custom.hxx    2003-12-09 00:01:14 UTC (rev 
313)
+++ trunk/src/input/input_manager_custom.hxx    2003-12-09 11:05:11 UTC (rev 
314)
@@ -20,52 +20,14 @@
 #ifndef HEADER_INPUT_MANAGER_CUSTOM_HXX
 #define HEADER_INPUT_MANAGER_CUSTOM_HXX
 
+#include <guile/gh.h>
 #include <ClanLib/Display/input_device.h>
 #include <ClanLib/Display/input_event.h>
 #include "input_event.hxx"
+#include "input_button.hxx"
+#include "input_axis.hxx"
 #include "input_manager_impl.hxx"
 
-class InputAxis
-{
-private:
-  CL_InputDevice dev;
-  int axis_num;
-
-  std::vector<CL_Slot> slots;
-  CL_Signal_v1<float> move;  
-public:
-  InputAxis() {}
-  InputAxis(CL_InputDevice& dev, int num);
-  
-  void on_axis_move(const CL_InputEvent& event); 
-
-  void update(float delta) {}
-
-  CL_Signal_v1<float>& on_move() { return move; }
-};
-
-class InputButton
-{
-private:
-  CL_InputDevice dev;
-  int keycode;
-
-  std::vector<CL_Slot> slots;
-  CL_Signal_v0 button_down;
-  CL_Signal_v0 button_up;
-public:
-  InputButton() {}
-  InputButton(CL_InputDevice& dev, int keycode);
-  
-  void on_key_down(const CL_InputEvent& event);
-  void on_key_up(const CL_InputEvent& event);
-
-  void update(float delta) {}
-
-  CL_Signal_v0& on_key_down() { return button_down; }
-  CL_Signal_v0& on_key_up()   { return button_up; }
-};
-
 /** */
 class InputManagerCustom : public InputManagerImpl
 {
@@ -82,7 +44,7 @@
   InputAxis* strafe_axis;
 
 public:
-  InputManagerCustom();
+  InputManagerCustom(SCM lst);
   
   void update(float delta);
 
@@ -90,6 +52,8 @@
   void on_button_down(ButtonName name);
   void on_axis_move(float pos, AxisName name);
 private:
+  void init(SCM lst);
+
   InputManagerCustom (const InputManagerCustom&);
   InputManagerCustom& operator= (const InputManagerCustom&);
 };

Modified: trunk/src/system.cxx
===================================================================
--- trunk/src/system.cxx        2003-12-09 00:01:14 UTC (rev 313)
+++ trunk/src/system.cxx        2003-12-09 11:05:11 UTC (rev 314)
@@ -204,7 +204,7 @@
 
   if (homedir) 
     {
-      return std::string(homedir) + "/.pingus/";
+      return std::string(homedir) + "/.feuerkraft/";
     }
   else
     {





reply via email to

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