[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/input joystick_axis.cxx,1.3,1.4 joyst
From: |
torangan |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/input joystick_axis.cxx,1.3,1.4 joystick_button.cxx,1.1,1.2 mouse_button.cxx,1.1,1.2 |
Date: |
11 Jul 2002 15:24:37 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/input
In directory dark:/tmp/cvs-serv26730
Modified Files:
joystick_axis.cxx joystick_button.cxx mouse_button.cxx
Log Message:
added checks for correct parameters
Index: joystick_axis.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input/joystick_axis.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- joystick_axis.cxx 5 Jul 2002 11:02:47 -0000 1.3
+++ joystick_axis.cxx 11 Jul 2002 15:24:35 -0000 1.4
@@ -21,11 +21,18 @@
#include <ClanLib/Display/Input/inputdevice.h>
#include <ClanLib/Display/Input/inputaxis.h>
#include "joystick_axis.hxx"
+#include "../pingus_error.hxx"
namespace Input
{
JoystickAxis::JoystickAxis(int id_, int axis_, float angle_) : id(id_),
axis(axis_), angle(angle_)
{
+ if (static_cast<unsigned int> (id) >= CL_Input::joysticks.size())
+ throw PingusError("JoystickAxis: Invalid joystick id");
+
+ if (axis > CL_Input::joysticks[id]->get_num_axes())
+ throw PingusError("JoystickAxis: Invalid joystick axis id");
+
if (angle < 0)
angle = (static_cast<int>(angle) % 360) + 360;
else if (angle > 360)
Index: joystick_button.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input/joystick_button.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- joystick_button.cxx 4 Jul 2002 12:03:47 -0000 1.1
+++ joystick_button.cxx 11 Jul 2002 15:24:35 -0000 1.2
@@ -21,10 +21,18 @@
#include <ClanLib/Display/Input/inputdevice.h>
#include <ClanLib/Display/Input/inputbutton.h>
#include "joystick_button.hxx"
+#include "../pingus_error.hxx"
namespace Input {
- JoystickButton::JoystickButton(int id_, int button_) : id(id_),
button(button_) { }
+ JoystickButton::JoystickButton(int id_, int button_) : id(id_),
button(button_)
+ {
+ if (static_cast<unsigned int>(id) >= CL_Input::joysticks.size())
+ throw PingusError("JoystickButton: Invalid joystick id");
+
+ if (button > CL_Input::joysticks[id]->get_num_buttons())
+ throw PingusError("JoystickButton: Invalid joystick button id");
+ }
void
JoystickButton::update(float)
Index: mouse_button.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input/mouse_button.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- mouse_button.cxx 4 Jul 2002 11:54:57 -0000 1.1
+++ mouse_button.cxx 11 Jul 2002 15:24:35 -0000 1.2
@@ -21,10 +21,15 @@
#include <ClanLib/Display/Input/inputdevice.h>
#include <ClanLib/Display/Input/inputbutton.h>
#include "mouse_button.hxx"
+#include "../pingus_error.hxx"
namespace Input {
- MouseButton::MouseButton(int button_) : button(button_) { }
+ MouseButton::MouseButton(int button_) : button(button_)
+ {
+ if (button > CL_Input::pointers[0]->get_num_buttons())
+ throw PingusError("MouseButton: Invalid button id");
+ }
void
MouseButton::update(float)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/input joystick_axis.cxx,1.3,1.4 joystick_button.cxx,1.1,1.2 mouse_button.cxx,1.1,1.2,
torangan <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/input scroll_event.hxx,NONE,1.1 event.hxx,1.2,1.3 Makefile.am,1.15,1.16
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/input button_factory.cxx,1.3,1.4 button_factory.hxx,1.2,1.3
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/input scroll_event.hxx,NONE,1.1 event.hxx,1.2,1.3 Makefile.am,1.15,1.16
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/input button_factory.cxx,1.3,1.4 button_factory.hxx,1.2,1.3
- Index(es):