Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/dinput_main.c | 32 +++++++++++++--------------- dlls/dinput/dinput_private.h | 2 +- dlls/dinput/joystick_linux.c | 34 ++++-------------------------- dlls/dinput/joystick_linuxinput.c | 34 ++++-------------------------- dlls/dinput/joystick_osx.c | 33 ++++------------------------- dlls/dinput/keyboard.c | 35 ++++--------------------------- dlls/dinput/mouse.c | 34 ++++-------------------------- 7 files changed, 36 insertions(+), 168 deletions(-)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 85de9f79b81..3d6d5732cfb 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -644,9 +644,15 @@ static HRESULT WINAPI IDirectInput2WImpl_FindDevice(LPDIRECTINPUT7W iface, REFGU return DI_OK; }
-static HRESULT create_device(IDirectInputImpl *This, REFGUID rguid, REFIID riid, LPVOID *pvOut, BOOL unicode) +static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx( IDirectInput7W *iface, REFGUID rguid, REFIID riid, + LPVOID *pvOut, LPUNKNOWN lpUnknownOuter ) { + IDirectInputDevice8W *device; + IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); unsigned int i; + HRESULT hr; + + TRACE( "(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid( rguid ), debugstr_guid( riid ), pvOut, lpUnknownOuter );
if (pvOut) *pvOut = NULL; @@ -660,31 +666,23 @@ static HRESULT create_device(IDirectInputImpl *This, REFGUID rguid, REFIID riid, /* Loop on all the devices to see if anyone matches the given GUID */ for (i = 0; i < ARRAY_SIZE(dinput_devices); i++) { - HRESULT ret; - if (!dinput_devices[i]->create_device) continue; - if ((ret = dinput_devices[i]->create_device(This, rguid, riid, pvOut, unicode)) == DI_OK) - return DI_OK; + if (SUCCEEDED(hr = dinput_devices[i]->create_device( This, rguid, &device ))) + { + hr = IDirectInputDevice8_QueryInterface( device, riid, pvOut ); + IDirectInputDevice8_Release( device ); + return hr; + } }
WARN("invalid device GUID %s\n", debugstr_guid(rguid)); return DIERR_DEVICENOTREG; }
-static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, REFGUID rguid, - REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter) -{ - IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); - - TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter); - - return create_device(This, rguid, riid, pvOut, TRUE); -} - static HRESULT WINAPI IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7W iface, REFGUID rguid, LPDIRECTINPUTDEVICEW* pdev, LPUNKNOWN punk) { - return IDirectInput7_CreateDeviceEx( iface, rguid, NULL, (LPVOID *)pdev, punk ); + return IDirectInput7_CreateDeviceEx( iface, rguid, &IID_IDirectInputDeviceW, (LPVOID *)pdev, punk ); }
/******************************************************************************* @@ -713,7 +711,7 @@ static HRESULT WINAPI IDirectInput8WImpl_CreateDevice(LPDIRECTINPUT8W iface, REF LPDIRECTINPUTDEVICE8W* pdev, LPUNKNOWN punk) { IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInput7_CreateDeviceEx( &This->IDirectInput7W_iface, rguid, NULL, (LPVOID *)pdev, punk ); + return IDirectInput7_CreateDeviceEx( &This->IDirectInput7W_iface, rguid, &IID_IDirectInputDevice8W, (LPVOID *)pdev, punk ); }
static HRESULT WINAPI IDirectInput8WImpl_EnumDevices(LPDIRECTINPUT8W iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, diff --git a/dlls/dinput/dinput_private.h b/dlls/dinput/dinput_private.h index 256c30d3dc0..404eaad1d52 100644 --- a/dlls/dinput/dinput_private.h +++ b/dlls/dinput/dinput_private.h @@ -57,7 +57,7 @@ struct dinput_device { const char *name; HRESULT (*enum_deviceA)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id); HRESULT (*enum_deviceW)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id); - HRESULT (*create_device)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode); + HRESULT (*create_device)(IDirectInputImpl *dinput, REFGUID rguid, IDirectInputDevice8W **out); };
struct DevicePlayer { diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 0c1560617dd..32e355c47e8 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -587,13 +587,13 @@ static unsigned short get_joystick_index(REFGUID guid) return MAX_JOYSTICKS; }
-static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode) +static HRESULT joydev_create_device( IDirectInputImpl *dinput, REFGUID rguid, IDirectInputDevice8W **out ) { unsigned short index;
- TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode); + TRACE( "%p %s %p\n", dinput, debugstr_guid( rguid ), out ); find_joystick_devices(); - *pdev = NULL; + *out = NULL;
if ((index = get_joystick_index(rguid)) < MAX_JOYSTICKS && joystick_devices_count && index < joystick_devices_count) @@ -601,37 +601,11 @@ static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REF JoystickImpl *This; HRESULT hr;
- if (riid == NULL) - ;/* nothing */ - else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) || - IsEqualGUID(&IID_IDirectInputDevice2A, riid) || - IsEqualGUID(&IID_IDirectInputDevice7A, riid) || - IsEqualGUID(&IID_IDirectInputDevice8A, riid)) - { - unicode = 0; - } - else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) || - IsEqualGUID(&IID_IDirectInputDevice2W, riid) || - IsEqualGUID(&IID_IDirectInputDevice7W, riid) || - IsEqualGUID(&IID_IDirectInputDevice8W, riid)) - { - unicode = 1; - } - else - { - WARN("no interface\n"); - return DIERR_NOINTERFACE; - } - if (FAILED(hr = alloc_device( rguid, dinput, &This, index ))) return hr;
TRACE( "Created a Joystick device (%p)\n", This );
- if (unicode) - *pdev = &This->generic.base.IDirectInputDevice8W_iface; - else - *pdev = &This->generic.base.IDirectInputDevice8A_iface; - + *out = &This->generic.base.IDirectInputDevice8W_iface; return hr; }
diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 3bc6114322f..0b7a4e63c8f 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -612,13 +612,13 @@ static unsigned short get_joystick_index(REFGUID guid) return MAX_JOYDEV; }
-static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode) +static HRESULT joydev_create_device( IDirectInputImpl *dinput, REFGUID rguid, IDirectInputDevice8W **out ) { unsigned short index;
- TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode); + TRACE( "%p %s %p\n", dinput, debugstr_guid( rguid ), out ); find_joydevs(); - *pdev = NULL; + *out = NULL;
if ((index = get_joystick_index(rguid)) < MAX_JOYDEV && have_joydevs && index < have_joydevs) @@ -626,37 +626,11 @@ static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REF JoystickImpl *This; HRESULT hr;
- if (riid == NULL) - ;/* nothing */ - else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) || - IsEqualGUID(&IID_IDirectInputDevice2A, riid) || - IsEqualGUID(&IID_IDirectInputDevice7A, riid) || - IsEqualGUID(&IID_IDirectInputDevice8A, riid)) - { - unicode = 0; - } - else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) || - IsEqualGUID(&IID_IDirectInputDevice2W, riid) || - IsEqualGUID(&IID_IDirectInputDevice7W, riid) || - IsEqualGUID(&IID_IDirectInputDevice8W, riid)) - { - unicode = 1; - } - else - { - WARN("no interface\n"); - return DIERR_NOINTERFACE; - } - if (FAILED(hr = alloc_device( rguid, dinput, &This, index ))) return hr;
TRACE( "Created a Joystick device (%p)\n", This );
- if (unicode) - *pdev = &This->generic.base.IDirectInputDevice8W_iface; - else - *pdev = &This->generic.base.IDirectInputDevice8A_iface; - + *out = &This->generic.base.IDirectInputDevice8W_iface; return DI_OK; }
diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c index e29a7bd9726..38a708d4cae 100644 --- a/dlls/dinput/joystick_osx.c +++ b/dlls/dinput/joystick_osx.c @@ -1323,13 +1323,13 @@ static unsigned short get_joystick_index(REFGUID guid) return 0xffff; }
-static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode) +static HRESULT joydev_create_device( IDirectInputImpl *dinput, REFGUID rguid, IDirectInputDevice8W **out ) { unsigned short index; int joystick_devices_count;
- TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode); - *pdev = NULL; + TRACE( "%p %s %p\n", dinput, debugstr_guid( rguid ), out ); + *out = NULL;
if ((joystick_devices_count = find_joystick_devices()) == 0) return DIERR_DEVICENOTREG; @@ -1340,36 +1340,11 @@ static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REF JoystickImpl *This; HRESULT hr;
- if (riid == NULL) - ;/* nothing */ - else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) || - IsEqualGUID(&IID_IDirectInputDevice2A, riid) || - IsEqualGUID(&IID_IDirectInputDevice7A, riid) || - IsEqualGUID(&IID_IDirectInputDevice8A, riid)) - { - unicode = 0; - } - else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) || - IsEqualGUID(&IID_IDirectInputDevice2W, riid) || - IsEqualGUID(&IID_IDirectInputDevice7W, riid) || - IsEqualGUID(&IID_IDirectInputDevice8W, riid)) - { - unicode = 1; - } - else - { - WARN("no interface\n"); - return DIERR_NOINTERFACE; - } - if (FAILED(hr = alloc_device( rguid, dinput, &This, index ))) return hr;
TRACE( "Created a Joystick device (%p)\n", This );
- if (unicode) - *pdev = &This->generic.base.IDirectInputDevice8W_iface; - else - *pdev = &This->generic.base.IDirectInputDevice8A_iface; + *out = &This->generic.base.IDirectInputDevice8W_iface; return hr; }
diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index c64051e8663..0e371e31b99 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -283,48 +283,21 @@ failed: return DIERR_OUTOFMEMORY; }
- -static HRESULT keyboarddev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode) +static HRESULT keyboarddev_create_device( IDirectInputImpl *dinput, REFGUID rguid, IDirectInputDevice8W **out ) { - TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode); - *pdev = NULL; + TRACE( "%p %s %p\n", dinput, debugstr_guid( rguid ), out ); + *out = NULL;
if (IsEqualGUID(&GUID_SysKeyboard, rguid)) /* Wine Keyboard */ { SysKeyboardImpl *This; HRESULT hr;
- if (riid == NULL) - ;/* nothing */ - else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) || - IsEqualGUID(&IID_IDirectInputDevice2A, riid) || - IsEqualGUID(&IID_IDirectInputDevice7A, riid) || - IsEqualGUID(&IID_IDirectInputDevice8A, riid)) - { - unicode = 0; - } - else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) || - IsEqualGUID(&IID_IDirectInputDevice2W, riid) || - IsEqualGUID(&IID_IDirectInputDevice7W, riid) || - IsEqualGUID(&IID_IDirectInputDevice8W, riid)) - { - unicode = 1; - } - else - { - WARN("no interface\n"); - return DIERR_NOINTERFACE; - } - if (FAILED(hr = alloc_device( rguid, dinput, &This ))) return hr;
TRACE( "Created a Keyboard device (%p)\n", This );
- if (unicode) - *pdev = &This->base.IDirectInputDevice8W_iface; - else - *pdev = &This->base.IDirectInputDevice8A_iface; - + *out = &This->base.IDirectInputDevice8W_iface; return DI_OK; }
diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index ef503526c35..09cfe945a50 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -240,47 +240,21 @@ failed: return DIERR_OUTOFMEMORY; }
-static HRESULT mousedev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode) +static HRESULT mousedev_create_device( IDirectInputImpl *dinput, REFGUID rguid, IDirectInputDevice8W **out ) { - TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode); - *pdev = NULL; + TRACE( "%p %s %p\n", dinput, debugstr_guid( rguid ), out ); + *out = NULL;
if (IsEqualGUID(&GUID_SysMouse, rguid)) /* Wine Mouse */ { SysMouseImpl *This; HRESULT hr;
- if (riid == NULL) - ;/* nothing */ - else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) || - IsEqualGUID(&IID_IDirectInputDevice2A, riid) || - IsEqualGUID(&IID_IDirectInputDevice7A, riid) || - IsEqualGUID(&IID_IDirectInputDevice8A, riid)) - { - unicode = 0; - } - else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) || - IsEqualGUID(&IID_IDirectInputDevice2W, riid) || - IsEqualGUID(&IID_IDirectInputDevice7W, riid) || - IsEqualGUID(&IID_IDirectInputDevice8W, riid)) - { - unicode = 1; - } - else - { - WARN("no interface\n"); - return DIERR_NOINTERFACE; - } - if (FAILED(hr = alloc_device( rguid, dinput, &This ))) return hr;
TRACE( "Created a Mouse device (%p)\n", This );
- if (unicode) - *pdev = &This->base.IDirectInputDevice8W_iface; - else - *pdev = &This->base.IDirectInputDevice8A_iface; - + *out = &This->base.IDirectInputDevice8W_iface; return DI_OK; }
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/dinput_main.c | 14 ++++---- dlls/dinput/dinput_private.h | 3 +- dlls/dinput/joystick_linux.c | 58 ++----------------------------- dlls/dinput/joystick_linuxinput.c | 54 ++-------------------------- dlls/dinput/joystick_osx.c | 52 ++------------------------- dlls/dinput/keyboard.c | 50 ++------------------------ dlls/dinput/mouse.c | 50 ++------------------------ 7 files changed, 18 insertions(+), 263 deletions(-)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 3d6d5732cfb..62e70e0535c 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -382,11 +382,11 @@ static HRESULT WINAPI IDirectInputWImpl_EnumDevices( return DIERR_NOTINITIALIZED;
for (i = 0; i < ARRAY_SIZE(dinput_devices); i++) { - if (!dinput_devices[i]->enum_deviceW) continue; + if (!dinput_devices[i]->enum_device) continue; for (j = 0, r = S_OK; SUCCEEDED(r); j++) { devInstance.dwSize = sizeof(devInstance); TRACE(" - checking device %u ('%s')\n", i, dinput_devices[i]->name); - r = dinput_devices[i]->enum_deviceW(dwDevType, dwFlags, &devInstance, This->dwVersion, j); + r = dinput_devices[i]->enum_device(dwDevType, dwFlags, &devInstance, This->dwVersion, j); if (r == S_OK) if (enum_callback_wrapper(lpCallback, &devInstance, pvRef) == DIENUM_STOP) return S_OK; @@ -825,14 +825,14 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics( { HRESULT enumSuccess;
- if (!dinput_devices[i]->enum_deviceW) continue; + if (!dinput_devices[i]->enum_device) continue;
for (j = 0, enumSuccess = S_OK; SUCCEEDED(enumSuccess); j++) { TRACE(" - checking device %u ('%s')\n", i, dinput_devices[i]->name);
/* Default behavior is to enumerate attached game controllers */ - enumSuccess = dinput_devices[i]->enum_deviceW(DI8DEVCLASS_GAMECTRL, DIEDFL_ATTACHEDONLY | dwFlags, &didevi, This->dwVersion, j); + enumSuccess = dinput_devices[i]->enum_device(DI8DEVCLASS_GAMECTRL, DIEDFL_ATTACHEDONLY | dwFlags, &didevi, This->dwVersion, j); if (enumSuccess == S_OK && should_enumerate_device(ptszUserName, dwFlags, &This->device_players, &didevi.guidInstance)) { @@ -998,13 +998,13 @@ static HRESULT WINAPI JoyConfig8Impl_GetConfig(IDirectInputJoyConfig8 *iface, UI /* Enumerate all joysticks in order */ for (i = 0; i < ARRAY_SIZE(dinput_devices); i++) { - if (!dinput_devices[i]->enum_deviceA) continue; + if (!dinput_devices[i]->enum_device) continue;
for (j = 0, r = S_OK; SUCCEEDED(r); j++) { - DIDEVICEINSTANCEA dev; + DIDEVICEINSTANCEW dev; dev.dwSize = sizeof(dev); - if ((r = dinput_devices[i]->enum_deviceA(DI8DEVCLASS_GAMECTRL, 0, &dev, di->dwVersion, j)) == S_OK) + if ((r = dinput_devices[i]->enum_device(DI8DEVCLASS_GAMECTRL, 0, &dev, di->dwVersion, j)) == S_OK) { /* Only take into account the chosen id */ if (found == id) diff --git a/dlls/dinput/dinput_private.h b/dlls/dinput/dinput_private.h index 404eaad1d52..7e0f56c68df 100644 --- a/dlls/dinput/dinput_private.h +++ b/dlls/dinput/dinput_private.h @@ -55,8 +55,7 @@ extern const IDirectInput8AVtbl dinput8_a_vtbl DECLSPEC_HIDDEN; /* Function called by all devices that Wine supports */ struct dinput_device { const char *name; - HRESULT (*enum_deviceA)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id); - HRESULT (*enum_deviceW)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id); + HRESULT (*enum_device)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id); HRESULT (*create_device)(IDirectInputImpl *dinput, REFGUID rguid, IDirectInputDevice8W **out); };
diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 32e355c47e8..5a88e643e07 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -369,59 +369,7 @@ static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD ver lpddi->guidFFDriver = GUID_NULL; }
-static void fill_joystick_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version, int id) -{ - DIDEVICEINSTANCEW lpddiW; - DWORD dwSize = lpddi->dwSize; - - lpddiW.dwSize = sizeof(lpddiW); - fill_joystick_dideviceinstanceW(&lpddiW, version, id); - - TRACE("%d %p\n", dwSize, lpddi); - memset(lpddi, 0, dwSize); - - /* Convert W->A */ - lpddi->dwSize = dwSize; - lpddi->guidInstance = lpddiW.guidInstance; - lpddi->guidProduct = lpddiW.guidProduct; - lpddi->dwDevType = lpddiW.dwDevType; - strcpy(lpddi->tszInstanceName, joystick_devices[id].name); - strcpy(lpddi->tszProductName, joystick_devices[id].name); - lpddi->guidFFDriver = lpddiW.guidFFDriver; - lpddi->wUsagePage = lpddiW.wUsagePage; - lpddi->wUsage = lpddiW.wUsage; -} - -static HRESULT joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id) -{ - int fd = -1; - - if (id >= find_joystick_devices()) return E_FAIL; - - if (dwFlags & DIEDFL_FORCEFEEDBACK) { - WARN("force feedback not supported\n"); - return S_FALSE; - } - - if ((dwDevType == 0) || - ((dwDevType == DIDEVTYPE_JOYSTICK) && (version >= 0x0300 && version < 0x0800)) || - (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) { - /* check whether we have a joystick */ - if ((fd = open(joystick_devices[id].device, O_RDONLY)) == -1) - { - WARN("open(%s, O_RDONLY) failed: %s\n", joystick_devices[id].device, strerror(errno)); - return S_FALSE; - } - fill_joystick_dideviceinstanceA( lpddi, version, id ); - close(fd); - TRACE("Enumerating the linux Joystick device: %s (%s)\n", joystick_devices[id].device, joystick_devices[id].name); - return S_OK; - } - - return S_FALSE; -} - -static HRESULT joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id) +static HRESULT joydev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id) { int fd = -1;
@@ -616,8 +564,7 @@ static HRESULT joydev_create_device( IDirectInputImpl *dinput, REFGUID rguid, ID
const struct dinput_device joystick_linux_device = { "Wine Linux joystick driver", - joydev_enum_deviceA, - joydev_enum_deviceW, + joydev_enum_device, joydev_create_device };
@@ -877,7 +824,6 @@ const struct dinput_device joystick_linux_device = { "Wine Linux joystick driver", NULL, NULL, - NULL };
#endif /* HAVE_LINUX_22_JOYSTICK_API */ diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 0b7a4e63c8f..488e9c04759 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -371,55 +371,7 @@ static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD ver MultiByteToWideChar(CP_ACP, 0, joydevs[id].name, -1, lpddi->tszProductName, MAX_PATH); }
-static void fill_joystick_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version, int id) -{ - DIDEVICEINSTANCEW lpddiW; - DWORD dwSize = lpddi->dwSize; - - lpddiW.dwSize = sizeof(lpddiW); - fill_joystick_dideviceinstanceW(&lpddiW, version, id); - - TRACE("%d %p\n", dwSize, lpddi); - memset(lpddi, 0, dwSize); - - /* Convert W->A */ - lpddi->dwSize = dwSize; - lpddi->guidInstance = lpddiW.guidInstance; - lpddi->guidProduct = lpddiW.guidProduct; - lpddi->dwDevType = lpddiW.dwDevType; - lstrcpynA(lpddi->tszInstanceName, joydevs[id].name, MAX_PATH); - lstrcpynA(lpddi->tszProductName, joydevs[id].name, MAX_PATH); - lpddi->guidFFDriver = lpddiW.guidFFDriver; - lpddi->wUsagePage = lpddiW.wUsagePage; - lpddi->wUsage = lpddiW.wUsage; -} - -static HRESULT joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id) -{ - find_joydevs(); - - if (id >= have_joydevs) { - return E_FAIL; - } - - if (!((dwDevType == 0) || - ((dwDevType == DIDEVTYPE_JOYSTICK) && (version >= 0x0300 && version < 0x0800)) || - (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800)))) - return S_FALSE; - -#ifndef HAVE_STRUCT_FF_EFFECT_DIRECTION - if (dwFlags & DIEDFL_FORCEFEEDBACK) - return S_FALSE; -#endif - - if (!(dwFlags & DIEDFL_FORCEFEEDBACK) || joydevs[id].has_ff) { - fill_joystick_dideviceinstanceA(lpddi, version, id); - return S_OK; - } - return S_FALSE; -} - -static HRESULT joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id) +static HRESULT joydev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id) { find_joydevs();
@@ -640,8 +592,7 @@ static HRESULT joydev_create_device( IDirectInputImpl *dinput, REFGUID rguid, ID
const struct dinput_device joystick_linuxinput_device = { "Wine Linux-input joystick driver", - joydev_enum_deviceA, - joydev_enum_deviceW, + joydev_enum_device, joydev_create_device };
@@ -1318,7 +1269,6 @@ const struct dinput_device joystick_linuxinput_device = { "Wine Linux-input joystick driver", NULL, NULL, - NULL };
#endif /* HAS_PROPER_HEADER */ diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c index 38a708d4cae..6d37a476380 100644 --- a/dlls/dinput/joystick_osx.c +++ b/dlls/dinput/joystick_osx.c @@ -984,53 +984,7 @@ static DWORD make_vid_pid(IOHIDDeviceRef device) return MAKELONG(vendID, prodID); }
-static HRESULT joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id) -{ - IOHIDDeviceRef device; - BOOL is_joystick; - - TRACE("dwDevType %u dwFlags 0x%08x version 0x%04x id %d\n", dwDevType, dwFlags, version, id); - - if (id >= find_joystick_devices()) return E_FAIL; - - device = get_device_ref(id); - - if ((dwDevType == 0) || - ((dwDevType == DIDEVTYPE_JOYSTICK) && (version >= 0x0300 && version < 0x0800)) || - (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) - { - if (dwFlags & DIEDFL_FORCEFEEDBACK) { - if(!device) - return S_FALSE; - if(get_ff(device, NULL) != S_OK) - return S_FALSE; - } - is_joystick = get_device_property_long(device, CFSTR(kIOHIDDeviceUsageKey)) == kHIDUsage_GD_Joystick; - /* Return joystick */ - lpddi->guidInstance = DInput_Wine_OsX_Joystick_GUID; - lpddi->guidInstance.Data3 = id; - lpddi->guidProduct = DInput_PIDVID_Product_GUID; - lpddi->guidProduct.Data1 = make_vid_pid(device); - lpddi->dwDevType = get_device_type(version, is_joystick); - lpddi->dwDevType |= DIDEVTYPE_HID; - lpddi->wUsagePage = 0x01; /* Desktop */ - if (is_joystick) - lpddi->wUsage = 0x04; /* Joystick */ - else - lpddi->wUsage = 0x05; /* Game Pad */ - sprintf(lpddi->tszInstanceName, "Joystick %d", id); - - /* get the device name */ - get_osx_device_name(id, lpddi->tszProductName, MAX_PATH); - - lpddi->guidFFDriver = GUID_NULL; - return S_OK; - } - - return S_FALSE; -} - -static HRESULT joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id) +static HRESULT joydev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id) { char name[MAX_PATH]; char friendly[32]; @@ -1522,8 +1476,7 @@ static HRESULT WINAPI JoystickWImpl_SendForceFeedbackCommand(IDirectInputDevice8
const struct dinput_device joystick_osx_device = { "Wine OS X joystick driver", - joydev_enum_deviceA, - joydev_enum_deviceW, + joydev_enum_device, joydev_create_device };
@@ -1700,7 +1653,6 @@ const struct dinput_device joystick_osx_device = { "Wine OS X joystick driver", NULL, NULL, - NULL };
#endif /* HAVE_IOHIDMANAGERCREATE */ diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index 0e371e31b99..fc9dbdb2ed4 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -149,30 +149,6 @@ static DWORD get_keyboard_subtype(void) return dev_subtype; }
-static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version, DWORD subtype) { - DWORD dwSize; - DIDEVICEINSTANCEA ddi; - - dwSize = lpddi->dwSize; - - TRACE("%d %p\n", dwSize, lpddi); - - memset(lpddi, 0, dwSize); - memset(&ddi, 0, sizeof(ddi)); - - ddi.dwSize = dwSize; - ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */ - ddi.guidProduct = GUID_SysKeyboard; - if (version >= 0x0800) - ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (subtype << 8); - else - ddi.dwDevType = DIDEVTYPE_KEYBOARD | (subtype << 8); - strcpy(ddi.tszInstanceName, "Keyboard"); - strcpy(ddi.tszProductName, "Wine Keyboard"); - - memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi))); -} - static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version, DWORD subtype) { DWORD dwSize; DIDEVICEINSTANCEW ddi; @@ -197,28 +173,7 @@ static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD ver memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi))); }
-static HRESULT keyboarddev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id) -{ - if (id != 0) - return E_FAIL; - - if (dwFlags & DIEDFL_FORCEFEEDBACK) - return S_FALSE; - - if ((dwDevType == 0) || - ((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) || - (((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) { - TRACE("Enumerating the Keyboard device\n"); - - fill_keyboard_dideviceinstanceA(lpddi, version, get_keyboard_subtype()); - - return S_OK; - } - - return S_FALSE; -} - -static HRESULT keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id) +static HRESULT keyboarddev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id) { if (id != 0) return E_FAIL; @@ -306,8 +261,7 @@ static HRESULT keyboarddev_create_device( IDirectInputImpl *dinput, REFGUID rgui
const struct dinput_device keyboard_device = { "Wine keyboard driver", - keyboarddev_enum_deviceA, - keyboarddev_enum_deviceW, + keyboarddev_enum_device, keyboarddev_create_device };
diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index 09cfe945a50..22e40a60285 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -93,30 +93,6 @@ static void _dump_mouse_state(const DIMOUSESTATE2 *m_state) TRACE(")\n"); }
-static void fill_mouse_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version) { - DWORD dwSize; - DIDEVICEINSTANCEA ddi; - - dwSize = lpddi->dwSize; - - TRACE("%d %p\n", dwSize, lpddi); - - memset(lpddi, 0, dwSize); - memset(&ddi, 0, sizeof(ddi)); - - ddi.dwSize = dwSize; - ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */ - ddi.guidProduct = GUID_SysMouse; - if (version >= 0x0800) - ddi.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8); - else - ddi.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8); - strcpy(ddi.tszInstanceName, "Mouse"); - strcpy(ddi.tszProductName, "Wine Mouse"); - - memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi))); -} - static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version) { DWORD dwSize; DIDEVICEINSTANCEW ddi; @@ -141,28 +117,7 @@ static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD versio memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi))); }
-static HRESULT mousedev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id) -{ - if (id != 0) - return E_FAIL; - - if (dwFlags & DIEDFL_FORCEFEEDBACK) - return S_FALSE; - - if ((dwDevType == 0) || - ((dwDevType == DIDEVTYPE_MOUSE) && (version < 0x0800)) || - (((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 0x0800))) { - TRACE("Enumerating the mouse device\n"); - - fill_mouse_dideviceinstanceA(lpddi, version); - - return S_OK; - } - - return S_FALSE; -} - -static HRESULT mousedev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id) +static HRESULT mousedev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id) { if (id != 0) return E_FAIL; @@ -263,8 +218,7 @@ static HRESULT mousedev_create_device( IDirectInputImpl *dinput, REFGUID rguid,
const struct dinput_device mouse_device = { "Wine mouse driver", - mousedev_enum_deviceA, - mousedev_enum_deviceW, + mousedev_enum_device, mousedev_create_device };
Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=36263 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/dinput_main.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 62e70e0535c..c7b932aca44 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -864,8 +864,10 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics( if (lpCallback(&didevis[i], lpdid, callbackFlags, --remain, pvRef) == DIENUM_STOP) { HeapFree(GetProcessHeap(), 0, didevis); + IDirectInputDevice_Release(lpdid); return DI_OK; } + IDirectInputDevice_Release(lpdid); }
HeapFree(GetProcessHeap(), 0, didevis); @@ -883,7 +885,11 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics( IDirectInputDevice_GetDeviceInfo(lpdid, &didevi);
if (lpCallback(&didevi, lpdid, callbackFlags, --remain, pvRef) == DIENUM_STOP) + { + IDirectInputDevice_Release(lpdid); return DI_OK; + } + IDirectInputDevice_Release(lpdid); } }
Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=36263 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick.c | 11 +++++++++++ dlls/dinput/joystick_linux.c | 2 +- dlls/dinput/joystick_linuxinput.c | 2 +- dlls/dinput/joystick_osx.c | 2 +- dlls/dinput/joystick_private.h | 2 ++ 5 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c index a68c4df20e6..8ea7850621c 100644 --- a/dlls/dinput/joystick.c +++ b/dlls/dinput/joystick.c @@ -534,6 +534,17 @@ HRESULT WINAPI JoystickWGenericImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W iface, return DI_OK; }
+ +ULONG WINAPI JoystickWGenericImpl_Release(LPDIRECTINPUTDEVICE8W iface) +{ + JoystickGenericImpl *This = impl_from_IDirectInputDevice8W(iface); + void *axis_map = This->axis_map; + ULONG res = IDirectInputDevice2WImpl_Release(iface); + if (!res) HeapFree(GetProcessHeap(), 0, axis_map); + return res; +} + + /****************************************************************************** * GetObjectInfo : get object info */ diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 5a88e643e07..3215978c995 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -786,7 +786,7 @@ static const IDirectInputDevice8WVtbl JoystickWvt = { IDirectInputDevice2WImpl_QueryInterface, IDirectInputDevice2WImpl_AddRef, - IDirectInputDevice2WImpl_Release, + JoystickWGenericImpl_Release, JoystickWGenericImpl_GetCapabilities, IDirectInputDevice2WImpl_EnumObjects, JoystickLinuxWImpl_GetProperty, diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 488e9c04759..2b970271ec3 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -1231,7 +1231,7 @@ static const IDirectInputDevice8WVtbl JoystickWvt = { IDirectInputDevice2WImpl_QueryInterface, IDirectInputDevice2WImpl_AddRef, - IDirectInputDevice2WImpl_Release, + JoystickWGenericImpl_Release, JoystickWGenericImpl_GetCapabilities, IDirectInputDevice2WImpl_EnumObjects, JoystickWImpl_GetProperty, diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c index 6d37a476380..27a47b07639 100644 --- a/dlls/dinput/joystick_osx.c +++ b/dlls/dinput/joystick_osx.c @@ -1484,7 +1484,7 @@ static const IDirectInputDevice8WVtbl JoystickWvt = { IDirectInputDevice2WImpl_QueryInterface, IDirectInputDevice2WImpl_AddRef, - IDirectInputDevice2WImpl_Release, + JoystickWGenericImpl_Release, JoystickWGenericImpl_GetCapabilities, IDirectInputDevice2WImpl_EnumObjects, JoystickWImpl_GetProperty, diff --git a/dlls/dinput/joystick_private.h b/dlls/dinput/joystick_private.h index 78d5d721808..874bf3e69a7 100644 --- a/dlls/dinput/joystick_private.h +++ b/dlls/dinput/joystick_private.h @@ -59,6 +59,8 @@ DWORD joystick_map_pov(const POINTL *p) DECLSPEC_HIDDEN;
BOOL device_disabled_registry(const char* name) DECLSPEC_HIDDEN;
+ULONG WINAPI JoystickWGenericImpl_Release(LPDIRECTINPUTDEVICE8W iface); + HRESULT WINAPI JoystickWGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) DECLSPEC_HIDDEN;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/ansi.c | 2 +- include/dinput.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/dinput/ansi.c b/dlls/dinput/ansi.c index 431b812aeb2..390b2f56581 100644 --- a/dlls/dinput/ansi.c +++ b/dlls/dinput/ansi.c @@ -92,7 +92,7 @@ static void dideviceobjectinstance_wtoa( const DIDEVICEOBJECTINSTANCEW *in, DIDE out->wUsage = in->wUsage; out->dwDimension = in->dwDimension; out->wExponent = in->wExponent; - out->wReserved = in->wReserved; + out->wReportId = in->wReportId; }
static void dideviceinstance_wtoa( const DIDEVICEINSTANCEW *in, DIDEVICEINSTANCEA *out ) diff --git a/include/dinput.h b/include/dinput.h index 2d183bbc944..a073054b388 100644 --- a/include/dinput.h +++ b/include/dinput.h @@ -358,7 +358,7 @@ typedef struct DIDEVICEOBJECTINSTANCEA { WORD wUsage; DWORD dwDimension; WORD wExponent; - WORD wReserved; + WORD wReportId; } DIDEVICEOBJECTINSTANCEA, *LPDIDEVICEOBJECTINSTANCEA; typedef const DIDEVICEOBJECTINSTANCEA *LPCDIDEVICEOBJECTINSTANCEA;
@@ -377,7 +377,7 @@ typedef struct DIDEVICEOBJECTINSTANCEW { WORD wUsage; DWORD dwDimension; WORD wExponent; - WORD wReserved; + WORD wReportId; } DIDEVICEOBJECTINSTANCEW, *LPDIDEVICEOBJECTINSTANCEW; typedef const DIDEVICEOBJECTINSTANCEW *LPCDIDEVICEOBJECTINSTANCEW;