mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-07-21 16:31:22 +00:00
Android: remove pollInputDevice() in favor of InputDeviceListener (#15659)
This commit is contained in:
@@ -535,11 +535,9 @@ done:
|
||||
SDL_UnlockJoysticks();
|
||||
}
|
||||
|
||||
static void ANDROID_JoystickDetect(void);
|
||||
|
||||
static bool ANDROID_JoystickInit(void)
|
||||
{
|
||||
ANDROID_JoystickDetect();
|
||||
Android_JNI_DetectDevices();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -550,16 +548,9 @@ static int ANDROID_JoystickGetCount(void)
|
||||
|
||||
static void ANDROID_JoystickDetect(void)
|
||||
{
|
||||
/* Support for device connect/disconnect is API >= 16 only,
|
||||
* so we poll every three seconds
|
||||
/* Support for device connect/disconnect is implemented using InputDeviceListener
|
||||
* Ref: http://developer.android.com/reference/android/hardware/input/InputManager.InputDeviceListener.html
|
||||
*/
|
||||
static Uint64 timeout = 0;
|
||||
Uint64 now = SDL_GetTicks();
|
||||
if (!timeout || now >= timeout) {
|
||||
timeout = now + 3000;
|
||||
Android_JNI_PollInputDevices();
|
||||
}
|
||||
}
|
||||
|
||||
static bool ANDROID_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name)
|
||||
@@ -596,16 +587,6 @@ static SDL_joylist_item *JoystickByDeviceId(int device_id)
|
||||
item = item->next;
|
||||
}
|
||||
|
||||
// Joystick not found, try adding it
|
||||
ANDROID_JoystickDetect();
|
||||
|
||||
while (item) {
|
||||
if (item->device_id == device_id) {
|
||||
return item;
|
||||
}
|
||||
item = item->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user