dinput: Don't try to create non existing device (/dev/js*).

This commit is contained in:
Vitaliy Margolen 2007-08-20 22:06:54 -06:00 committed by Alexandre Julliard
parent 56f4262e94
commit e2e3d19351
1 changed files with 39 additions and 32 deletions

View File

@ -583,48 +583,55 @@ static unsigned short get_joystick_index(REFGUID guid)
static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev) static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
{ {
unsigned short index; unsigned short index;
if ((index = get_joystick_index(rguid)) < MAX_JOYSTICKS) { find_joystick_devices();
if ((riid == NULL) || *pdev = NULL;
IsEqualGUID(&IID_IDirectInputDeviceA,riid) ||
IsEqualGUID(&IID_IDirectInputDevice2A,riid) || if ((index = get_joystick_index(rguid)) < MAX_JOYSTICKS &&
IsEqualGUID(&IID_IDirectInputDevice7A,riid) || joystick_devices_count && index < joystick_devices_count)
IsEqualGUID(&IID_IDirectInputDevice8A,riid)) { {
return alloc_device(rguid, &JoystickAvt, dinput, pdev, index); if ((riid == NULL) ||
} else { IsEqualGUID(&IID_IDirectInputDeviceA, riid) ||
WARN("no interface\n"); IsEqualGUID(&IID_IDirectInputDevice2A, riid) ||
*pdev = 0; IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
return DIERR_NOINTERFACE; IsEqualGUID(&IID_IDirectInputDevice8A, riid))
{
return alloc_device(rguid, &JoystickAvt, dinput, pdev, index);
}
WARN("no interface\n");
return DIERR_NOINTERFACE;
} }
}
WARN("invalid device GUID\n"); WARN("invalid device GUID\n");
*pdev = 0; return DIERR_DEVICENOTREG;
return DIERR_DEVICENOTREG;
} }
static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev) static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
{ {
unsigned short index; unsigned short index;
if ((index = get_joystick_index(rguid)) < MAX_JOYSTICKS) { find_joystick_devices();
if ((riid == NULL) || *pdev = NULL;
IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
IsEqualGUID(&IID_IDirectInputDevice2W,riid) || if ((index = get_joystick_index(rguid)) < MAX_JOYSTICKS &&
IsEqualGUID(&IID_IDirectInputDevice7W,riid) || joystick_devices_count && index < joystick_devices_count)
IsEqualGUID(&IID_IDirectInputDevice8W,riid)) { {
return alloc_device(rguid, &JoystickWvt, dinput, (LPDIRECTINPUTDEVICEA *)pdev, index); if ((riid == NULL) ||
} else { IsEqualGUID(&IID_IDirectInputDeviceW, riid) ||
WARN("no interface\n"); IsEqualGUID(&IID_IDirectInputDevice2W, riid) ||
*pdev = 0; IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
return DIERR_NOINTERFACE; IsEqualGUID(&IID_IDirectInputDevice8W, riid))
{
return alloc_device(rguid, &JoystickWvt, dinput, (LPDIRECTINPUTDEVICEA *)pdev, index);
}
WARN("no interface\n");
return DIERR_NOINTERFACE;
} }
}
WARN("invalid device GUID\n"); WARN("invalid device GUID\n");
*pdev = 0; return DIERR_DEVICENOTREG;
return DIERR_DEVICENOTREG;
} }
#undef MAX_JOYSTICKS #undef MAX_JOYSTICKS