Commit c6784cda authored by Vitaliy Margolen's avatar Vitaliy Margolen Committed by Alexandre Julliard

dinput: Count should not be 0-based.

parent 35f3ff87
...@@ -138,6 +138,7 @@ static INT find_joystick_devices(void) ...@@ -138,6 +138,7 @@ static INT find_joystick_devices(void)
if (joystick_devices_count != -1) return joystick_devices_count; if (joystick_devices_count != -1) return joystick_devices_count;
joystick_devices_count = 0;
for (i = 0; i < MAX_JOYSTICKS; i++) for (i = 0; i < MAX_JOYSTICKS; i++)
{ {
CHAR device_name[MAX_PATH], *str; CHAR device_name[MAX_PATH], *str;
...@@ -154,7 +155,7 @@ static INT find_joystick_devices(void) ...@@ -154,7 +155,7 @@ static INT find_joystick_devices(void)
if (!(str = HeapAlloc(GetProcessHeap(), 0, len))) break; if (!(str = HeapAlloc(GetProcessHeap(), 0, len))) break;
memcpy(str, device_name, len); memcpy(str, device_name, len);
joystick_devices[++joystick_devices_count] = str; joystick_devices[joystick_devices_count++] = str;
} }
return joystick_devices_count; return joystick_devices_count;
...@@ -164,7 +165,7 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN ...@@ -164,7 +165,7 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
{ {
int fd = -1; int fd = -1;
if (id > find_joystick_devices()) return FALSE; if (id >= find_joystick_devices()) return FALSE;
if (dwFlags & DIEDFL_FORCEFEEDBACK) { if (dwFlags & DIEDFL_FORCEFEEDBACK) {
WARN("force feedback not supported\n"); WARN("force feedback not supported\n");
...@@ -215,7 +216,7 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN ...@@ -215,7 +216,7 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
char name[MAX_PATH]; char name[MAX_PATH];
char friendly[32]; char friendly[32];
if (id > find_joystick_devices()) return FALSE; if (id >= find_joystick_devices()) return FALSE;
if (dwFlags & DIEDFL_FORCEFEEDBACK) { if (dwFlags & DIEDFL_FORCEFEEDBACK) {
WARN("force feedback not supported\n"); WARN("force feedback not supported\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment