winejoystick.drv: Test for new joysticks in intervals of 2 seconds.

Signed-off-by: Bruno Jesus <00cpxxx@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Bruno Jesus 2016-09-08 00:08:33 -03:00 committed by Alexandre Julliard
parent 4f114ad623
commit caaedf1cd6
1 changed files with 8 additions and 0 deletions

View File

@ -163,10 +163,17 @@ static int JSTCK_OpenDevice(WINE_JSTCK* jstick)
{
char buf[20];
int flags, fd, found_ix, i;
static DWORD last_attempt;
DWORD now;
if (jstick->dev > 0)
return jstick->dev;
now = GetTickCount();
if (now - last_attempt < 2000)
return -1;
last_attempt = now;
#ifdef HAVE_LINUX_22_JOYSTICK_API
flags = O_RDONLY | O_NONBLOCK;
#else
@ -189,6 +196,7 @@ static int JSTCK_OpenDevice(WINE_JSTCK* jstick)
{
TRACE("Found joystick[%d] at %s\n", jstick->joyIntf, buf);
jstick->dev = fd;
last_attempt = 0;
break;
}