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-28 17:44:32 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-05-28 17:44:32 +0400
commit8c4620f3d3d5cb533f3d1bf5c526c6ffc0355aaa (patch)
tree90b518f3231f1a1d426edae48f5039be0bac3025 /source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
parent6ac072e1bd05d41ae0c713b9ab0c5b83477c2919 (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_JoystickEvents.cpp')
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp37
1 files changed, 16 insertions, 21 deletions
diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
index 3ca8d7d2329..66193a2f4b9 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
+++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
@@ -42,7 +42,7 @@ void SCA_Joystick::OnAxisMotion(SDL_Event* sdl_event)
m_istrig_axis = 1;
}
-
+/* See notes below in the event loop */
void SCA_Joystick::OnHatMotion(SDL_Event* sdl_event)
{
if(sdl_event->jhat.hat >= JOYAXIS_MAX)
@@ -52,30 +52,20 @@ void SCA_Joystick::OnHatMotion(SDL_Event* sdl_event)
m_istrig_hat = 1;
}
+/* See notes below in the event loop */
void SCA_Joystick::OnButtonUp(SDL_Event* sdl_event)
{
m_istrig_button = 1;
-
- /* this is needed for the "all events" option
- * so we know if there are no buttons pressed */
- int i;
- for (i=0; i<m_buttonmax; i++) {
- if (SDL_JoystickGetButton(m_private->m_joystick, i)) {
- m_buttonnum = i;
- return;
- }
- }
- m_buttonnum = -2;
}
void SCA_Joystick::OnButtonDown(SDL_Event* sdl_event)
{
- if(sdl_event->jbutton.button <= m_buttonmax) /* unsigned int so always above 0 */
- {
- m_istrig_button = 1;
- m_buttonnum = sdl_event->jbutton.button;
- }
+ //if(sdl_event->jbutton.button > m_buttonmax) /* unsigned int so always above 0 */
+ // return;
+ // sdl_event->jbutton.button;
+
+ m_istrig_button = 1;
}
@@ -84,22 +74,27 @@ void SCA_Joystick::OnNothing(SDL_Event* sdl_event)
m_istrig_axis = m_istrig_button = m_istrig_hat = 0;
}
-/* only handle events for 1 joystick */
-
void SCA_Joystick::HandleEvents(void)
{
SDL_Event sdl_event;
int i;
- for (i=0; i<JOYINDEX_MAX; i++) {
+ for (i=0; i<m_joynum; i++) { /* could use JOYINDEX_MAX but no reason to */
if(SCA_Joystick::m_instance[i])
SCA_Joystick::m_instance[i]->OnNothing(&sdl_event);
}
- if(SDL_PollEvent(&sdl_event))
+ while(SDL_PollEvent(&sdl_event))
{
/* Note! m_instance[sdl_event.jaxis.which]
* will segfault if over JOYINDEX_MAX, not too nice but what are the chances? */
+
+ /* Note!, with buttons, this wont care which button is pressed,
+ * only to set 'm_istrig_button', actual pressed buttons are detected by SDL_JoystickGetButton */
+
+ /* Note!, if you manage to press and release a button within 1 logic tick
+ * it wont work as it should */
+
switch(sdl_event.type)
{
case SDL_JOYAXISMOTION: