diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-05-28 17:44:32 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-05-28 17:44:32 +0400 |
commit | 8c4620f3d3d5cb533f3d1bf5c526c6ffc0355aaa (patch) | |
tree | 90b518f3231f1a1d426edae48f5039be0bac3025 /source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp | |
parent | 6ac072e1bd05d41ae0c713b9ab0c5b83477c2919 (diff) |
[#18840] Joystick sensor lag
if(SDL_PollEvent(&sdl_event)) // if -> while fixed it
removed 'm_buttonnum' was misleading, wasn't used as you expect.
Added gravity to variable to world to be used by collada.
Diffstat (limited to 'source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp')
-rw-r--r-- | source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp index 7c4ebb4c330..d83179d4f80 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp @@ -38,7 +38,6 @@ SCA_Joystick::SCA_Joystick(short int index) : m_joyindex(index), m_prec(3200), - m_buttonnum(-2), m_axismax(-1), m_buttonmax(-1), m_hatmax(-1), @@ -68,6 +67,7 @@ SCA_Joystick::~SCA_Joystick() } SCA_Joystick *SCA_Joystick::m_instance[JOYINDEX_MAX]; +int SCA_Joystick::m_joynum = 0; int SCA_Joystick::m_refCount = 0; SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex ) @@ -88,6 +88,9 @@ SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex ) echo("Error-Initializing-SDL: " << SDL_GetError()); return NULL; } + + m_joynum = SDL_NumJoysticks(); + for (i=0; i<JOYINDEX_MAX; i++) { m_instance[i] = new SCA_Joystick(i); m_instance[i]->CreateJoystickDevice(); @@ -155,12 +158,13 @@ bool SCA_Joystick::aAxisIsPositive(int axis_single) bool SCA_Joystick::aAnyButtonPressIsPositive(void) { - return (m_buttonnum==-2) ? false : true; -} - -bool SCA_Joystick::aAnyButtonReleaseIsPositive(void) -{ - return (m_buttonnum==-2) ? true : false; + /* this is needed for the "all events" option + * so we know if there are no buttons pressed */ + for (int i=0; i<m_buttonmax; i++) + if (SDL_JoystickGetButton(m_private->m_joystick, i)) + return true; + + return false; } bool SCA_Joystick::aButtonPressIsPositive(int button) @@ -217,7 +221,7 @@ bool SCA_Joystick::CreateJoystickDevice(void) return false; #else if(m_isinit == false){ - if (m_joyindex>=SDL_NumJoysticks()) { + if (m_joyindex>=m_joynum) { // don't print a message, because this is done anyway //echo("Joystick-Error: " << SDL_NumJoysticks() << " avaiable joystick(s)"); |