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/Joystick/SCA_JoystickEvents.cpp
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/Joystick/SCA_JoystickEvents.cpp')
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
index 8e190060e95..3ca8d7d2329 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
+++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
@@ -35,17 +35,20 @@
#ifndef DISABLE_SDL
void SCA_Joystick::OnAxisMotion(SDL_Event* sdl_event)
{
- pFillAxes();
- m_axisnum = sdl_event->jaxis.axis;
- m_axisvalue = sdl_event->jaxis.value;
+ if(sdl_event->jaxis.axis >= JOYAXIS_MAX)
+ return;
+
+ m_axis_array[sdl_event->jaxis.axis]= sdl_event->jaxis.value;
m_istrig_axis = 1;
}
void SCA_Joystick::OnHatMotion(SDL_Event* sdl_event)
{
- m_hatdir = sdl_event->jhat.value;
- m_hatnum = sdl_event->jhat.hat;
+ if(sdl_event->jhat.hat >= JOYAXIS_MAX)
+ return;
+
+ m_hat_array[sdl_event->jhat.hat]= sdl_event->jhat.value;
m_istrig_hat = 1;
}