[DINPUT] Sync with Wine Staging 4.0. CORE-15682

This commit is contained in:
Amine Khaldi 2019-01-25 13:11:07 +01:00
parent e7b199daff
commit 98e62237b1
13 changed files with 65 additions and 61 deletions

View file

@ -20,6 +20,7 @@ add_library(dinput SHARED
${SOURCE}
data_formats.c
dinput.rc
version.rc
${CMAKE_CURRENT_BINARY_DIR}/dinput.def)
add_library(dinput_data_formats data_formats.c)

View file

@ -86,7 +86,6 @@ static BOOL CALLBACK collect_devices(LPCDIDEVICEINSTANCEW lpddi, IDirectInputDev
*/
static void init_listview_columns(HWND dialog)
{
HINSTANCE hinstance = (HINSTANCE) GetWindowLongPtrW(dialog, GWLP_HINSTANCE);
LVCOLUMNW listColumn;
RECT viewRect;
int width;
@ -95,7 +94,7 @@ static void init_listview_columns(HWND dialog)
GetClientRect(GetDlgItem(dialog, IDC_DEVICEOBJECTSLIST), &viewRect);
width = (viewRect.right - viewRect.left)/2;
LoadStringW(hinstance, IDS_OBJECTCOLUMN, column, sizeof(column)/sizeof(column[0]));
LoadStringW(DINPUT_instance, IDS_OBJECTCOLUMN, column, ARRAY_SIZE(column));
listColumn.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
listColumn.pszText = column;
listColumn.cchTextMax = lstrlenW(listColumn.pszText);
@ -103,7 +102,7 @@ static void init_listview_columns(HWND dialog)
SendDlgItemMessageW (dialog, IDC_DEVICEOBJECTSLIST, LVM_INSERTCOLUMNW, 0, (LPARAM) &listColumn);
LoadStringW(hinstance, IDS_ACTIONCOLUMN, column, sizeof(column)/sizeof(column[0]));
LoadStringW(DINPUT_instance, IDS_ACTIONCOLUMN, column, ARRAY_SIZE(column));
listColumn.cx = width;
listColumn.pszText = column;
listColumn.cchTextMax = lstrlenW(listColumn.pszText);
@ -453,7 +452,8 @@ HRESULT _configure_devices(IDirectInput8W *iface,
InitCommonControls();
DialogBoxParamW(GetModuleHandleA("dinput.dll"), (LPCWSTR) MAKEINTRESOURCE(IDD_CONFIGUREDEVICES), lpdiCDParams->hwnd, ConfigureDevicesDlgProc, (LPARAM) &data);
DialogBoxParamW(DINPUT_instance, (const WCHAR *)MAKEINTRESOURCE(IDD_CONFIGUREDEVICES),
lpdiCDParams->hwnd, ConfigureDevicesDlgProc, (LPARAM)&data);
return DI_OK;
}

View file

@ -80,7 +80,7 @@ static void _dump_cooperativelevel_DI(DWORD dwFlags) {
#undef FE
};
TRACE(" cooperative level : ");
for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
for (i = 0; i < ARRAY_SIZE(flags); i++)
if (flags[i].mask & dwFlags)
TRACE("%s ",flags[i].name);
TRACE("\n");
@ -106,7 +106,7 @@ static void _dump_ObjectDataFormat_flags(DWORD dwFlags) {
TRACE("Flags:");
/* First the flags */
for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++) {
for (i = 0; i < ARRAY_SIZE(flags); i++) {
if (flags[i].mask & dwFlags)
TRACE(" %s",flags[i].name);
}
@ -153,7 +153,7 @@ static void _dump_EnumObjects_flags(DWORD dwFlags) {
if (type == DIDFT_ALL) {
TRACE(" DIDFT_ALL");
} else {
for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++) {
for (i = 0; i < ARRAY_SIZE(flags); i++) {
if (flags[i].mask & type) {
type &= ~flags[i].mask;
TRACE(" %s",flags[i].name);
@ -230,7 +230,7 @@ const char *_dump_dinput_GUID(const GUID *guid) {
};
if (guid == NULL)
return "null GUID";
for (i = 0; i < (sizeof(guids) / sizeof(guids[0])); i++) {
for (i = 0; i < ARRAY_SIZE(guids); i++) {
if (IsEqualGUID(guids[i].guid, guid)) {
return guids[i].name;
}
@ -916,7 +916,7 @@ HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, L
if (dwFlags & DIDSAM_NOUSER)
dps.wsz[0] = '\0';
else
lstrcpynW(dps.wsz, username, sizeof(dps.wsz)/sizeof(WCHAR));
lstrcpynW(dps.wsz, username, ARRAY_SIZE(dps.wsz));
IDirectInputDevice8_SetProperty(iface, DIPROP_USERNAME, &dps.diph);
/* Save the settings to disk */
@ -1323,7 +1323,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface,
{
if (*device_player->username)
{
lstrcpynW(ps->wsz, device_player->username, sizeof(ps->wsz)/sizeof(WCHAR));
lstrcpynW(ps->wsz, device_player->username, ARRAY_SIZE(ps->wsz));
return DI_OK;
}
else break;
@ -1428,8 +1428,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetProperty(
device_player->instance_guid = This->guid;
}
if (device_player)
lstrcpynW(device_player->username, ps->wsz,
sizeof(device_player->username)/sizeof(WCHAR));
lstrcpynW(device_player->username, ps->wsz, ARRAY_SIZE(device_player->username));
break;
}
default:

View file

@ -114,9 +114,6 @@ typedef struct
LPDIRECTINPUTEFFECT ref;
} effect_list_item;
extern const GUID DInput_Wine_Keyboard_GUID DECLSPEC_HIDDEN;
extern const GUID DInput_Wine_Mouse_GUID DECLSPEC_HIDDEN;
/* Various debug tools */
extern void _dump_DIPROPHEADER(LPCDIPROPHEADER diph) DECLSPEC_HIDDEN;
extern void _dump_OBJECTINSTANCEA(const DIDEVICEOBJECTINSTANCEA *ddoi) DECLSPEC_HIDDEN;

View file

@ -18,19 +18,10 @@
#include "resource.h"
1 WINE_REGISTRY dinput_classes.rgs
#define WINE_FILEDESCRIPTION_STR "Wine DirectInput"
#define WINE_FILENAME_STR "dinput.dll"
#define WINE_FILEVERSION 5,1,2600,881
#define WINE_FILEVERSION_STR "5.1.2600.881"
#define WINE_PRODUCTVERSION 5,1,2600,881
#define WINE_PRODUCTVERSION_STR "5.1"
#include "wine/wine_common_ver.rc"
#pragma makedep po
1 WINE_REGISTRY dinput_classes.rgs
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
STRINGTABLE

View file

@ -93,7 +93,7 @@ static const struct dinput_device *dinput_devices[] =
&joystick_osx_device
};
static HINSTANCE DINPUT_instance = NULL;
HINSTANCE DINPUT_instance;
static BOOL check_hook_thread(void);
static CRITICAL_SECTION dinput_hook_crit;
@ -282,7 +282,7 @@ static void _dump_EnumDevices_dwFlags(DWORD dwFlags)
TRACE("DIEDFL_ALLDEVICES\n");
return;
}
for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
for (i = 0; i < ARRAY_SIZE(flags); i++)
if (flags[i].mask & dwFlags)
TRACE("%s ",flags[i].name);
}
@ -1090,7 +1090,7 @@ static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics(
/* Add keyboard and mouse to remaining device count */
if (!(dwFlags & DIEDBSFL_FORCEFEEDBACK))
{
for (i = 0; i < sizeof(guids) / sizeof(guids[0]); i++)
for (i = 0; i < ARRAY_SIZE(guids); i++)
{
if (should_enumerate_device(username_w, dwFlags, &This->device_players, guids[i]))
remain++;
@ -1119,7 +1119,7 @@ static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics(
}
/* Enumerate keyboard and mouse */
for(i=0; i < sizeof(guids)/sizeof(guids[0]); i++)
for (i = 0; i < ARRAY_SIZE(guids); i++)
{
if (should_enumerate_device(username_w, dwFlags, &This->device_players, guids[i]))
{
@ -1191,7 +1191,7 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics(
/* Add keyboard and mouse to remaining device count */
if (!(dwFlags & DIEDBSFL_FORCEFEEDBACK))
{
for (i = 0; i < sizeof(guids) / sizeof(guids[0]); i++)
for (i = 0; i < ARRAY_SIZE(guids); i++)
{
if (should_enumerate_device(ptszUserName, dwFlags, &This->device_players, guids[i]))
remain++;
@ -1215,7 +1215,7 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics(
if (dwFlags & DIEDBSFL_FORCEFEEDBACK) return DI_OK;
/* Enumerate keyboard and mouse */
for(i=0; i < sizeof(guids)/sizeof(guids[0]); i++)
for (i = 0; i < ARRAY_SIZE(guids); i++)
{
if (should_enumerate_device(ptszUserName, dwFlags, &This->device_players, guids[i]))
{
@ -1747,12 +1747,10 @@ static DWORD WINAPI hook_thread_proc(void *param)
{
if (!dev->acquired || !dev->event_proc) continue;
if (IsEqualGUID( &dev->guid, &GUID_SysKeyboard ) ||
IsEqualGUID( &dev->guid, &DInput_Wine_Keyboard_GUID ))
if (IsEqualGUID( &dev->guid, &GUID_SysKeyboard ))
kbd_cnt++;
else
if (IsEqualGUID( &dev->guid, &GUID_SysMouse ) ||
IsEqualGUID( &dev->guid, &DInput_Wine_Mouse_GUID ))
if (IsEqualGUID( &dev->guid, &GUID_SysMouse ))
mice_cnt++;
}
LeaveCriticalSection( &dinput->crit );

View file

@ -27,6 +27,8 @@
#include "dinputd.h"
#include "wine/list.h"
extern HINSTANCE DINPUT_instance;
/* Implementation specification */
typedef struct IDirectInputImpl IDirectInputImpl;
struct IDirectInputImpl

View file

@ -92,7 +92,7 @@ static void _dump_DIEFFECT_flags(DWORD dwFlags)
FE(DIEFF_SPHERICAL)
#undef FE
};
for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
for (i = 0; i < ARRAY_SIZE(flags); i++)
if (flags[i].mask & dwFlags)
TRACE("%s ", flags[i].name);
TRACE("\n");
@ -766,11 +766,11 @@ HRESULT WINAPI JoystickWGenericImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
LPCWSTR lpszUserName,
DWORD dwFlags)
{
static const DWORD object_types[] = { DIDFT_AXIS, DIDFT_BUTTON };
static const DWORD type_map[] = { DIDFT_RELAXIS, DIDFT_PSHBUTTON };
JoystickGenericImpl *This = impl_from_IDirectInputDevice8W(iface);
unsigned int i, j;
BOOL has_actions = FALSE;
DWORD object_types[] = { DIDFT_AXIS, DIDFT_BUTTON };
DWORD type_map[] = { DIDFT_RELAXIS, DIDFT_PSHBUTTON };
FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
@ -786,7 +786,7 @@ HRESULT WINAPI JoystickWGenericImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
/* Only consider actions of the right genre */
if (lpdiaf->dwGenre != genre && genre != DIGENRE_ANY) continue;
for (j=0; j < sizeof(object_types)/sizeof(object_types[0]); j++)
for (j = 0; j < ARRAY_SIZE(object_types); j++)
{
if (type & object_types[j])
{
@ -979,7 +979,7 @@ HRESULT setup_dinput_options(JoystickGenericImpl *This, const int *default_axis_
{
int i;
for (i = 0; i < sizeof(axis_names) / sizeof(axis_names[0]); i++)
for (i = 0; i < ARRAY_SIZE(axis_names); i++)
{
if (!strcmp(ptr, axis_names[i]))
{
@ -1011,7 +1011,7 @@ HRESULT setup_dinput_options(JoystickGenericImpl *This, const int *default_axis_
}
}
if (i == sizeof(axis_names) / sizeof(axis_names[0]))
if (i == ARRAY_SIZE(axis_names))
{
ERR("invalid joystick axis type: \"%s\"\n", ptr);
i = -1;

View file

@ -279,7 +279,7 @@ static const char* debugstr_cf(CFTypeRef t)
if (!ret)
{
UniChar buf[200];
int len = min(CFStringGetLength(s), sizeof(buf)/sizeof(buf[0]));
int len = min(CFStringGetLength(s), ARRAY_SIZE(buf));
CFStringGetCharacters(s, CFRangeMake(0, len), buf);
ret = debugstr_wn(buf, len);
}

View file

@ -145,10 +145,6 @@ static int KeyboardCallback( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM
return ret;
}
const GUID DInput_Wine_Keyboard_GUID = { /* 0ab8648a-7735-11d2-8c73-71df54a96441 */
0x0ab8648a, 0x7735, 0x11d2, {0x8c, 0x73, 0x71, 0xdf, 0x54, 0xa9, 0x64, 0x41}
};
static DWORD get_keyboard_subtype(void)
{
DWORD kbd_type, kbd_subtype, dev_subtype;
@ -179,7 +175,7 @@ static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD ver
ddi.dwSize = dwSize;
ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
ddi.guidProduct = GUID_SysKeyboard;
if (version >= 0x0800)
ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (subtype << 8);
else
@ -203,7 +199,7 @@ static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD ver
ddi.dwSize = dwSize;
ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
ddi.guidProduct = GUID_SysKeyboard;
if (version >= 0x0800)
ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (subtype << 8);
else
@ -308,8 +304,7 @@ static HRESULT keyboarddev_create_device(IDirectInputImpl *dinput, REFGUID rguid
TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode);
*pdev = NULL;
if (IsEqualGUID(&GUID_SysKeyboard, rguid) || /* Generic Keyboard */
IsEqualGUID(&DInput_Wine_Keyboard_GUID, rguid)) /* Wine Keyboard */
if (IsEqualGUID(&GUID_SysKeyboard, rguid)) /* Wine Keyboard */
{
SysKeyboardImpl *This;
@ -508,7 +503,7 @@ static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface
scan = map_dik_to_scan(DIDFT_GETINSTANCE(pdidoi->dwType), This->subtype);
if (!GetKeyNameTextW((scan & 0x80) << 17 | (scan & 0x7f) << 16,
pdidoi->tszName, sizeof(pdidoi->tszName)/sizeof(pdidoi->tszName[0])))
pdidoi->tszName, ARRAY_SIZE(pdidoi->tszName)))
return DIERR_OBJECTNOTFOUND;
_dump_OBJECTINSTANCEW(pdidoi);

View file

@ -93,10 +93,6 @@ static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(SysMouseImpl
static int dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam );
const GUID DInput_Wine_Mouse_GUID = { /* 9e573ed8-7734-11d2-8d4a-23903fb6bdf7 */
0x9e573ed8, 0x7734, 0x11d2, {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
};
static void _dump_mouse_state(const DIMOUSESTATE2 *m_state)
{
int i;
@ -121,7 +117,7 @@ static void fill_mouse_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD versio
ddi.dwSize = dwSize;
ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */
ddi.guidProduct = DInput_Wine_Mouse_GUID; /* Vendor's GUID */
ddi.guidProduct = GUID_SysMouse;
if (version >= 0x0800)
ddi.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
else
@ -145,7 +141,7 @@ static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD versio
ddi.dwSize = dwSize;
ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */
ddi.guidProduct = DInput_Wine_Mouse_GUID; /* Vendor's GUID */
ddi.guidProduct = GUID_SysMouse;
if (version >= 0x0800)
ddi.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
else
@ -257,8 +253,7 @@ static HRESULT mousedev_create_device(IDirectInputImpl *dinput, REFGUID rguid, R
TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode);
*pdev = NULL;
if (IsEqualGUID(&GUID_SysMouse, rguid) || /* Generic Mouse */
IsEqualGUID(&DInput_Wine_Mouse_GUID, rguid)) /* Wine Mouse */
if (IsEqualGUID(&GUID_SysMouse, rguid)) /* Wine Mouse */
{
SysMouseImpl *This;

View file

@ -0,0 +1,26 @@
/*
* Copyright 2001 Ove Kaaven
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define WINE_FILEDESCRIPTION_STR "Wine DirectInput"
#define WINE_FILENAME_STR "dinput.dll"
#define WINE_FILEVERSION 5,1,2600,881
#define WINE_FILEVERSION_STR "5.1.2600.881"
#define WINE_PRODUCTVERSION 5,1,2600,881
#define WINE_PRODUCTVERSION_STR "5.1"
#include "wine/wine_common_ver.rc"

View file

@ -30,7 +30,7 @@ reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to WineStaging-4.0
reactos/dll/directx/wine/d3dxof # Synced to WineStaging-3.17
reactos/dll/directx/wine/ddraw # Synced to WineStaging-3.9
reactos/dll/directx/wine/devenum # Synced to WineStaging-3.9
reactos/dll/directx/wine/dinput # Synced to WineStaging-3.17
reactos/dll/directx/wine/dinput # Synced to WineStaging-4.0
reactos/dll/directx/wine/dinput8 # Synced to WineStaging-3.3
reactos/dll/directx/wine/dmusic # Synced to WineStaging-3.17
reactos/dll/directx/wine/dplay # Synced to WineStaging-3.3