Skip to content

Commit

Permalink
[Android] Poll joysticks every three seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
gabomdq committed Dec 12, 2013
1 parent 35ab76d commit 2159de6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/joystick/android/SDL_sysjoystick.c
Expand Up @@ -34,6 +34,7 @@
#include "SDL_joystick.h"
#include "SDL_hints.h"
#include "SDL_assert.h"
#include "SDL_timer.h"
#include "SDL_sysjoystick_c.h"
#include "../SDL_joystick_c.h"
#include "../../core/android/SDL_android.h"
Expand Down Expand Up @@ -339,10 +340,14 @@ int SDL_SYS_NumJoysticks()
void SDL_SYS_JoystickDetect()
{
/* Support for device connect/disconnect is API >= 16 only,
* so we have to poll ever few seconds.
* so we poll every three seconds
* Ref: http://developer.android.com/reference/android/hardware/input/InputManager.InputDeviceListener.html
*/
Android_JNI_PollInputDevices();
static Uint32 timeout = 0;
if (SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) {
timeout = SDL_GetTicks() + 3000;
Android_JNI_PollInputDevices();
}
}

SDL_bool SDL_SYS_JoystickNeedsPolling()
Expand Down

0 comments on commit 2159de6

Please sign in to comment.