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

dinput: Don't try to create non existing device.

parent 55b63fe0
...@@ -505,24 +505,31 @@ static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, RE ...@@ -505,24 +505,31 @@ static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, RE
find_joydevs(); find_joydevs();
if ((index = get_joystick_index(rguid)) < MAX_JOYDEV) { if ((index = get_joystick_index(rguid)) < MAX_JOYDEV &&
if ((riid == NULL) || have_joydevs && index < have_joydevs)
IsEqualGUID(&IID_IDirectInputDeviceA,riid) || {
IsEqualGUID(&IID_IDirectInputDevice2A,riid) || if ((riid == NULL) ||
IsEqualGUID(&IID_IDirectInputDevice7A,riid) || IsEqualGUID(&IID_IDirectInputDeviceA, riid) ||
IsEqualGUID(&IID_IDirectInputDevice8A,riid)) { IsEqualGUID(&IID_IDirectInputDevice2A, riid) ||
*pdev = (IDirectInputDeviceA*) alloc_device(rguid, &JoystickAvt, dinput, index); IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
TRACE("Creating a Joystick device (%p)\n", *pdev); IsEqualGUID(&IID_IDirectInputDevice8A, riid))
if (*pdev==0) { {
ERR("out of memory\n"); *pdev = (IDirectInputDeviceA*) alloc_device(rguid, &JoystickAvt, dinput, index);
return DIERR_OUTOFMEMORY; TRACE("Created a Joystick device (%p)\n", *pdev);
if (*pdev == NULL)
{
ERR("out of memory\n");
return DIERR_OUTOFMEMORY;
}
return DI_OK;
} }
return DI_OK;
} else { WARN("no interface\n");
return DIERR_NOINTERFACE; return DIERR_NOINTERFACE;
}
} }
WARN("invalid device GUID\n");
return DIERR_DEVICENOTREG; return DIERR_DEVICENOTREG;
} }
...@@ -533,24 +540,30 @@ static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, RE ...@@ -533,24 +540,30 @@ static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, RE
find_joydevs(); find_joydevs();
if ((index = get_joystick_index(rguid)) < MAX_JOYDEV) { if ((index = get_joystick_index(rguid)) < MAX_JOYDEV &&
if ((riid == NULL) || have_joydevs && index < have_joydevs)
IsEqualGUID(&IID_IDirectInputDeviceW,riid) || {
IsEqualGUID(&IID_IDirectInputDevice2W,riid) || if ((riid == NULL) ||
IsEqualGUID(&IID_IDirectInputDevice7W,riid) || IsEqualGUID(&IID_IDirectInputDeviceW, riid) ||
IsEqualGUID(&IID_IDirectInputDevice8W,riid)) { IsEqualGUID(&IID_IDirectInputDevice2W, riid) ||
*pdev = (IDirectInputDeviceW*) alloc_device(rguid, &JoystickWvt, dinput, index); IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
TRACE("Creating a Joystick device (%p)\n", *pdev); IsEqualGUID(&IID_IDirectInputDevice8W, riid))
if (*pdev==0) { {
ERR("out of memory\n"); *pdev = (IDirectInputDeviceW*) alloc_device(rguid, &JoystickWvt, dinput, index);
return DIERR_OUTOFMEMORY; TRACE("Created a Joystick device (%p)\n", *pdev);
if (*pdev == NULL)
{
ERR("out of memory\n");
return DIERR_OUTOFMEMORY;
}
return DI_OK;
} }
return DI_OK; WARN("no interface\n");
} else {
return DIERR_NOINTERFACE; return DIERR_NOINTERFACE;
}
} }
WARN("invalid device GUID\n");
return DIERR_DEVICENOTREG; return DIERR_DEVICENOTREG;
} }
......
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