src/joystick/android/SDL_sysjoystick.c
changeset 8060 d1948d163145
parent 8057 801d84e26f91
child 8074 acf83dce00d1
equal deleted inserted replaced
8059:e70f5749f692 8060:d1948d163145
    32 #endif
    32 #endif
    33 
    33 
    34 #include "SDL_joystick.h"
    34 #include "SDL_joystick.h"
    35 #include "SDL_hints.h"
    35 #include "SDL_hints.h"
    36 #include "SDL_assert.h"
    36 #include "SDL_assert.h"
       
    37 #include "SDL_timer.h"
    37 #include "SDL_sysjoystick_c.h"
    38 #include "SDL_sysjoystick_c.h"
    38 #include "../SDL_joystick_c.h"
    39 #include "../SDL_joystick_c.h"
    39 #include "../../core/android/SDL_android.h"
    40 #include "../../core/android/SDL_android.h"
    40 
    41 
    41 #include "android/keycodes.h"
    42 #include "android/keycodes.h"
   337 }
   338 }
   338 
   339 
   339 void SDL_SYS_JoystickDetect()
   340 void SDL_SYS_JoystickDetect()
   340 {
   341 {
   341     /* Support for device connect/disconnect is API >= 16 only,
   342     /* Support for device connect/disconnect is API >= 16 only,
   342      * so we have to poll ever few seconds.
   343      * so we poll every three seconds
   343      * Ref: http://developer.android.com/reference/android/hardware/input/InputManager.InputDeviceListener.html
   344      * Ref: http://developer.android.com/reference/android/hardware/input/InputManager.InputDeviceListener.html
   344      */
   345      */
   345     Android_JNI_PollInputDevices();   
   346     static Uint32 timeout = 0;
       
   347     if (SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) {
       
   348         timeout = SDL_GetTicks() + 3000;
       
   349         Android_JNI_PollInputDevices();
       
   350     }
   346 }
   351 }
   347 
   352 
   348 SDL_bool SDL_SYS_JoystickNeedsPolling()
   353 SDL_bool SDL_SYS_JoystickNeedsPolling()
   349 {
   354 {
   350     return SDL_TRUE;
   355     return SDL_TRUE;