|
From: knittl <kn...@us...> - 2009-08-03 08:40:40
|
Module: performous
Branch: master
Commit: 68ce777bcb78b9f11a672aab08fbbb92ac20d8e6
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Aug 1 18:10:18 2009 +0200
Tried to fix initialization of button states
---
game/joystick.cc | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index 21c3f9c..691042b 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -67,11 +67,19 @@ void input::init_devices() {
unsigned int num_buttons = SDL_JoystickNumButtons(input::sdl_devices[id]);
for( unsigned int i = 0 ; i < num_buttons ; ++i ) {
SDL_Event event;
- event.type = SDL_JOYBUTTONDOWN;
- event.jbutton.type = SDL_JOYBUTTONDOWN;
+ int state = SDL_JoystickGetButton(input::sdl_devices[id], i);
+ if( state == 0 ) {
+ event.type = SDL_JOYBUTTONDOWN;
+ event.jbutton.type = SDL_JOYBUTTONDOWN;
+ event.jbutton.state = SDL_PRESSED;
+ } else {
+ event.type = SDL_JOYBUTTONUP;
+ event.jbutton.type = SDL_JOYBUTTONUP;
+ event.jbutton.state = SDL_RELEASED;
+ }
+
event.jbutton.which = id;
event.jbutton.button = i;
- event.jbutton.state = SDL_PRESSED;
input::pushEvent(event);
}
}
|