[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/input mouse_axis.cxx,1.1,1.2 mouse_ax
From: |
torangan |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/input mouse_axis.cxx,1.1,1.2 mouse_axis.hxx,1.2,1.3 |
Date: |
11 Jul 2002 11:23:47 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/input
In directory dark:/tmp/cvs-serv19398
Modified Files:
mouse_axis.cxx mouse_axis.hxx
Log Message:
corrected behaviour
Index: mouse_axis.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input/mouse_axis.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- mouse_axis.cxx 8 Jul 2002 14:47:35 -0000 1.1
+++ mouse_axis.cxx 11 Jul 2002 11:23:44 -0000 1.2
@@ -19,23 +19,32 @@
#include <ClanLib/Display/Input/input.h>
#include <ClanLib/Display/Input/inputdevice.h>
-#include <ClanLib/Display/Input/inputaxis.h>
+#include <ClanLib/Display/Input/inputcursor.h>
#include "mouse_axis.hxx"
namespace Input
{
- MouseAxis::MouseAxis(int axis_, float angle_) : axis(axis_), angle(angle_)
+ MouseAxis::MouseAxis(int axis_, float angle_) : axis(axis_), angle(angle_),
pos(0)
{
if (angle < 0)
angle = (static_cast<int>(angle) % 360) + 360;
else if (angle > 360)
angle = static_cast<int>(angle) % 360;
+
+ switch (axis)
+ {
+ case 0: old_pos = CL_Input::pointers[0]->get_cursor(0)->get_x();
+ break;
+ case 1: old_pos = CL_Input::pointers[0]->get_cursor(0)->get_y();
+ break;
+ default: old_pos = 0;
+ }
}
float
MouseAxis::get_pos ()
{
- return CL_Input::pointers[0]->get_axis(axis)->get_pos();
+ return pos;
}
float
@@ -47,6 +56,33 @@
void
MouseAxis::update(float)
{
+ switch (axis)
+ {
+ case 0: if (old_pos != CL_Input::pointers[0]->get_cursor(0)->get_x())
+ {
+ pos = CL_Input::pointers[0]->get_cursor(0)->get_x() -
old_pos;
+ old_pos = CL_Input::pointers[0]->get_cursor(0)->get_x();
+
+ if (pos < -1)
+ pos = -1;
+ else if (pos > 1)
+ pos = 1;
+ }
+ break;
+
+ case 1: if (old_pos != CL_Input::pointers[0]->get_cursor(0)->get_y())
+ {
+ pos = CL_Input::pointers[0]->get_cursor(0)->get_y() -
old_pos;
+ old_pos = CL_Input::pointers[0]->get_cursor(0)->get_y();
+
+ if (pos < -1)
+ pos = -1;
+ else if (pos > 1)
+ pos = 1;
+ }
+ break;
+ default: break; // do nothing
+ }
}
}
Index: mouse_axis.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input/mouse_axis.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- mouse_axis.hxx 9 Jul 2002 17:00:10 -0000 1.2
+++ mouse_axis.hxx 11 Jul 2002 11:23:45 -0000 1.3
@@ -26,17 +26,18 @@
{
class MouseAxis : public Axis {
- private:
- int axis;
- float angle;
-
+ private:
+ int axis;
+ float angle;
+ float pos;
+ float old_pos;
- public:
- MouseAxis(int axis_, float angle_);
+ public:
+ MouseAxis(int axis_, float angle_);
- virtual float get_pos ();
- virtual float get_angle ();
- virtual void update (float);
+ virtual float get_pos ();
+ virtual float get_angle ();
+ virtual void update (float);
};
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/input mouse_axis.cxx,1.1,1.2 mouse_axis.hxx,1.2,1.3,
torangan <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src pingus_error.cxx,1.1,1.2 pingus_error.hxx,1.2,1.3 pingus_main.cxx,1.5,1.6
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/input axis_scroller.cxx,NONE,1.1 axis_scroller.hxx,NONE,1.1 pointer_scroller.cxx,NONE,1.1 pointer_scroller.hxx,NONE,1.1 scroller.hxx,NONE,1.1
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src pingus_error.cxx,1.1,1.2 pingus_error.hxx,1.2,1.3 pingus_main.cxx,1.5,1.6
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/input axis_scroller.cxx,NONE,1.1 axis_scroller.hxx,NONE,1.1 pointer_scroller.cxx,NONE,1.1 pointer_scroller.hxx,NONE,1.1 scroller.hxx,NONE,1.1
- Index(es):