[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Feuerkraft-CVS] rev 330 - trunk/src/input
From: |
Ingo Ruhnke |
Subject: |
[Feuerkraft-CVS] rev 330 - trunk/src/input |
Date: |
Sat, 10 Jan 2004 16:50:05 +0100 |
Author: grumbel
Date: 2004-01-10 16:50:05 +0100 (Sat, 10 Jan 2004)
New Revision: 330
Added:
trunk/src/input/axis_button.cxx
trunk/src/input/axis_button.hxx
Log:
- added axisbutton
Added: trunk/src/input/axis_button.cxx
===================================================================
--- trunk/src/input/axis_button.cxx 2004-01-10 15:48:59 UTC (rev 329)
+++ trunk/src/input/axis_button.cxx 2004-01-10 15:50:05 UTC (rev 330)
@@ -0,0 +1,71 @@
+// $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 "input_axis.hxx"
+#include "axis_button.hxx"
+
+AxisButton::AxisButton(InputAxis* axis, bool top)
+ : axis(axis),
+ down(false),
+ top(top)
+{
+ on_axis_move_slot = axis->on_move().connect(this, &AxisButton::on_axis_move);
+}
+
+AxisButton::~AxisButton()
+{
+}
+
+void
+AxisButton::update(float delta)
+{
+}
+
+void
+AxisButton::on_axis_move(float pos)
+{
+ if (top)
+ {
+ if (down && pos < 0.5f)
+ {
+ down = false;
+ on_key_up();
+ }
+ else if (!down && pos > 0.5f)
+ {
+ down = true;
+ on_key_down();
+ }
+ }
+ else
+ {
+ if (down && pos > -0.5f)
+ {
+ down = false;
+ on_key_up();
+ }
+ else if (!down && pos < -0.5f)
+ {
+ down = true;
+ on_key_down();
+ }
+ }
+}
+
+/* EOF */
Added: trunk/src/input/axis_button.hxx
===================================================================
--- trunk/src/input/axis_button.hxx 2004-01-10 15:48:59 UTC (rev 329)
+++ trunk/src/input/axis_button.hxx 2004-01-10 15:50:05 UTC (rev 330)
@@ -0,0 +1,53 @@
+// $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_BUTTON_HXX
+#define HEADER_AXIS_BUTTON_HXX
+
+#include "input_button.hxx"
+
+class InputAxis;
+
+/** */
+class AxisButton : public InputButton
+{
+private:
+ CL_Slot on_axis_move_slot;
+ InputAxis* axis;
+ bool down;
+
+ /** true if the range 0..1 should be used to trigger, false if -1..0
+ should be used */
+ bool top;
+public:
+ AxisButton(InputAxis* axis, bool top);
+ ~AxisButton();
+
+ void update(float delta);
+
+private:
+ void on_axis_move(float pos);
+
+ AxisButton (const AxisButton&);
+ AxisButton& operator= (const AxisButton&);
+};
+
+#endif
+
+/* EOF */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Feuerkraft-CVS] rev 330 - trunk/src/input,
Ingo Ruhnke <=