Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-05-25 10:24:23 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-05-25 10:24:23 +0400
commit2fa8504dd104e0bde32ee487f97fbce4fd6d7104 (patch)
treede257b1dc9329c0819a201f0140c8b0be9487969 /source/gameengine/GameLogic/SCA_JoystickSensor.h
parent2a9d9605d08e2521b2c6aadafe8294e1eed78fc3 (diff)
BGE Joystick Hat Bugfix
bug reported by blenderage on blenderartist (found other bugs too). - "All Hat Events" didnt work. - Multiple hats didnt work - use a menu with direction names rather then have the user guess. disallow zero as a direction. - Allow up to 4 hats (was 2). - Python api was clamping the axis to 2, maximum is currently JOYAXIS_MAX - 16 - New python attributes hatValues and hatSingle, match axis functions. - Use SDL Axis events to fill in the axis and hat array rather then filling in every axis with SDL_JoystickGetAxis for each axis event.
Diffstat (limited to 'source/gameengine/GameLogic/SCA_JoystickSensor.h')
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h
index e8185d1911e..e6a1d2eef32 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.h
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h
@@ -30,6 +30,7 @@
#define __JOYSENSOR_H
#include "SCA_ISensor.h"
+#include "./Joystick/SCA_JoystickDefines.h"
class SCA_JoystickSensor :public SCA_ISensor
{
@@ -37,7 +38,7 @@ class SCA_JoystickSensor :public SCA_ISensor
class SCA_JoystickManager* m_pJoystickMgr;
/**
- * Axis 1-or-2, MUST be followed by m_axisf
+ * Axis 1-JOYAXIS_MAX, MUST be followed by m_axisf
*/
int m_axis;
/**
@@ -53,11 +54,11 @@ class SCA_JoystickSensor :public SCA_ISensor
*/
int m_buttonf;
/**
- * The actual hat. MUST be followed by m_hatf
+ * The actual hat 1-JOYHAT_MAX. MUST be followed by m_hatf
*/
int m_hat;
/**
- * Flag to find direction 0-11, MUST be an int
+ * Flag to find direction 1-12, MUST be an int
*/
int m_hatf;
/**
@@ -152,6 +153,8 @@ public:
static PyObject* pyattr_get_axis_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_axis_single(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_hat_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static PyObject* pyattr_get_hat_single(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_num_axis(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_num_buttons(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_num_hats(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
@@ -164,8 +167,8 @@ public:
SCA_JoystickSensor* sensor = reinterpret_cast<SCA_JoystickSensor*>(self);
if (sensor->m_axis < 1)
sensor->m_axis = 1;
- else if (sensor->m_axis > 2)
- sensor->m_axis = 2;
+ else if (sensor->m_axis > JOYAXIS_MAX)
+ sensor->m_axis = JOYAXIS_MAX;
return 0;
}
static int CheckHat(void *self, const PyAttributeDef*)
@@ -173,8 +176,8 @@ public:
SCA_JoystickSensor* sensor = reinterpret_cast<SCA_JoystickSensor*>(self);
if (sensor->m_hat < 1)
sensor->m_hat = 1;
- else if (sensor->m_hat > 2)
- sensor->m_hat = 2;
+ else if (sensor->m_hat > JOYHAT_MAX)
+ sensor->m_hat = JOYHAT_MAX;
return 0;
}