diff --git a/reactos/dll/directx/wine/dinput/device.c b/reactos/dll/directx/wine/dinput/device.c index 715e03dcb2d..82059a378e1 100644 --- a/reactos/dll/directx/wine/dinput/device.c +++ b/reactos/dll/directx/wine/dinput/device.c @@ -852,7 +852,7 @@ HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, L /* Save the settings to disk */ save_mapping_settings(iface, lpdiaf, username); - return IDirectInputDevice8WImpl_SetActionMap(iface, lpdiaf, lpszUserName, dwFlags); + return DI_OK; } /****************************************************************************** @@ -1617,8 +1617,14 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Poll(LPDIRECTINPUTDEVICE8W iface) IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface); if (!This->acquired) return DIERR_NOTACQUIRED; - /* Because wine devices do not need to be polled, just return DI_NOEFFECT */ + +#ifndef __REACTOS__ + __wine_check_for_events( QS_ALLINPUT ); + return DI_OK; +#else + /* Devices do not need to be polled on ReactOS. */ return DI_NOEFFECT; +#endif } HRESULT WINAPI IDirectInputDevice2AImpl_Poll(LPDIRECTINPUTDEVICE8A iface) @@ -1705,16 +1711,6 @@ HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W ifa return DI_OK; } -HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface, - LPDIACTIONFORMATW lpdiaf, - LPCWSTR lpszUserName, - DWORD dwFlags) -{ - FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags); - - return DI_OK; -} - HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface, LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader) { diff --git a/reactos/dll/directx/wine/dinput/device_private.h b/reactos/dll/directx/wine/dinput/device_private.h index 75d872d884f..bf227fd7f26 100644 --- a/reactos/dll/directx/wine/dinput/device_private.h +++ b/reactos/dll/directx/wine/dinput/device_private.h @@ -235,10 +235,6 @@ extern HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVIC LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface, - LPDIACTIONFORMATW lpdiaf, - LPCWSTR lpszUserName, - DWORD dwFlags) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface, LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface, diff --git a/reactos/dll/directx/wine/dinput/joystick.c b/reactos/dll/directx/wine/dinput/joystick.c index 1c801ccd1c5..c435b1c971e 100644 --- a/reactos/dll/directx/wine/dinput/joystick.c +++ b/reactos/dll/directx/wine/dinput/joystick.c @@ -28,6 +28,8 @@ #include "dinput_private.h" +#include + #include "joystick_private.h" static inline JoystickGenericImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface) @@ -407,13 +409,13 @@ void _dump_DIDEVCAPS(const DIDEVCAPS *lpDIDevCaps) TRACE("dwFlags: %08x\n", lpDIDevCaps->dwFlags); switch(type) { - /* Directx <= 7 definitions */ + /* Direct X <= 7 definitions */ DEBUG_TYPE(DIDEVTYPE_DEVICE); DEBUG_TYPE(DIDEVTYPE_MOUSE); DEBUG_TYPE(DIDEVTYPE_KEYBOARD); DEBUG_TYPE(DIDEVTYPE_JOYSTICK); DEBUG_TYPE(DIDEVTYPE_HID); - /* Directx >= 8 definitions */ + /* Direct X >= 8 definitions */ DEBUG_TYPE(DI8DEVTYPE_DEVICE); DEBUG_TYPE(DI8DEVTYPE_MOUSE); DEBUG_TYPE(DI8DEVTYPE_KEYBOARD); @@ -606,6 +608,8 @@ HRESULT WINAPI JoystickAGenericImpl_GetDeviceInfo( LPDIDEVICEINSTANCEA pdidi) { JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface); + DIPROPDWORD pd; + DWORD index = 0; TRACE("(%p,%p)\n", iface, pdidi); @@ -620,12 +624,20 @@ HRESULT WINAPI JoystickAGenericImpl_GetDeviceInfo( return DIERR_INVALIDPARAM; } + /* Try to get joystick index */ + pd.diph.dwSize = sizeof(pd); + pd.diph.dwHeaderSize = sizeof(pd.diph); + pd.diph.dwObj = 0; + pd.diph.dwHow = DIPH_DEVICE; + if (SUCCEEDED(IDirectInputDevice2_GetProperty(iface, DIPROP_JOYSTICKID, &pd.diph))) + index = pd.dwData; + /* Return joystick */ pdidi->guidInstance = This->guidInstance; pdidi->guidProduct = This->guidProduct; /* we only support traditional joysticks for now */ pdidi->dwDevType = This->devcaps.dwDevType; - strcpy(pdidi->tszInstanceName, "Joystick"); + snprintf(pdidi->tszInstanceName, MAX_PATH, "Joystick %d", index); strcpy(pdidi->tszProductName, This->name); if (pdidi->dwSize > sizeof(DIDEVICEINSTANCE_DX3A)) { pdidi->guidFFDriver = GUID_NULL; @@ -644,6 +656,9 @@ HRESULT WINAPI JoystickWGenericImpl_GetDeviceInfo( LPDIDEVICEINSTANCEW pdidi) { JoystickGenericImpl *This = impl_from_IDirectInputDevice8W(iface); + CHAR buffer[MAX_PATH]; + DIPROPDWORD pd; + DWORD index = 0; TRACE("(%p,%p)\n", iface, pdidi); @@ -653,12 +668,21 @@ HRESULT WINAPI JoystickWGenericImpl_GetDeviceInfo( return DIERR_INVALIDPARAM; } + /* Try to get joystick index */ + pd.diph.dwSize = sizeof(pd); + pd.diph.dwHeaderSize = sizeof(pd.diph); + pd.diph.dwObj = 0; + pd.diph.dwHow = DIPH_DEVICE; + if (SUCCEEDED(IDirectInputDevice2_GetProperty(iface, DIPROP_JOYSTICKID, &pd.diph))) + index = pd.dwData; + /* Return joystick */ pdidi->guidInstance = This->guidInstance; pdidi->guidProduct = This->guidProduct; /* we only support traditional joysticks for now */ pdidi->dwDevType = This->devcaps.dwDevType; - MultiByteToWideChar(CP_ACP, 0, "Joystick", -1, pdidi->tszInstanceName, MAX_PATH); + snprintf(buffer, sizeof(buffer), "Joystick %d", index); + MultiByteToWideChar(CP_ACP, 0, buffer, -1, pdidi->tszInstanceName, MAX_PATH); MultiByteToWideChar(CP_ACP, 0, This->name, -1, pdidi->tszProductName, MAX_PATH); if (pdidi->dwSize > sizeof(DIDEVICEINSTANCE_DX3W)) { pdidi->guidFFDriver = GUID_NULL; @@ -740,7 +764,7 @@ HRESULT WINAPI JoystickWGenericImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface, DWORD type = 0x000000ff & (lpdiaf->rgoAction[i].dwSemantic >> 8); DWORD genre = 0xff000000 & lpdiaf->rgoAction[i].dwSemantic; - /* Don't touch an user configured action */ + /* Don't touch a user configured action */ if (lpdiaf->rgoAction[i].dwHow == DIAH_USERCONFIG) continue; /* Only consider actions of the right genre */ @@ -750,7 +774,7 @@ HRESULT WINAPI JoystickWGenericImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface, { if (type & object_types[j]) { - /* Assure that the object exists */ + /* Ensure that the object exists */ LPDIOBJECTDATAFORMAT odf = dataformat_to_odf_by_type(This->base.data_format.wine_df, inst, object_types[j]); if (odf != NULL) diff --git a/reactos/dll/directx/wine/dinput/joystick_linux.c b/reactos/dll/directx/wine/dinput/joystick_linux.c index 418bdbb355f..85a56e91151 100644 --- a/reactos/dll/directx/wine/dinput/joystick_linux.c +++ b/reactos/dll/directx/wine/dinput/joystick_linux.c @@ -203,6 +203,52 @@ static INT find_joystick_devices(void) return joystick_devices_count; } +static void fill_joystick_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version, int id) +{ + DWORD dwSize = lpddi->dwSize; + + TRACE("%d %p\n", dwSize, lpddi); + memset(lpddi, 0, dwSize); + + /* Return joystick */ + lpddi->dwSize = dwSize; + lpddi->guidInstance = DInput_Wine_Joystick_GUID; + lpddi->guidInstance.Data3 = id; + lpddi->guidProduct = DInput_Wine_Joystick_GUID; + /* we only support traditional joysticks for now */ + if (version >= 0x0800) + lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8); + else + lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8); + strcpy(lpddi->tszInstanceName, joystick_devices[id].name); + strcpy(lpddi->tszProductName, joystick_devices[id].name); + + lpddi->guidFFDriver = GUID_NULL; +} + +static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version, int id) +{ + DWORD dwSize = lpddi->dwSize; + + TRACE("%d %p\n", dwSize, lpddi); + memset(lpddi, 0, dwSize); + + /* Return joystick */ + lpddi->dwSize = dwSize; + lpddi->guidInstance = DInput_Wine_Joystick_GUID; + lpddi->guidInstance.Data3 = id; + lpddi->guidProduct = DInput_Wine_Joystick_GUID; + /* we only support traditional joysticks for now */ + if (version >= 0x0800) + lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8); + else + lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8); + + MultiByteToWideChar(CP_ACP, 0, joystick_devices[id].name, -1, lpddi->tszInstanceName, MAX_PATH); + MultiByteToWideChar(CP_ACP, 0, joystick_devices[id].name, -1, lpddi->tszProductName, MAX_PATH); + lpddi->guidFFDriver = GUID_NULL; +} + static HRESULT joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id) { int fd = -1; @@ -223,21 +269,7 @@ static HRESULT joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS WARN("open(%s, O_RDONLY) failed: %s\n", joystick_devices[id].name, strerror(errno)); return S_FALSE; } - - /* Return joystick */ - lpddi->guidInstance = DInput_Wine_Joystick_GUID; - lpddi->guidInstance.Data3 = id; - lpddi->guidProduct = DInput_Wine_Joystick_GUID; - /* we only support traditional joysticks for now */ - if (version >= 0x0800) - lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8); - else - lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8); - - strcpy(lpddi->tszInstanceName, joystick_devices[id].name); - strcpy(lpddi->tszProductName, joystick_devices[id].name); - - lpddi->guidFFDriver = GUID_NULL; + fill_joystick_dideviceinstanceA( lpddi, version, id ); close(fd); TRACE("Enumerating the linux Joystick device: %s (%s)\n", joystick_devices[id].device, lpddi->tszProductName); return S_OK; @@ -266,20 +298,7 @@ static HRESULT joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS WARN("open(%s,O_RDONLY) failed: %s\n", joystick_devices[id].device, strerror(errno)); return S_FALSE; } - - /* Return joystick */ - lpddi->guidInstance = DInput_Wine_Joystick_GUID; - lpddi->guidInstance.Data3 = id; - lpddi->guidProduct = DInput_Wine_Joystick_GUID; - /* we only support traditional joysticks for now */ - if (version >= 0x0800) - lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8); - else - lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8); - - MultiByteToWideChar(CP_ACP, 0, joystick_devices[id].name, -1, lpddi->tszInstanceName, MAX_PATH); - MultiByteToWideChar(CP_ACP, 0, joystick_devices[id].name, -1, lpddi->tszProductName, MAX_PATH); - lpddi->guidFFDriver = GUID_NULL; + fill_joystick_dideviceinstanceW( 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; @@ -570,6 +589,41 @@ static HRESULT WINAPI JoystickLinuxAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface return JoystickLinuxWImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph); } +/****************************************************************************** + * GetDeviceInfo : get information about a device's identity + */ +static HRESULT WINAPI JoystickLinuxAImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8A iface, LPDIDEVICEINSTANCEA ddi) +{ + JoystickImpl *This = impl_from_IDirectInputDevice8A(iface); + + TRACE("(%p) %p\n", This, ddi); + + if (ddi == NULL) return E_POINTER; + if ((ddi->dwSize != sizeof(DIDEVICEINSTANCE_DX3A)) && + (ddi->dwSize != sizeof(DIDEVICEINSTANCEA))) + return DIERR_INVALIDPARAM; + + fill_joystick_dideviceinstanceA( ddi, This->generic.base.dinput->dwVersion, + get_joystick_index(&This->generic.base.guid) ); + return DI_OK; +} + +static HRESULT WINAPI JoystickLinuxWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW ddi) +{ + JoystickImpl *This = impl_from_IDirectInputDevice8W(iface); + + TRACE("(%p) %p\n", This, ddi); + + if (ddi == NULL) return E_POINTER; + if ((ddi->dwSize != sizeof(DIDEVICEINSTANCE_DX3W)) && + (ddi->dwSize != sizeof(DIDEVICEINSTANCEW))) + return DIERR_INVALIDPARAM; + + fill_joystick_dideviceinstanceW( ddi, This->generic.base.dinput->dwVersion, + get_joystick_index(&This->generic.base.guid) ); + return DI_OK; +} + /****************************************************************************** * Unacquire : frees the joystick */ @@ -693,7 +747,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt = IDirectInputDevice2AImpl_SetEventNotification, IDirectInputDevice2AImpl_SetCooperativeLevel, JoystickAGenericImpl_GetObjectInfo, - JoystickAGenericImpl_GetDeviceInfo, + JoystickLinuxAImpl_GetDeviceInfo, IDirectInputDevice2AImpl_RunControlPanel, IDirectInputDevice2AImpl_Initialize, IDirectInputDevice2AImpl_CreateEffect, @@ -729,7 +783,7 @@ static const IDirectInputDevice8WVtbl JoystickWvt = IDirectInputDevice2WImpl_SetEventNotification, IDirectInputDevice2WImpl_SetCooperativeLevel, JoystickWGenericImpl_GetObjectInfo, - JoystickWGenericImpl_GetDeviceInfo, + JoystickLinuxWImpl_GetDeviceInfo, IDirectInputDevice2WImpl_RunControlPanel, IDirectInputDevice2WImpl_Initialize, IDirectInputDevice2WImpl_CreateEffect, diff --git a/reactos/dll/directx/wine/dinput/keyboard.c b/reactos/dll/directx/wine/dinput/keyboard.c index decf3d13973..294ccfd755f 100644 --- a/reactos/dll/directx/wine/dinput/keyboard.c +++ b/reactos/dll/directx/wine/dinput/keyboard.c @@ -515,6 +515,29 @@ static HRESULT WINAPI SysKeyboardAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, return SysKeyboardWImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph); } +static HRESULT WINAPI SysKeyboardWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface) +{ + SysKeyboardImpl *This = impl_from_IDirectInputDevice8W(iface); + HRESULT res; + + TRACE("(%p)\n", This); + + res = IDirectInputDevice2WImpl_Acquire(iface); + if (res == DI_OK) + { + TRACE("clearing keystate\n"); + memset(This->DInputKeyState, 0, sizeof(This->DInputKeyState)); + } + + return res; +} + +static HRESULT WINAPI SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) +{ + SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface); + return SysKeyboardWImpl_Acquire(IDirectInputDevice8W_from_impl(This)); +} + static HRESULT WINAPI SysKeyboardWImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, @@ -603,7 +626,7 @@ static const IDirectInputDevice8AVtbl SysKeyboardAvt = IDirectInputDevice2AImpl_EnumObjects, SysKeyboardAImpl_GetProperty, IDirectInputDevice2AImpl_SetProperty, - IDirectInputDevice2AImpl_Acquire, + SysKeyboardAImpl_Acquire, IDirectInputDevice2AImpl_Unacquire, SysKeyboardAImpl_GetDeviceState, IDirectInputDevice2AImpl_GetDeviceData, @@ -639,7 +662,7 @@ static const IDirectInputDevice8WVtbl SysKeyboardWvt = IDirectInputDevice2WImpl_EnumObjects, SysKeyboardWImpl_GetProperty, IDirectInputDevice2WImpl_SetProperty, - IDirectInputDevice2WImpl_Acquire, + SysKeyboardWImpl_Acquire, IDirectInputDevice2WImpl_Unacquire, SysKeyboardWImpl_GetDeviceState, IDirectInputDevice2WImpl_GetDeviceData, diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index 415c74a609b..99f0610217c 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -30,7 +30,7 @@ reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to WineStaging-1.7.37 reactos/dll/directx/wine/d3dxof # Synced to WineStaging-1.7.47 reactos/dll/directx/wine/ddraw # Synced to WineStaging-1.7.37 reactos/dll/directx/wine/devenum # Synced to WineStaging-1.7.47 -reactos/dll/directx/wine/dinput # Synced to WineStaging-1.7.37 +reactos/dll/directx/wine/dinput # Synced to WineStaging-1.7.47 reactos/dll/directx/wine/dinput8 # Synced to WineStaging-1.7.37 reactos/dll/directx/wine/dmusic # Synced to WineStaging-1.7.37 reactos/dll/directx/wine/dplay # Synced to WineStaging-1.7.37