Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_linux.c | 21 +++++++-------------- dlls/dinput/joystick_linuxinput.c | 15 ++++++++------- dlls/dinput/joystick_osx.c | 21 +++++++-------------- dlls/dinput/keyboard.c | 15 +++++++++------ dlls/dinput/mouse.c | 16 +++++++++------- 5 files changed, 40 insertions(+), 48 deletions(-)
diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index a33b16454b0..14074bb176c 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -451,8 +451,7 @@ static HRESULT joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS return S_FALSE; }
-static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput, - JoystickImpl **pdev, unsigned short index) +static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, JoystickImpl **out, unsigned short index ) { DWORD i; JoystickImpl* newDevice; @@ -461,14 +460,10 @@ static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput, int idx = 0; DIDEVICEINSTANCEW ddi;
- TRACE("%s %p %p %hu\n", debugstr_guid(rguid), dinput, pdev, index); + TRACE( "%s %p %p %hu\n", debugstr_guid( rguid ), dinput, out, index );
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl)); - if (newDevice == 0) { - WARN("out of memory\n"); - *pdev = 0; - return DIERR_OUTOFMEMORY; - } + if (!newDevice) return DIERR_OUTOFMEMORY;
newDevice->joydev = &joystick_devices[index]; newDevice->joyfd = -1; @@ -564,8 +559,7 @@ static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput, _dump_DIDEVCAPS(&newDevice->generic.devcaps); }
- *pdev = newDevice; - + *out = newDevice; return DI_OK;
FAILED: @@ -576,8 +570,6 @@ FAILED1: release_DataFormat(&newDevice->generic.base.data_format); HeapFree(GetProcessHeap(),0,newDevice->generic.axis_map); HeapFree(GetProcessHeap(),0,newDevice); - *pdev = 0; - return hr; }
@@ -641,8 +633,9 @@ static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REF return DIERR_NOINTERFACE; }
- hr = alloc_device(rguid, dinput, &This, index); - if (!This) return hr; + 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; diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 2e2c8a87261..95b2df81ece 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -444,7 +444,7 @@ static HRESULT joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS return S_FALSE; }
-static JoystickImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput, unsigned short index) +static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, JoystickImpl **out, unsigned short index ) { JoystickImpl* newDevice; LPDIDATAFORMAT df = NULL; @@ -453,7 +453,7 @@ static JoystickImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput, unsig DIDEVICEINSTANCEW ddi;
newDevice = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(JoystickImpl)); - if (!newDevice) return NULL; + if (!newDevice) return DIERR_OUTOFMEMORY;
newDevice->generic.base.IDirectInputDevice8A_iface.lpVtbl = &JoystickAvt; newDevice->generic.base.IDirectInputDevice8W_iface.lpVtbl = &JoystickWvt; @@ -584,14 +584,15 @@ static JoystickImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput, unsig
IDirectInput_AddRef(&newDevice->generic.base.dinput->IDirectInput7A_iface);
- return newDevice; + *out = newDevice; + return DI_OK;
failed: if (df) HeapFree(GetProcessHeap(), 0, df->rgodf); HeapFree(GetProcessHeap(), 0, df); HeapFree(GetProcessHeap(), 0, newDevice->generic.axis_map); HeapFree(GetProcessHeap(), 0, newDevice); - return NULL; + return DIERR_OUTOFMEMORY; }
/****************************************************************************** @@ -630,6 +631,7 @@ static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REF have_joydevs && index < have_joydevs) { JoystickImpl *This; + HRESULT hr;
if (riid == NULL) ;/* nothing */ @@ -653,10 +655,9 @@ static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REF return DIERR_NOINTERFACE; }
- This = alloc_device(rguid, dinput, index); - TRACE("Created a Joystick device (%p)\n", This); + if (FAILED(hr = alloc_device( rguid, dinput, &This, index ))) return hr;
- if (!This) return DIERR_OUTOFMEMORY; + TRACE( "Created a Joystick device (%p)\n", This );
if (unicode) *pdev = &This->generic.base.IDirectInputDevice8W_iface; diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c index e2212557180..65d0a4a36eb 100644 --- a/dlls/dinput/joystick_osx.c +++ b/dlls/dinput/joystick_osx.c @@ -1105,8 +1105,7 @@ static BOOL osx_axis_has_ff(FFCAPABILITIES *ffcaps, UInt8 axis) return FALSE; }
-static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput, - JoystickImpl **pdev, unsigned short index) +static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, JoystickImpl **out, unsigned short index ) { DWORD i; IOHIDDeviceRef device; @@ -1119,14 +1118,10 @@ static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput, int slider_count = 0; FFCAPABILITIES ffcaps;
- TRACE("%s %p %p %hu\n", debugstr_guid(rguid), dinput, pdev, index); + TRACE( "%s %p %p %hu\n", debugstr_guid( rguid ), dinput, out, index );
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl)); - if (newDevice == 0) { - WARN("out of memory\n"); - *pdev = 0; - return DIERR_OUTOFMEMORY; - } + if (!newDevice) return DIERR_OUTOFMEMORY;
newDevice->id = index;
@@ -1287,8 +1282,7 @@ static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput, _dump_DIDEVCAPS(&newDevice->generic.devcaps); }
- *pdev = newDevice; - + *out = newDevice; return DI_OK;
FAILED: @@ -1300,8 +1294,6 @@ FAILED: release_DataFormat(&newDevice->generic.base.data_format); HeapFree(GetProcessHeap(),0,newDevice->generic.name); HeapFree(GetProcessHeap(),0,newDevice); - *pdev = 0; - return hr; }
@@ -1380,8 +1372,9 @@ static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REF return DIERR_NOINTERFACE; }
- hr = alloc_device(rguid, dinput, &This, index); - if (!This) return hr; + 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; diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index 9d4ceda3edc..e9fa9eb8cbc 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -240,13 +240,15 @@ static HRESULT keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVI return S_FALSE; }
-static SysKeyboardImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput) +static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, SysKeyboardImpl **out ) { SysKeyboardImpl* newDevice; LPDIDATAFORMAT df = NULL; int i, idx = 0;
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl)); + if (!newDevice) return DIERR_OUTOFMEMORY; + newDevice->base.IDirectInputDevice8A_iface.lpVtbl = &SysKeyboardAvt; newDevice->base.IDirectInputDevice8W_iface.lpVtbl = &SysKeyboardWvt; newDevice->base.ref = 1; @@ -278,13 +280,14 @@ static SysKeyboardImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput) newDevice->base.data_format.wine_df = df; IDirectInput_AddRef(&newDevice->base.dinput->IDirectInput7A_iface);
- return newDevice; + *out = newDevice; + return DI_OK;
failed: if (df) HeapFree(GetProcessHeap(), 0, df->rgodf); HeapFree(GetProcessHeap(), 0, df); HeapFree(GetProcessHeap(), 0, newDevice); - return NULL; + return DIERR_OUTOFMEMORY; }
@@ -296,6 +299,7 @@ static HRESULT keyboarddev_create_device(IDirectInputImpl *dinput, REFGUID rguid if (IsEqualGUID(&GUID_SysKeyboard, rguid)) /* Wine Keyboard */ { SysKeyboardImpl *This; + HRESULT hr;
if (riid == NULL) ;/* nothing */ @@ -319,10 +323,9 @@ static HRESULT keyboarddev_create_device(IDirectInputImpl *dinput, REFGUID rguid return DIERR_NOINTERFACE; }
- This = alloc_device(rguid, dinput); - TRACE("Created a Keyboard device (%p)\n", This); + if (FAILED(hr = alloc_device( rguid, dinput, &This ))) return hr;
- if (!This) return DIERR_OUTOFMEMORY; + TRACE( "Created a Keyboard device (%p)\n", This );
if (unicode) *pdev = &This->base.IDirectInputDevice8W_iface; diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index e5bd697a0ea..e789d260e5a 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -184,7 +184,7 @@ static HRESULT mousedev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEI return S_FALSE; }
-static SysMouseImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput) +static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, SysMouseImpl **out ) { SysMouseImpl* newDevice; LPDIDATAFORMAT df = NULL; @@ -193,7 +193,8 @@ static SysMouseImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput) HKEY hkey, appkey;
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseImpl)); - if (!newDevice) return NULL; + if (!newDevice) return DIERR_OUTOFMEMORY; + newDevice->base.IDirectInputDevice8A_iface.lpVtbl = &SysMouseAvt; newDevice->base.IDirectInputDevice8W_iface.lpVtbl = &SysMouseWvt; newDevice->base.ref = 1; @@ -237,13 +238,14 @@ static SysMouseImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput) newDevice->base.raw_device.usUsage = 2; /* HID generic mouse */ }
- return newDevice; + *out = newDevice; + return DI_OK;
failed: if (df) HeapFree(GetProcessHeap(), 0, df->rgodf); HeapFree(GetProcessHeap(), 0, df); HeapFree(GetProcessHeap(), 0, newDevice); - return NULL; + return DIERR_OUTOFMEMORY; }
static HRESULT mousedev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode) @@ -254,6 +256,7 @@ static HRESULT mousedev_create_device(IDirectInputImpl *dinput, REFGUID rguid, R if (IsEqualGUID(&GUID_SysMouse, rguid)) /* Wine Mouse */ { SysMouseImpl *This; + HRESULT hr;
if (riid == NULL) ;/* nothing */ @@ -277,10 +280,9 @@ static HRESULT mousedev_create_device(IDirectInputImpl *dinput, REFGUID rguid, R return DIERR_NOINTERFACE; }
- This = alloc_device(rguid, dinput); - TRACE("Created a Mouse device (%p)\n", This); + if (FAILED(hr = alloc_device( rguid, dinput, &This ))) return hr;
- if (!This) return DIERR_OUTOFMEMORY; + TRACE( "Created a Mouse device (%p)\n", This );
if (unicode) *pdev = &This->base.IDirectInputDevice8W_iface;
To factor out device allocation and initialization.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 20 ++++++++++++++++++++ dlls/dinput/device_private.h | 4 ++++ dlls/dinput/joystick_linux.c | 15 +++------------ dlls/dinput/joystick_linuxinput.c | 15 ++++----------- dlls/dinput/joystick_osx.c | 15 +++------------ dlls/dinput/keyboard.c | 14 ++++---------- dlls/dinput/mouse.c | 15 ++++----------- 7 files changed, 42 insertions(+), 56 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 5da58b85126..a5dfc78370c 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1703,3 +1703,23 @@ HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface
return DI_OK; } + +HRESULT direct_input_device_alloc( SIZE_T size, const IDirectInputDevice8WVtbl *vtblw, + const IDirectInputDevice8AVtbl *vtbla, const GUID *guid, + IDirectInputImpl *dinput, void **out ) +{ + IDirectInputDeviceImpl *This; + + if (!(This = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size ))) return DIERR_OUTOFMEMORY; + + This->IDirectInputDevice8A_iface.lpVtbl = vtbla; + This->IDirectInputDevice8W_iface.lpVtbl = vtblw; + This->ref = 1; + This->guid = *guid; + InitializeCriticalSection( &This->crit ); + This->dinput = dinput; + IDirectInput_AddRef( &dinput->IDirectInput7A_iface ); + + *out = This; + return DI_OK; +} diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h index e9168712fd9..b6c024def0d 100644 --- a/dlls/dinput/device_private.h +++ b/dlls/dinput/device_private.h @@ -86,6 +86,10 @@ struct IDirectInputDeviceImpl ActionMap *action_map; /* array of mappings */ };
+extern HRESULT direct_input_device_alloc( SIZE_T size, const IDirectInputDevice8WVtbl *vtblw, + const IDirectInputDevice8AVtbl *vtbla, const GUID *guid, + IDirectInputImpl *dinput, void **out ) DECLSPEC_HIDDEN; + extern BOOL get_app_key(HKEY*, HKEY*) DECLSPEC_HIDDEN; extern DWORD get_config_key(HKEY, HKEY, const char*, char*, DWORD) DECLSPEC_HIDDEN;
diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 14074bb176c..7151e6e676c 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -462,8 +462,9 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, JoystickIm
TRACE( "%s %p %p %hu\n", debugstr_guid( rguid ), dinput, out, index );
- newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl)); - if (!newDevice) return DIERR_OUTOFMEMORY; + if (FAILED(hr = direct_input_device_alloc( sizeof(JoystickImpl), &JoystickWvt, &JoystickAvt, rguid, dinput, (void **)&newDevice ))) + return hr; + newDevice->generic.base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->generic.base.crit");
newDevice->joydev = &joystick_devices[index]; newDevice->joyfd = -1; @@ -481,14 +482,6 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, JoystickIm newDevice->generic.devcaps.dwButtons = 128; }
- newDevice->generic.base.IDirectInputDevice8A_iface.lpVtbl = &JoystickAvt; - newDevice->generic.base.IDirectInputDevice8W_iface.lpVtbl = &JoystickWvt; - newDevice->generic.base.ref = 1; - newDevice->generic.base.dinput = dinput; - newDevice->generic.base.guid = *rguid; - InitializeCriticalSection(&newDevice->generic.base.crit); - newDevice->generic.base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->generic.base.crit"); - /* setup_dinput_options may change these */ newDevice->generic.deadzone = 0;
@@ -537,8 +530,6 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, JoystickIm newDevice->generic.props[i].lSaturation = 0; }
- IDirectInput_AddRef(&newDevice->generic.base.dinput->IDirectInput7A_iface); - newDevice->generic.devcaps.dwSize = sizeof(newDevice->generic.devcaps); newDevice->generic.devcaps.dwFlags = DIDC_ATTACHED;
diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 95b2df81ece..1b581f511ed 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -451,15 +451,12 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, JoystickIm int i, idx = 0; int default_axis_map[WINE_JOYSTICK_MAX_AXES + WINE_JOYSTICK_MAX_POVS*2]; DIDEVICEINSTANCEW ddi; + HRESULT hr;
- newDevice = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(JoystickImpl)); - if (!newDevice) return DIERR_OUTOFMEMORY; + if (FAILED(hr = direct_input_device_alloc( sizeof(JoystickImpl), &JoystickWvt, &JoystickAvt, rguid, dinput, (void **)&newDevice ))) + return hr; + newDevice->generic.base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->base.crit");
- newDevice->generic.base.IDirectInputDevice8A_iface.lpVtbl = &JoystickAvt; - newDevice->generic.base.IDirectInputDevice8W_iface.lpVtbl = &JoystickWvt; - newDevice->generic.base.ref = 1; - newDevice->generic.base.guid = *rguid; - newDevice->generic.base.dinput = dinput; newDevice->generic.joy_polldev = joy_polldev; newDevice->joyfd = -1; newDevice->joydev = &joydevs[index]; @@ -473,8 +470,6 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, JoystickIm enabled. */ newDevice->ff_autocenter = 1; newDevice->ff_gain = 0xFFFF; - InitializeCriticalSection(&newDevice->generic.base.crit); - newDevice->generic.base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->base.crit");
/* Count number of available axes - supported Axis & POVs */ for (i = 0; i < ABS_MAX; i++) @@ -582,8 +577,6 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, JoystickIm if (newDevice->joydev->has_ff) newDevice->generic.devcaps.dwFlags |= DIDC_FORCEFEEDBACK;
- IDirectInput_AddRef(&newDevice->generic.base.dinput->IDirectInput7A_iface); - *out = newDevice; return DI_OK;
diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c index 65d0a4a36eb..bd758fb10a4 100644 --- a/dlls/dinput/joystick_osx.c +++ b/dlls/dinput/joystick_osx.c @@ -1120,8 +1120,9 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, JoystickIm
TRACE( "%s %p %p %hu\n", debugstr_guid( rguid ), dinput, out, index );
- newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl)); - if (!newDevice) return DIERR_OUTOFMEMORY; + if (FAILED(hr = direct_input_device_alloc( sizeof(JoystickImpl), &JoystickWvt, &JoystickAvt, rguid, dinput, (void **)&newDevice ))) + return hr; + newDevice->generic.base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->generic.base.crit");
newDevice->id = index;
@@ -1183,14 +1184,6 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, JoystickIm newDevice->generic.devcaps.dwButtons = 128; }
- newDevice->generic.base.IDirectInputDevice8A_iface.lpVtbl = &JoystickAvt; - newDevice->generic.base.IDirectInputDevice8W_iface.lpVtbl = &JoystickWvt; - newDevice->generic.base.ref = 1; - newDevice->generic.base.dinput = dinput; - newDevice->generic.base.guid = *rguid; - InitializeCriticalSection(&newDevice->generic.base.crit); - newDevice->generic.base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->generic.base.crit"); - /* Create copy of default data format */ if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIJoystick2.dwSize))) goto FAILED; memcpy(df, &c_dfDIJoystick2, c_dfDIJoystick2.dwSize); @@ -1262,8 +1255,6 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, JoystickIm /* initialize default properties */ get_osx_device_elements_props(newDevice);
- IDirectInput_AddRef(&newDevice->generic.base.dinput->IDirectInput7A_iface); - newDevice->generic.devcaps.dwSize = sizeof(newDevice->generic.devcaps); newDevice->generic.devcaps.dwFlags |= DIDC_ATTACHED; if (newDevice->generic.base.dinput->dwVersion >= 0x0800) diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index e9fa9eb8cbc..b8d48513faf 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -245,17 +245,12 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, SysKeyboar SysKeyboardImpl* newDevice; LPDIDATAFORMAT df = NULL; int i, idx = 0; + HRESULT hr;
- newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl)); - if (!newDevice) return DIERR_OUTOFMEMORY; - - newDevice->base.IDirectInputDevice8A_iface.lpVtbl = &SysKeyboardAvt; - newDevice->base.IDirectInputDevice8W_iface.lpVtbl = &SysKeyboardWvt; - newDevice->base.ref = 1; - memcpy(&newDevice->base.guid, rguid, sizeof(*rguid)); - newDevice->base.dinput = dinput; - InitializeCriticalSection(&newDevice->base.crit); + if (FAILED(hr = direct_input_device_alloc( sizeof(SysKeyboardImpl), &SysKeyboardWvt, &SysKeyboardAvt, rguid, dinput, (void **)&newDevice ))) + return hr; newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysKeyboardImpl*->base.crit"); + newDevice->subtype = get_keyboard_subtype();
/* Create copy of default data format */ @@ -278,7 +273,6 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, SysKeyboar df->dwNumObjs = idx;
newDevice->base.data_format.wine_df = df; - IDirectInput_AddRef(&newDevice->base.dinput->IDirectInput7A_iface);
*out = newDevice; return DI_OK; diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index e789d260e5a..7cf196d0173 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -191,18 +191,13 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, SysMouseIm unsigned i; char buffer[20]; HKEY hkey, appkey; + HRESULT hr;
- newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseImpl)); - if (!newDevice) return DIERR_OUTOFMEMORY; + if (FAILED(hr = direct_input_device_alloc( sizeof(SysMouseImpl), &SysMouseWvt, &SysMouseAvt, rguid, dinput, (void **)&newDevice ))) + return hr; + newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysMouseImpl*->base.crit");
- newDevice->base.IDirectInputDevice8A_iface.lpVtbl = &SysMouseAvt; - newDevice->base.IDirectInputDevice8W_iface.lpVtbl = &SysMouseWvt; - newDevice->base.ref = 1; newDevice->base.dwCoopLevel = DISCL_NONEXCLUSIVE | DISCL_BACKGROUND; - newDevice->base.guid = *rguid; - InitializeCriticalSection(&newDevice->base.crit); - newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysMouseImpl*->base.crit"); - newDevice->base.dinput = dinput;
get_app_key(&hkey, &appkey); if (!get_config_key(hkey, appkey, "MouseWarpOverride", buffer, sizeof(buffer))) @@ -229,8 +224,6 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, SysMouseIm df->rgodf[i].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_PSHBUTTON;
newDevice->base.data_format.wine_df = df; - IDirectInput_AddRef(&newDevice->base.dinput->IDirectInput7A_iface); - if (dinput->dwVersion >= 0x0800) { newDevice->base.use_raw_input = TRUE;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/ansi.c | 127 ++++++++++++++++++++---------- dlls/dinput/device.c | 11 +-- dlls/dinput/device_private.h | 68 +--------------- dlls/dinput/joystick_linux.c | 39 +-------- dlls/dinput/joystick_linuxinput.c | 40 +--------- dlls/dinput/joystick_osx.c | 39 +-------- dlls/dinput/keyboard.c | 39 +-------- dlls/dinput/mouse.c | 39 +-------- 8 files changed, 96 insertions(+), 306 deletions(-)
diff --git a/dlls/dinput/ansi.c b/dlls/dinput/ansi.c index 77b535746a2..910940f3257 100644 --- a/dlls/dinput/ansi.c +++ b/dlls/dinput/ansi.c @@ -202,28 +202,28 @@ static void dideviceimageinfoheader_wtoa( const DIDEVICEIMAGEINFOHEADERW *in, DI } }
-HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface( IDirectInputDevice8A *iface_a, REFIID iid, void **out ) +static HRESULT WINAPI dinput_device_a_QueryInterface( IDirectInputDevice8A *iface_a, REFIID iid, void **out ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_QueryInterface( iface_w, iid, out ); }
-ULONG WINAPI IDirectInputDevice2AImpl_AddRef( IDirectInputDevice8A *iface_a ) +static ULONG WINAPI dinput_device_a_AddRef( IDirectInputDevice8A *iface_a ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_AddRef( iface_w ); }
-ULONG WINAPI IDirectInputDevice2AImpl_Release( IDirectInputDevice8A *iface_a ) +static ULONG WINAPI dinput_device_a_Release( IDirectInputDevice8A *iface_a ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_Release( iface_w ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_GetCapabilities( IDirectInputDevice8A *iface_a, DIDEVCAPS *caps ) +static HRESULT WINAPI dinput_device_a_GetCapabilities( IDirectInputDevice8A *iface_a, DIDEVCAPS *caps ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); @@ -245,8 +245,8 @@ static BOOL CALLBACK enum_objects_wtoa_callback( const DIDEVICEOBJECTINSTANCEW * return params->callback( &instance_a, params->ref ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects( IDirectInputDevice8A *iface_a, LPDIENUMDEVICEOBJECTSCALLBACKA callback, - void *ref, DWORD flags ) +static HRESULT WINAPI dinput_device_a_EnumObjects( IDirectInputDevice8A *iface_a, LPDIENUMDEVICEOBJECTSCALLBACKA callback, + void *ref, DWORD flags ) { struct enum_objects_wtoa_params params = {callback, ref}; IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); @@ -257,72 +257,72 @@ HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects( IDirectInputDevice8A *iface return IDirectInputDevice8_EnumObjects( iface_w, enum_objects_wtoa_callback, ¶ms, flags ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty( IDirectInputDevice8A *iface_a, REFGUID guid, DIPROPHEADER *header ) +static HRESULT WINAPI dinput_device_a_GetProperty( IDirectInputDevice8A *iface_a, REFGUID guid, DIPROPHEADER *header ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_GetProperty( iface_w, guid, header ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_SetProperty( IDirectInputDevice8A *iface_a, REFGUID guid, const DIPROPHEADER *header ) +static HRESULT WINAPI dinput_device_a_SetProperty( IDirectInputDevice8A *iface_a, REFGUID guid, const DIPROPHEADER *header ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_SetProperty( iface_w, guid, header ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_Acquire( IDirectInputDevice8A *iface_a ) +static HRESULT WINAPI dinput_device_a_Acquire( IDirectInputDevice8A *iface_a ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_Acquire( iface_w ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_Unacquire( IDirectInputDevice8A *iface_a ) +static HRESULT WINAPI dinput_device_a_Unacquire( IDirectInputDevice8A *iface_a ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_Unacquire( iface_w ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceState( IDirectInputDevice8A *iface_a, DWORD count, void *data ) +static HRESULT WINAPI dinput_device_a_GetDeviceState( IDirectInputDevice8A *iface_a, DWORD count, void *data ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_GetDeviceState( iface_w, count, data ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceData( IDirectInputDevice8A *iface_a, DWORD data_size, DIDEVICEOBJECTDATA *data, - DWORD *entries, DWORD flags ) +static HRESULT WINAPI dinput_device_a_GetDeviceData( IDirectInputDevice8A *iface_a, DWORD data_size, DIDEVICEOBJECTDATA *data, + DWORD *entries, DWORD flags ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_GetDeviceData( iface_w, data_size, data, entries, flags ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat( IDirectInputDevice8A *iface_a, const DIDATAFORMAT *format ) +static HRESULT WINAPI dinput_device_a_SetDataFormat( IDirectInputDevice8A *iface_a, const DIDATAFORMAT *format ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_SetDataFormat( iface_w, format ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification( IDirectInputDevice8A *iface_a, HANDLE event ) +static HRESULT WINAPI dinput_device_a_SetEventNotification( IDirectInputDevice8A *iface_a, HANDLE event ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_SetEventNotification( iface_w, event ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel( IDirectInputDevice8A *iface_a, HWND window, DWORD flags ) +static HRESULT WINAPI dinput_device_a_SetCooperativeLevel( IDirectInputDevice8A *iface_a, HWND window, DWORD flags ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_SetCooperativeLevel( iface_w, window, flags ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo( IDirectInputDevice8A *iface_a, DIDEVICEOBJECTINSTANCEA *instance_a, - DWORD obj, DWORD how ) +static HRESULT WINAPI dinput_device_a_GetObjectInfo( IDirectInputDevice8A *iface_a, DIDEVICEOBJECTINSTANCEA *instance_a, + DWORD obj, DWORD how ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); @@ -340,7 +340,7 @@ HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo( IDirectInputDevice8A *ifa return hr; }
-HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo( IDirectInputDevice8A *iface_a, DIDEVICEINSTANCEA *instance_a ) +static HRESULT WINAPI dinput_device_a_GetDeviceInfo( IDirectInputDevice8A *iface_a, DIDEVICEINSTANCEA *instance_a ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); @@ -357,22 +357,22 @@ HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo( IDirectInputDevice8A *ifa return hr; }
-HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel( IDirectInputDevice8A *iface_a, HWND owner, DWORD flags ) +static HRESULT WINAPI dinput_device_a_RunControlPanel( IDirectInputDevice8A *iface_a, HWND owner, DWORD flags ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_RunControlPanel( iface_w, owner, flags ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_Initialize( IDirectInputDevice8A *iface_a, HINSTANCE instance, DWORD version, REFGUID guid ) +static HRESULT WINAPI dinput_device_a_Initialize( IDirectInputDevice8A *iface_a, HINSTANCE instance, DWORD version, REFGUID guid ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_Initialize( iface_w, instance, version, guid ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect( IDirectInputDevice8A *iface_a, REFGUID guid, const DIEFFECT *effect, - IDirectInputEffect **out, IUnknown *outer ) +static HRESULT WINAPI dinput_device_a_CreateEffect( IDirectInputDevice8A *iface_a, REFGUID guid, const DIEFFECT *effect, + IDirectInputEffect **out, IUnknown *outer ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); @@ -394,8 +394,8 @@ static BOOL CALLBACK enum_effects_wtoa_callback( const DIEFFECTINFOW *info_w, vo return params->callback( &info_a, params->ref ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects( IDirectInputDevice8A *iface_a, LPDIENUMEFFECTSCALLBACKA callback, - void *ref, DWORD type ) +static HRESULT WINAPI dinput_device_a_EnumEffects( IDirectInputDevice8A *iface_a, LPDIENUMEFFECTSCALLBACKA callback, + void *ref, DWORD type ) { struct enum_effects_wtoa_params params = {callback, ref}; IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); @@ -406,7 +406,7 @@ HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects( IDirectInputDevice8A *iface return IDirectInputDevice8_EnumEffects( iface_w, enum_effects_wtoa_callback, ¶ms, type ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo( IDirectInputDevice8A *iface_a, DIEFFECTINFOA *info_a, REFGUID guid ) +static HRESULT WINAPI dinput_device_a_GetEffectInfo( IDirectInputDevice8A *iface_a, DIEFFECTINFOA *info_a, REFGUID guid ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); @@ -422,52 +422,52 @@ HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo( IDirectInputDevice8A *ifa return hr; }
-HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState( IDirectInputDevice8A *iface_a, DWORD *state ) +static HRESULT WINAPI dinput_device_a_GetForceFeedbackState( IDirectInputDevice8A *iface_a, DWORD *state ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_GetForceFeedbackState( iface_w, state ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand( IDirectInputDevice8A *iface_a, DWORD flags ) +static HRESULT WINAPI dinput_device_a_SendForceFeedbackCommand( IDirectInputDevice8A *iface_a, DWORD flags ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_SendForceFeedbackCommand( iface_w, flags ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects( IDirectInputDevice8A *iface_a, LPDIENUMCREATEDEFFECTOBJECTSCALLBACK callback, - void *ref, DWORD flags ) +static HRESULT WINAPI dinput_device_a_EnumCreatedEffectObjects( IDirectInputDevice8A *iface_a, LPDIENUMCREATEDEFFECTOBJECTSCALLBACK callback, + void *ref, DWORD flags ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_EnumCreatedEffectObjects( iface_w, callback, ref, flags ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_Escape( IDirectInputDevice8A *iface_a, DIEFFESCAPE *escape ) +static HRESULT WINAPI dinput_device_a_Escape( IDirectInputDevice8A *iface_a, DIEFFESCAPE *escape ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_Escape( iface_w, escape ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_Poll( IDirectInputDevice8A *iface_a ) +static HRESULT WINAPI dinput_device_a_Poll( IDirectInputDevice8A *iface_a ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_Poll( iface_w ); }
-HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData( IDirectInputDevice8A *iface_a, DWORD count, const DIDEVICEOBJECTDATA *data, - DWORD *inout, DWORD flags ) +static HRESULT WINAPI dinput_device_a_SendDeviceData( IDirectInputDevice8A *iface_a, DWORD count, const DIDEVICEOBJECTDATA *data, + DWORD *inout, DWORD flags ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_SendDeviceData( iface_w, count, data, inout, flags ); }
-HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile( IDirectInputDevice8A *iface_a, const char *filename_a, LPDIENUMEFFECTSINFILECALLBACK callback, - void *ref, DWORD flags ) +static HRESULT WINAPI dinput_device_a_EnumEffectsInFile( IDirectInputDevice8A *iface_a, const char *filename_a, LPDIENUMEFFECTSINFILECALLBACK callback, + void *ref, DWORD flags ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); @@ -479,8 +479,8 @@ HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile( IDirectInputDevice8A return IDirectInputDevice8_EnumEffectsInFile( iface_w, filename_w, callback, ref, flags ); }
-HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile( IDirectInputDevice8A *iface_a, const char *filename_a, DWORD entries, - DIFILEEFFECT *file_effect, DWORD flags ) +static HRESULT WINAPI dinput_device_a_WriteEffectToFile( IDirectInputDevice8A *iface_a, const char *filename_a, DWORD entries, + DIFILEEFFECT *file_effect, DWORD flags ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); @@ -492,8 +492,8 @@ HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile( IDirectInputDevice8A return IDirectInputDevice8_WriteEffectToFile( iface_w, filename_w, entries, file_effect, flags ); }
-HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap( IDirectInputDevice8A *iface_a, DIACTIONFORMATA *format_a, - const char *username_a, DWORD flags ) +static HRESULT WINAPI dinput_device_a_BuildActionMap( IDirectInputDevice8A *iface_a, DIACTIONFORMATA *format_a, + const char *username_a, DWORD flags ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); @@ -521,8 +521,8 @@ HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap( IDirectInputDevice8A *if return hr; }
-HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap( IDirectInputDevice8A *iface_a, DIACTIONFORMATA *format_a, - const char *username_a, DWORD flags ) +static HRESULT WINAPI dinput_device_a_SetActionMap( IDirectInputDevice8A *iface_a, DIACTIONFORMATA *format_a, + const char *username_a, DWORD flags ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); @@ -550,7 +550,7 @@ HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap( IDirectInputDevice8A *ifac return hr; }
-HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo( IDirectInputDevice8A *iface_a, DIDEVICEIMAGEINFOHEADERA *header_a ) +static HRESULT WINAPI dinput_device_a_GetImageInfo( IDirectInputDevice8A *iface_a, DIDEVICEIMAGEINFOHEADERA *header_a ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); @@ -570,3 +570,44 @@ HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo( IDirectInputDevice8A *ifac HeapFree( GetProcessHeap(), 0, header_w.lprgImageInfoArray ); return hr; } + +const IDirectInputDevice8AVtbl dinput_device_a_vtbl = +{ + /*** IUnknown methods ***/ + dinput_device_a_QueryInterface, + dinput_device_a_AddRef, + dinput_device_a_Release, + /*** IDirectInputDeviceA methods ***/ + dinput_device_a_GetCapabilities, + dinput_device_a_EnumObjects, + dinput_device_a_GetProperty, + dinput_device_a_SetProperty, + dinput_device_a_Acquire, + dinput_device_a_Unacquire, + dinput_device_a_GetDeviceState, + dinput_device_a_GetDeviceData, + dinput_device_a_SetDataFormat, + dinput_device_a_SetEventNotification, + dinput_device_a_SetCooperativeLevel, + dinput_device_a_GetObjectInfo, + dinput_device_a_GetDeviceInfo, + dinput_device_a_RunControlPanel, + dinput_device_a_Initialize, + /*** IDirectInputDevice2A methods ***/ + dinput_device_a_CreateEffect, + dinput_device_a_EnumEffects, + dinput_device_a_GetEffectInfo, + dinput_device_a_GetForceFeedbackState, + dinput_device_a_SendForceFeedbackCommand, + dinput_device_a_EnumCreatedEffectObjects, + dinput_device_a_Escape, + dinput_device_a_Poll, + dinput_device_a_SendDeviceData, + /*** IDirectInputDevice7A methods ***/ + dinput_device_a_EnumEffectsInFile, + dinput_device_a_WriteEffectToFile, + /*** IDirectInputDevice8A methods ***/ + dinput_device_a_BuildActionMap, + dinput_device_a_SetActionMap, + dinput_device_a_GetImageInfo, +}; diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index a5dfc78370c..29a569ca9f1 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1704,16 +1704,13 @@ HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface return DI_OK; }
-HRESULT direct_input_device_alloc( SIZE_T size, const IDirectInputDevice8WVtbl *vtblw, - const IDirectInputDevice8AVtbl *vtbla, const GUID *guid, - IDirectInputImpl *dinput, void **out ) +HRESULT direct_input_device_alloc( SIZE_T size, const IDirectInputDevice8WVtbl *vtbl, + const GUID *guid, IDirectInputImpl *dinput, void **out ) { IDirectInputDeviceImpl *This; - if (!(This = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size ))) return DIERR_OUTOFMEMORY; - - This->IDirectInputDevice8A_iface.lpVtbl = vtbla; - This->IDirectInputDevice8W_iface.lpVtbl = vtblw; + This->IDirectInputDevice8A_iface.lpVtbl = &dinput_device_a_vtbl; + This->IDirectInputDevice8W_iface.lpVtbl = vtbl; This->ref = 1; This->guid = *guid; InitializeCriticalSection( &This->crit ); diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h index b6c024def0d..1811e0cc5a6 100644 --- a/dlls/dinput/device_private.h +++ b/dlls/dinput/device_private.h @@ -86,9 +86,9 @@ struct IDirectInputDeviceImpl ActionMap *action_map; /* array of mappings */ };
-extern HRESULT direct_input_device_alloc( SIZE_T size, const IDirectInputDevice8WVtbl *vtblw, - const IDirectInputDevice8AVtbl *vtbla, const GUID *guid, +extern HRESULT direct_input_device_alloc( SIZE_T size, const IDirectInputDevice8WVtbl *vtbl, const GUID *guid, IDirectInputImpl *dinput, void **out ) DECLSPEC_HIDDEN; +extern const IDirectInputDevice8AVtbl dinput_device_a_vtbl DECLSPEC_HIDDEN;
extern BOOL get_app_key(HKEY*, HKEY*) DECLSPEC_HIDDEN; extern DWORD get_config_key(HKEY, HKEY, const char*, char*, DWORD) DECLSPEC_HIDDEN; @@ -136,113 +136,55 @@ extern HRESULT _build_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW extern HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, LPCDIDATAFORMAT df) DECLSPEC_HIDDEN;
/* And the stubs */ -extern HRESULT WINAPI IDirectInputDevice2AImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_Acquire(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceState(LPDIRECTINPUTDEVICE8A iface, DWORD count, void *data) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(LPDIRECTINPUTDEVICE8A iface, LPCDIDATAFORMAT df) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_SetDataFormat(LPDIRECTINPUTDEVICE8W iface, LPCDIDATAFORMAT df) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8A iface, HWND hwnd, DWORD dwflags) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8W iface, HWND hwnd, DWORD dwflags) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(LPDIRECTINPUTDEVICE8A iface, HANDLE hnd) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_SetEventNotification(LPDIRECTINPUTDEVICE8W iface, HANDLE hnd) DECLSPEC_HIDDEN; -extern ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN; extern ULONG WINAPI IDirectInputDevice2WImpl_Release(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_GetCapabilities(LPDIRECTINPUTDEVICE8A iface, DIDEVCAPS *caps) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(LPDIRECTINPUTDEVICE8A iface, REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(LPDIRECTINPUTDEVICE8W iface, REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN; -extern ULONG WINAPI IDirectInputDevice2AImpl_AddRef(LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN; extern ULONG WINAPI IDirectInputDevice2WImpl_AddRef(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects( - LPDIRECTINPUTDEVICE8A iface, - LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, - LPVOID lpvRef, - DWORD dwFlags) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects( LPDIRECTINPUTDEVICE8W iface, LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID lpvRef, DWORD dwFlags) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER pdiph) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIPROPHEADER pdiph) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo( - LPDIRECTINPUTDEVICE8A iface, - LPDIDEVICEOBJECTINSTANCEA pdidoi, - DWORD dwObj, - DWORD dwHow) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8A iface, DIDEVICEINSTANCEA *instance ) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface, DWORD dodsize, LPDIDEVICEOBJECTDATA dod, - LPDWORD entries, DWORD flags) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceData(LPDIRECTINPUTDEVICE8W iface, DWORD dodsize, LPDIDEVICEOBJECTDATA dod, LPDWORD entries, DWORD flags) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(LPDIRECTINPUTDEVICE8A iface, HWND hwndOwner, DWORD dwFlags) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_RunControlPanel(LPDIRECTINPUTDEVICE8W iface, HWND hwndOwner, DWORD dwFlags) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_Initialize(LPDIRECTINPUTDEVICE8A iface, HINSTANCE hinst, DWORD dwVersion, - REFGUID rguid) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_Initialize(LPDIRECTINPUTDEVICE8W iface, HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIEFFECT lpeff, - LPDIRECTINPUTEFFECT *ppdef, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_CreateEffect(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdef, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects( - LPDIRECTINPUTDEVICE8A iface, - LPDIENUMEFFECTSCALLBACKA lpCallback, - LPVOID lpvRef, - DWORD dwFlags) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects( LPDIRECTINPUTDEVICE8W iface, LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID lpvRef, DWORD dwFlags) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo( - LPDIRECTINPUTDEVICE8A iface, - LPDIEFFECTINFOA lpdei, - REFGUID rguid) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo( LPDIRECTINPUTDEVICE8W iface, LPDIEFFECTINFOW lpdei, REFGUID rguid) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8A iface, LPDWORD pdwOut) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8W iface, LPDWORD pdwOut) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8A iface, DWORD dwFlags) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8W iface, DWORD dwFlags) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8A iface, - LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, - LPVOID lpvRef, DWORD dwFlags) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8W iface, LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID lpvRef, DWORD dwFlags) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_Escape(LPDIRECTINPUTDEVICE8A iface, LPDIEFFESCAPE lpDIEEsc) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_Escape(LPDIRECTINPUTDEVICE8W iface, LPDIEFFESCAPE lpDIEEsc) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_Poll(LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_Poll(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData(LPDIRECTINPUTDEVICE8A iface, DWORD cbObjectData, - LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_SendDeviceData(LPDIRECTINPUTDEVICE8W iface, DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A iface, - LPCSTR lpszFileName, - LPDIENUMEFFECTSINFILECALLBACK pec, - LPVOID pvRef, - DWORD dwFlags) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8W iface, LPCWSTR lpszFileName, LPDIENUMEFFECTSINFILECALLBACK pec, LPVOID pvRef, DWORD dwFlags) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface, - LPCSTR lpszFileName, - DWORD dwEntries, - LPDIFILEEFFECT rgDiFileEft, - DWORD dwFlags) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice7WImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8W iface, LPCWSTR lpszFileName, DWORD dwEntries, @@ -252,12 +194,6 @@ extern HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVIC LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap( LPDIRECTINPUTDEVICE8A iface, DIACTIONFORMATA *format, - const char *username, DWORD flags ) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap( LPDIRECTINPUTDEVICE8A iface, DIACTIONFORMATA *format, - const char *username, DWORD flags ) DECLSPEC_HIDDEN; -extern HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface, - LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader) DECLSPEC_HIDDEN;
diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 7151e6e676c..0c1560617dd 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -90,7 +90,6 @@ struct JoyDev };
typedef struct JoystickImpl JoystickImpl; -static const IDirectInputDevice8AVtbl JoystickAvt; static const IDirectInputDevice8WVtbl JoystickWvt; struct JoystickImpl { @@ -462,7 +461,7 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, JoystickIm
TRACE( "%s %p %p %hu\n", debugstr_guid( rguid ), dinput, out, index );
- if (FAILED(hr = direct_input_device_alloc( sizeof(JoystickImpl), &JoystickWvt, &JoystickAvt, rguid, dinput, (void **)&newDevice ))) + if (FAILED(hr = direct_input_device_alloc( sizeof(JoystickImpl), &JoystickWvt, rguid, dinput, (void **)&newDevice ))) return hr; newDevice->generic.base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->generic.base.crit");
@@ -862,42 +861,6 @@ static void joy_polldev( IDirectInputDevice8W *iface ) } }
-static const IDirectInputDevice8AVtbl JoystickAvt = -{ - IDirectInputDevice2AImpl_QueryInterface, - IDirectInputDevice2AImpl_AddRef, - IDirectInputDevice2AImpl_Release, - IDirectInputDevice2AImpl_GetCapabilities, - IDirectInputDevice2AImpl_EnumObjects, - IDirectInputDevice2AImpl_GetProperty, - IDirectInputDevice2AImpl_SetProperty, - IDirectInputDevice2AImpl_Acquire, - IDirectInputDevice2AImpl_Unacquire, - IDirectInputDevice2AImpl_GetDeviceState, - IDirectInputDevice2AImpl_GetDeviceData, - IDirectInputDevice2AImpl_SetDataFormat, - IDirectInputDevice2AImpl_SetEventNotification, - IDirectInputDevice2AImpl_SetCooperativeLevel, - IDirectInputDevice2AImpl_GetObjectInfo, - IDirectInputDevice2AImpl_GetDeviceInfo, - IDirectInputDevice2AImpl_RunControlPanel, - IDirectInputDevice2AImpl_Initialize, - IDirectInputDevice2AImpl_CreateEffect, - IDirectInputDevice2AImpl_EnumEffects, - IDirectInputDevice2AImpl_GetEffectInfo, - IDirectInputDevice2AImpl_GetForceFeedbackState, - IDirectInputDevice2AImpl_SendForceFeedbackCommand, - IDirectInputDevice2AImpl_EnumCreatedEffectObjects, - IDirectInputDevice2AImpl_Escape, - IDirectInputDevice2AImpl_Poll, - IDirectInputDevice2AImpl_SendDeviceData, - IDirectInputDevice7AImpl_EnumEffectsInFile, - IDirectInputDevice7AImpl_WriteEffectToFile, - IDirectInputDevice8AImpl_BuildActionMap, - IDirectInputDevice8AImpl_SetActionMap, - IDirectInputDevice8AImpl_GetImageInfo -}; - static const IDirectInputDevice8WVtbl JoystickWvt = { IDirectInputDevice2WImpl_QueryInterface, diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 1b581f511ed..3bc6114322f 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -86,12 +86,12 @@ struct wine_input_absinfo {
/* implemented in effect_linuxinput.c */ HRESULT linuxinput_create_effect(int* fd, REFGUID rguid, struct list *parent_list_entry, LPDIRECTINPUTEFFECT* peff); +HRESULT linuxinput_get_info_A(int fd, REFGUID rguid, LPDIEFFECTINFOA info); HRESULT linuxinput_get_info_W(int fd, REFGUID rguid, LPDIEFFECTINFOW info);
static HRESULT WINAPI JoystickWImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8W iface, DWORD dwFlags);
typedef struct JoystickImpl JoystickImpl; -static const IDirectInputDevice8AVtbl JoystickAvt; static const IDirectInputDevice8WVtbl JoystickWvt;
struct JoyDev { @@ -453,7 +453,7 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, JoystickIm DIDEVICEINSTANCEW ddi; HRESULT hr;
- if (FAILED(hr = direct_input_device_alloc( sizeof(JoystickImpl), &JoystickWvt, &JoystickAvt, rguid, dinput, (void **)&newDevice ))) + if (FAILED(hr = direct_input_device_alloc( sizeof(JoystickImpl), &JoystickWvt, rguid, dinput, (void **)&newDevice ))) return hr; newDevice->generic.base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->base.crit");
@@ -1302,42 +1302,6 @@ static HRESULT WINAPI JoystickWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, return DI_OK; }
-static const IDirectInputDevice8AVtbl JoystickAvt = -{ - IDirectInputDevice2AImpl_QueryInterface, - IDirectInputDevice2AImpl_AddRef, - IDirectInputDevice2AImpl_Release, - IDirectInputDevice2AImpl_GetCapabilities, - IDirectInputDevice2AImpl_EnumObjects, - IDirectInputDevice2AImpl_GetProperty, - IDirectInputDevice2AImpl_SetProperty, - IDirectInputDevice2AImpl_Acquire, - IDirectInputDevice2AImpl_Unacquire, - IDirectInputDevice2AImpl_GetDeviceState, - IDirectInputDevice2AImpl_GetDeviceData, - IDirectInputDevice2AImpl_SetDataFormat, - IDirectInputDevice2AImpl_SetEventNotification, - IDirectInputDevice2AImpl_SetCooperativeLevel, - IDirectInputDevice2AImpl_GetObjectInfo, - IDirectInputDevice2AImpl_GetDeviceInfo, - IDirectInputDevice2AImpl_RunControlPanel, - IDirectInputDevice2AImpl_Initialize, - IDirectInputDevice2AImpl_CreateEffect, - IDirectInputDevice2AImpl_EnumEffects, - IDirectInputDevice2AImpl_GetEffectInfo, - IDirectInputDevice2AImpl_GetForceFeedbackState, - IDirectInputDevice2AImpl_SendForceFeedbackCommand, - IDirectInputDevice2AImpl_EnumCreatedEffectObjects, - IDirectInputDevice2AImpl_Escape, - IDirectInputDevice2AImpl_Poll, - IDirectInputDevice2AImpl_SendDeviceData, - IDirectInputDevice7AImpl_EnumEffectsInFile, - IDirectInputDevice7AImpl_WriteEffectToFile, - IDirectInputDevice8AImpl_BuildActionMap, - IDirectInputDevice8AImpl_SetActionMap, - IDirectInputDevice8AImpl_GetImageInfo -}; - static const IDirectInputDevice8WVtbl JoystickWvt = { IDirectInputDevice2WImpl_QueryInterface, diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c index bd758fb10a4..e29a7bd9726 100644 --- a/dlls/dinput/joystick_osx.c +++ b/dlls/dinput/joystick_osx.c @@ -101,7 +101,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput); static CFMutableArrayRef device_main_elements = NULL;
typedef struct JoystickImpl JoystickImpl; -static const IDirectInputDevice8AVtbl JoystickAvt; static const IDirectInputDevice8WVtbl JoystickWvt;
struct JoystickImpl @@ -1120,7 +1119,7 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, JoystickIm
TRACE( "%s %p %p %hu\n", debugstr_guid( rguid ), dinput, out, index );
- if (FAILED(hr = direct_input_device_alloc( sizeof(JoystickImpl), &JoystickWvt, &JoystickAvt, rguid, dinput, (void **)&newDevice ))) + if (FAILED(hr = direct_input_device_alloc( sizeof(JoystickImpl), &JoystickWvt, rguid, dinput, (void **)&newDevice ))) return hr; newDevice->generic.base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->generic.base.crit");
@@ -1553,42 +1552,6 @@ const struct dinput_device joystick_osx_device = { joydev_create_device };
-static const IDirectInputDevice8AVtbl JoystickAvt = -{ - IDirectInputDevice2AImpl_QueryInterface, - IDirectInputDevice2AImpl_AddRef, - IDirectInputDevice2AImpl_Release, - IDirectInputDevice2AImpl_GetCapabilities, - IDirectInputDevice2AImpl_EnumObjects, - IDirectInputDevice2AImpl_GetProperty, - IDirectInputDevice2AImpl_SetProperty, - IDirectInputDevice2AImpl_Acquire, - IDirectInputDevice2AImpl_Unacquire, - IDirectInputDevice2AImpl_GetDeviceState, - IDirectInputDevice2AImpl_GetDeviceData, - IDirectInputDevice2AImpl_SetDataFormat, - IDirectInputDevice2AImpl_SetEventNotification, - IDirectInputDevice2AImpl_SetCooperativeLevel, - IDirectInputDevice2AImpl_GetObjectInfo, - IDirectInputDevice2AImpl_GetDeviceInfo, - IDirectInputDevice2AImpl_RunControlPanel, - IDirectInputDevice2AImpl_Initialize, - IDirectInputDevice2AImpl_CreateEffect, - IDirectInputDevice2AImpl_EnumEffects, - IDirectInputDevice2AImpl_GetEffectInfo, - IDirectInputDevice2AImpl_GetForceFeedbackState, - IDirectInputDevice2AImpl_SendForceFeedbackCommand, - IDirectInputDevice2AImpl_EnumCreatedEffectObjects, - IDirectInputDevice2AImpl_Escape, - IDirectInputDevice2AImpl_Poll, - IDirectInputDevice2AImpl_SendDeviceData, - IDirectInputDevice7AImpl_EnumEffectsInFile, - IDirectInputDevice7AImpl_WriteEffectToFile, - IDirectInputDevice8AImpl_BuildActionMap, - IDirectInputDevice8AImpl_SetActionMap, - IDirectInputDevice8AImpl_GetImageInfo -}; - static const IDirectInputDevice8WVtbl JoystickWvt = { IDirectInputDevice2WImpl_QueryInterface, diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index b8d48513faf..c64051e8663 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -40,7 +40,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput);
#define WINE_DINPUT_KEYBOARD_MAX_KEYS 256
-static const IDirectInputDevice8AVtbl SysKeyboardAvt; static const IDirectInputDevice8WVtbl SysKeyboardWvt;
typedef struct SysKeyboardImpl SysKeyboardImpl; @@ -247,7 +246,7 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, SysKeyboar int i, idx = 0; HRESULT hr;
- if (FAILED(hr = direct_input_device_alloc( sizeof(SysKeyboardImpl), &SysKeyboardWvt, &SysKeyboardAvt, rguid, dinput, (void **)&newDevice ))) + if (FAILED(hr = direct_input_device_alloc( sizeof(SysKeyboardImpl), &SysKeyboardWvt, rguid, dinput, (void **)&newDevice ))) return hr; newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysKeyboardImpl*->base.crit");
@@ -558,42 +557,6 @@ static HRESULT WINAPI SysKeyboardWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface, return _set_action_map(iface, lpdiaf, lpszUserName, dwFlags, &c_dfDIKeyboard); }
-static const IDirectInputDevice8AVtbl SysKeyboardAvt = -{ - IDirectInputDevice2AImpl_QueryInterface, - IDirectInputDevice2AImpl_AddRef, - IDirectInputDevice2AImpl_Release, - IDirectInputDevice2AImpl_GetCapabilities, - IDirectInputDevice2AImpl_EnumObjects, - IDirectInputDevice2AImpl_GetProperty, - IDirectInputDevice2AImpl_SetProperty, - IDirectInputDevice2AImpl_Acquire, - IDirectInputDevice2AImpl_Unacquire, - IDirectInputDevice2AImpl_GetDeviceState, - IDirectInputDevice2AImpl_GetDeviceData, - IDirectInputDevice2AImpl_SetDataFormat, - IDirectInputDevice2AImpl_SetEventNotification, - IDirectInputDevice2AImpl_SetCooperativeLevel, - IDirectInputDevice2AImpl_GetObjectInfo, - IDirectInputDevice2AImpl_GetDeviceInfo, - IDirectInputDevice2AImpl_RunControlPanel, - IDirectInputDevice2AImpl_Initialize, - IDirectInputDevice2AImpl_CreateEffect, - IDirectInputDevice2AImpl_EnumEffects, - IDirectInputDevice2AImpl_GetEffectInfo, - IDirectInputDevice2AImpl_GetForceFeedbackState, - IDirectInputDevice2AImpl_SendForceFeedbackCommand, - IDirectInputDevice2AImpl_EnumCreatedEffectObjects, - IDirectInputDevice2AImpl_Escape, - IDirectInputDevice2AImpl_Poll, - IDirectInputDevice2AImpl_SendDeviceData, - IDirectInputDevice7AImpl_EnumEffectsInFile, - IDirectInputDevice7AImpl_WriteEffectToFile, - IDirectInputDevice8AImpl_BuildActionMap, - IDirectInputDevice8AImpl_SetActionMap, - IDirectInputDevice8AImpl_GetImageInfo -}; - static const IDirectInputDevice8WVtbl SysKeyboardWvt = { IDirectInputDevice2WImpl_QueryInterface, diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index 7cf196d0173..ef503526c35 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -47,7 +47,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput); #define WINE_MOUSE_Z_AXIS_INSTANCE 2 #define WINE_MOUSE_BUTTONS_INSTANCE 3
-static const IDirectInputDevice8AVtbl SysMouseAvt; static const IDirectInputDevice8WVtbl SysMouseWvt;
typedef struct SysMouseImpl SysMouseImpl; @@ -193,7 +192,7 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, SysMouseIm HKEY hkey, appkey; HRESULT hr;
- if (FAILED(hr = direct_input_device_alloc( sizeof(SysMouseImpl), &SysMouseWvt, &SysMouseAvt, rguid, dinput, (void **)&newDevice ))) + if (FAILED(hr = direct_input_device_alloc( sizeof(SysMouseImpl), &SysMouseWvt, rguid, dinput, (void **)&newDevice ))) return hr; newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysMouseImpl*->base.crit");
@@ -809,42 +808,6 @@ static HRESULT WINAPI SysMouseWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface, return _set_action_map(iface, lpdiaf, lpszUserName, dwFlags, &c_dfDIMouse2); }
-static const IDirectInputDevice8AVtbl SysMouseAvt = -{ - IDirectInputDevice2AImpl_QueryInterface, - IDirectInputDevice2AImpl_AddRef, - IDirectInputDevice2AImpl_Release, - IDirectInputDevice2AImpl_GetCapabilities, - IDirectInputDevice2AImpl_EnumObjects, - IDirectInputDevice2AImpl_GetProperty, - IDirectInputDevice2AImpl_SetProperty, - IDirectInputDevice2AImpl_Acquire, - IDirectInputDevice2AImpl_Unacquire, - IDirectInputDevice2AImpl_GetDeviceState, - IDirectInputDevice2AImpl_GetDeviceData, - IDirectInputDevice2AImpl_SetDataFormat, - IDirectInputDevice2AImpl_SetEventNotification, - IDirectInputDevice2AImpl_SetCooperativeLevel, - IDirectInputDevice2AImpl_GetObjectInfo, - IDirectInputDevice2AImpl_GetDeviceInfo, - IDirectInputDevice2AImpl_RunControlPanel, - IDirectInputDevice2AImpl_Initialize, - IDirectInputDevice2AImpl_CreateEffect, - IDirectInputDevice2AImpl_EnumEffects, - IDirectInputDevice2AImpl_GetEffectInfo, - IDirectInputDevice2AImpl_GetForceFeedbackState, - IDirectInputDevice2AImpl_SendForceFeedbackCommand, - IDirectInputDevice2AImpl_EnumCreatedEffectObjects, - IDirectInputDevice2AImpl_Escape, - IDirectInputDevice2AImpl_Poll, - IDirectInputDevice2AImpl_SendDeviceData, - IDirectInputDevice7AImpl_EnumEffectsInFile, - IDirectInputDevice7AImpl_WriteEffectToFile, - IDirectInputDevice8AImpl_BuildActionMap, - IDirectInputDevice8AImpl_SetActionMap, - IDirectInputDevice8AImpl_GetImageInfo -}; - static const IDirectInputDevice8WVtbl SysMouseWvt = { IDirectInputDevice2WImpl_QueryInterface,
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/dinput_main.c | 135 ++++++++++++++++++------------------- dlls/dinput/tests/dinput.c | 30 ++++++++- 2 files changed, 95 insertions(+), 70 deletions(-)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 7f59c16c45a..3b0de2fbde0 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -553,24 +553,24 @@ static HRESULT WINAPI IDirectInputWImpl_EnumDevices( return S_OK; }
-static ULONG WINAPI IDirectInputAImpl_AddRef(LPDIRECTINPUT7A iface) +static ULONG WINAPI IDirectInputWImpl_AddRef( IDirectInput7W *iface ) { - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); + IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); ULONG ref = InterlockedIncrement(&This->ref);
TRACE( "(%p) ref %d\n", This, ref ); return ref; }
-static ULONG WINAPI IDirectInputWImpl_AddRef(LPDIRECTINPUT7W iface) +static ULONG WINAPI IDirectInputAImpl_AddRef( IDirectInput7A *iface ) { - IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); - return IDirectInputAImpl_AddRef( &This->IDirectInput7A_iface ); + IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); + return IDirectInput_AddRef( &This->IDirectInput7W_iface ); }
-static ULONG WINAPI IDirectInputAImpl_Release(LPDIRECTINPUT7A iface) +static ULONG WINAPI IDirectInputWImpl_Release( IDirectInput7W *iface ) { - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); + IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); ULONG ref = InterlockedDecrement( &This->ref );
TRACE( "(%p) ref %d\n", This, ref ); @@ -584,15 +584,15 @@ static ULONG WINAPI IDirectInputAImpl_Release(LPDIRECTINPUT7A iface) return ref; }
-static ULONG WINAPI IDirectInputWImpl_Release(LPDIRECTINPUT7W iface) +static ULONG WINAPI IDirectInputAImpl_Release( IDirectInput7A *iface ) { - IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); - return IDirectInputAImpl_Release( &This->IDirectInput7A_iface ); + IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); + return IDirectInput_Release( &This->IDirectInput7W_iface ); }
-static HRESULT WINAPI IDirectInputAImpl_QueryInterface(LPDIRECTINPUT7A iface, REFIID riid, LPVOID *ppobj) +static HRESULT WINAPI IDirectInputWImpl_QueryInterface( IDirectInput7W *iface, REFIID riid, LPVOID *ppobj ) { - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); + IDirectInputImpl *This = impl_from_IDirectInput7W( iface );
TRACE( "(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppobj );
@@ -602,22 +602,22 @@ static HRESULT WINAPI IDirectInputAImpl_QueryInterface(LPDIRECTINPUT7A iface, RE *ppobj = NULL;
#if DIRECTINPUT_VERSION == 0x0700 - if (IsEqualGUID( &IID_IUnknown, riid ) || - IsEqualGUID( &IID_IDirectInputA, riid ) || - IsEqualGUID( &IID_IDirectInput2A, riid ) || - IsEqualGUID( &IID_IDirectInput7A, riid )) + if (IsEqualGUID( &IID_IDirectInputA, riid ) || + IsEqualGUID( &IID_IDirectInput2A, riid ) || + IsEqualGUID( &IID_IDirectInput7A, riid )) *ppobj = &This->IDirectInput7A_iface; - else if (IsEqualGUID( &IID_IDirectInputW, riid ) || + else if (IsEqualGUID( &IID_IUnknown, riid ) || + IsEqualGUID( &IID_IDirectInputW, riid ) || IsEqualGUID( &IID_IDirectInput2W, riid ) || IsEqualGUID( &IID_IDirectInput7W, riid )) *ppobj = &This->IDirectInput7W_iface;
#else - if (IsEqualGUID( &IID_IUnknown, riid ) || - IsEqualGUID( &IID_IDirectInput8A, riid )) + if (IsEqualGUID( &IID_IDirectInput8A, riid )) *ppobj = &This->IDirectInput8A_iface;
- else if (IsEqualGUID( &IID_IDirectInput8W, riid )) + else if (IsEqualGUID( &IID_IUnknown, riid ) || + IsEqualGUID( &IID_IDirectInput8W, riid )) *ppobj = &This->IDirectInput8W_iface;
#endif @@ -635,10 +635,10 @@ static HRESULT WINAPI IDirectInputAImpl_QueryInterface(LPDIRECTINPUT7A iface, RE return E_NOINTERFACE; }
-static HRESULT WINAPI IDirectInputWImpl_QueryInterface(LPDIRECTINPUT7W iface, REFIID riid, LPVOID *ppobj) +static HRESULT WINAPI IDirectInputAImpl_QueryInterface( IDirectInput7A *iface, REFIID riid, LPVOID *ppobj ) { - IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); - return IDirectInputAImpl_QueryInterface( &This->IDirectInput7A_iface, riid, ppobj ); + IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); + return IDirectInput_QueryInterface( &This->IDirectInput7W_iface, riid, ppobj ); }
static LRESULT WINAPI di_em_win_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) @@ -744,9 +744,9 @@ enum directinput_versions DIRECTINPUT_VERSION_700 = 0x0700, };
-static HRESULT WINAPI IDirectInputAImpl_Initialize(LPDIRECTINPUT7A iface, HINSTANCE hinst, DWORD version) +static HRESULT WINAPI IDirectInputWImpl_Initialize( IDirectInput7W *iface, HINSTANCE hinst, DWORD version ) { - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); + IDirectInputImpl *This = impl_from_IDirectInput7W( iface );
TRACE("(%p)->(%p, 0x%04x)\n", This, hinst, version);
@@ -765,17 +765,17 @@ static HRESULT WINAPI IDirectInputAImpl_Initialize(LPDIRECTINPUT7A iface, HINSTA return initialize_directinput_instance(This, version); }
-static HRESULT WINAPI IDirectInputWImpl_Initialize(LPDIRECTINPUT7W iface, HINSTANCE hinst, DWORD x) +static HRESULT WINAPI IDirectInputAImpl_Initialize( IDirectInput7A *iface, HINSTANCE hinst, DWORD version ) { - IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); - return IDirectInputAImpl_Initialize( &This->IDirectInput7A_iface, hinst, x ); + IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); + return IDirectInput_Initialize( &This->IDirectInput7W_iface, hinst, version ); }
-static HRESULT WINAPI IDirectInputAImpl_GetDeviceStatus(LPDIRECTINPUT7A iface, REFGUID rguid) +static HRESULT WINAPI IDirectInputWImpl_GetDeviceStatus( IDirectInput7W *iface, REFGUID rguid ) { - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); + IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); HRESULT hr; - LPDIRECTINPUTDEVICEA device; + IDirectInputDeviceW *device;
TRACE( "(%p)->(%s)\n", This, debugstr_guid(rguid) );
@@ -791,22 +791,19 @@ static HRESULT WINAPI IDirectInputAImpl_GetDeviceStatus(LPDIRECTINPUT7A iface, R return DI_OK; }
-static HRESULT WINAPI IDirectInputWImpl_GetDeviceStatus(LPDIRECTINPUT7W iface, REFGUID rguid) +static HRESULT WINAPI IDirectInputAImpl_GetDeviceStatus( IDirectInput7A *iface, REFGUID rguid ) { - IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); - return IDirectInputAImpl_GetDeviceStatus( &This->IDirectInput7A_iface, rguid ); + IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); + return IDirectInput_GetDeviceStatus( &This->IDirectInput7W_iface, rguid ); }
-static HRESULT WINAPI IDirectInputAImpl_RunControlPanel(LPDIRECTINPUT7A iface, - HWND hwndOwner, - DWORD dwFlags) +static HRESULT WINAPI IDirectInputWImpl_RunControlPanel( IDirectInput7W *iface, HWND hwndOwner, DWORD dwFlags ) { + IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); WCHAR control_exeW[] = {'c','o','n','t','r','o','l','.','e','x','e',0}; STARTUPINFOW si = {0}; PROCESS_INFORMATION pi;
- IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); - TRACE( "(%p)->(%p, %08x)\n", This, hwndOwner, dwFlags );
if (hwndOwner && !IsWindow(hwndOwner)) @@ -824,10 +821,10 @@ static HRESULT WINAPI IDirectInputAImpl_RunControlPanel(LPDIRECTINPUT7A iface, return DI_OK; }
-static HRESULT WINAPI IDirectInputWImpl_RunControlPanel(LPDIRECTINPUT7W iface, HWND hwndOwner, DWORD dwFlags) +static HRESULT WINAPI IDirectInputAImpl_RunControlPanel( IDirectInput7A *iface, HWND hwndOwner, DWORD dwFlags ) { - IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); - return IDirectInputAImpl_RunControlPanel( &This->IDirectInput7A_iface, hwndOwner, dwFlags ); + IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); + return IDirectInput_RunControlPanel( &This->IDirectInput7W_iface, hwndOwner, dwFlags ); }
static HRESULT WINAPI IDirectInput2AImpl_FindDevice(LPDIRECTINPUT7A iface, REFGUID rguid, @@ -900,13 +897,13 @@ static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, R static HRESULT WINAPI IDirectInputAImpl_CreateDevice(LPDIRECTINPUT7A iface, REFGUID rguid, LPDIRECTINPUTDEVICEA* pdev, LPUNKNOWN punk) { - return IDirectInput7AImpl_CreateDeviceEx(iface, rguid, NULL, (LPVOID*)pdev, punk); + return IDirectInput7_CreateDeviceEx( iface, rguid, NULL, (LPVOID *)pdev, punk ); }
static HRESULT WINAPI IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7W iface, REFGUID rguid, LPDIRECTINPUTDEVICEW* pdev, LPUNKNOWN punk) { - return IDirectInput7WImpl_CreateDeviceEx(iface, rguid, NULL, (LPVOID*)pdev, punk); + return IDirectInput7_CreateDeviceEx( iface, rguid, NULL, (LPVOID *)pdev, punk ); }
/******************************************************************************* @@ -916,94 +913,94 @@ static HRESULT WINAPI IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7W iface, REFG static ULONG WINAPI IDirectInput8AImpl_AddRef(LPDIRECTINPUT8A iface) { IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); - return IDirectInputAImpl_AddRef( &This->IDirectInput7A_iface ); + return IDirectInput_AddRef( &This->IDirectInput7A_iface ); }
static ULONG WINAPI IDirectInput8WImpl_AddRef(LPDIRECTINPUT8W iface) { IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInputAImpl_AddRef( &This->IDirectInput7A_iface ); + return IDirectInput_AddRef( &This->IDirectInput7W_iface ); }
static HRESULT WINAPI IDirectInput8AImpl_QueryInterface(LPDIRECTINPUT8A iface, REFIID riid, LPVOID *ppobj) { IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); - return IDirectInputAImpl_QueryInterface( &This->IDirectInput7A_iface, riid, ppobj ); + return IDirectInput_QueryInterface( &This->IDirectInput7A_iface, riid, ppobj ); }
static HRESULT WINAPI IDirectInput8WImpl_QueryInterface(LPDIRECTINPUT8W iface, REFIID riid, LPVOID *ppobj) { IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInputAImpl_QueryInterface( &This->IDirectInput7A_iface, riid, ppobj ); + return IDirectInput_QueryInterface( &This->IDirectInput7W_iface, riid, ppobj ); }
static ULONG WINAPI IDirectInput8AImpl_Release(LPDIRECTINPUT8A iface) { IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); - return IDirectInputAImpl_Release( &This->IDirectInput7A_iface ); + return IDirectInput_Release( &This->IDirectInput7A_iface ); }
static ULONG WINAPI IDirectInput8WImpl_Release(LPDIRECTINPUT8W iface) { IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInputAImpl_Release( &This->IDirectInput7A_iface ); + return IDirectInput_Release( &This->IDirectInput7W_iface ); }
static HRESULT WINAPI IDirectInput8AImpl_CreateDevice(LPDIRECTINPUT8A iface, REFGUID rguid, LPDIRECTINPUTDEVICE8A* pdev, LPUNKNOWN punk) { IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); - return IDirectInput7AImpl_CreateDeviceEx( &This->IDirectInput7A_iface, rguid, NULL, (LPVOID*)pdev, punk ); + return IDirectInput7_CreateDeviceEx( &This->IDirectInput7A_iface, rguid, NULL, (LPVOID *)pdev, punk ); }
static HRESULT WINAPI IDirectInput8WImpl_CreateDevice(LPDIRECTINPUT8W iface, REFGUID rguid, LPDIRECTINPUTDEVICE8W* pdev, LPUNKNOWN punk) { IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInput7WImpl_CreateDeviceEx( &This->IDirectInput7W_iface, rguid, NULL, (LPVOID*)pdev, punk ); + return IDirectInput7_CreateDeviceEx( &This->IDirectInput7W_iface, rguid, NULL, (LPVOID *)pdev, punk ); }
static HRESULT WINAPI IDirectInput8AImpl_EnumDevices(LPDIRECTINPUT8A iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) { IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); - return IDirectInputAImpl_EnumDevices( &This->IDirectInput7A_iface, dwDevType, lpCallback, pvRef, dwFlags ); + return IDirectInput_EnumDevices( &This->IDirectInput7A_iface, dwDevType, lpCallback, pvRef, dwFlags ); }
static HRESULT WINAPI IDirectInput8WImpl_EnumDevices(LPDIRECTINPUT8W iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) { IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInputWImpl_EnumDevices( &This->IDirectInput7W_iface, dwDevType, lpCallback, pvRef, dwFlags ); + return IDirectInput_EnumDevices( &This->IDirectInput7W_iface, dwDevType, lpCallback, pvRef, dwFlags ); }
static HRESULT WINAPI IDirectInput8AImpl_GetDeviceStatus(LPDIRECTINPUT8A iface, REFGUID rguid) { IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); - return IDirectInputAImpl_GetDeviceStatus( &This->IDirectInput7A_iface, rguid ); + return IDirectInput_GetDeviceStatus( &This->IDirectInput7A_iface, rguid ); }
static HRESULT WINAPI IDirectInput8WImpl_GetDeviceStatus(LPDIRECTINPUT8W iface, REFGUID rguid) { IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInputAImpl_GetDeviceStatus( &This->IDirectInput7A_iface, rguid ); + return IDirectInput_GetDeviceStatus( &This->IDirectInput7W_iface, rguid ); }
static HRESULT WINAPI IDirectInput8AImpl_RunControlPanel(LPDIRECTINPUT8A iface, HWND hwndOwner, DWORD dwFlags) { IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); - return IDirectInputAImpl_RunControlPanel( &This->IDirectInput7A_iface, hwndOwner, dwFlags ); + return IDirectInput_RunControlPanel( &This->IDirectInput7A_iface, hwndOwner, dwFlags ); }
static HRESULT WINAPI IDirectInput8WImpl_RunControlPanel(LPDIRECTINPUT8W iface, HWND hwndOwner, DWORD dwFlags) { IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInputAImpl_RunControlPanel( &This->IDirectInput7A_iface, hwndOwner, dwFlags ); + return IDirectInput_RunControlPanel( &This->IDirectInput7W_iface, hwndOwner, dwFlags ); }
-static HRESULT WINAPI IDirectInput8AImpl_Initialize(LPDIRECTINPUT8A iface, HINSTANCE hinst, DWORD version) +static HRESULT WINAPI IDirectInput8WImpl_Initialize( IDirectInput8W *iface, HINSTANCE hinst, DWORD version ) { - IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); + IDirectInputImpl *This = impl_from_IDirectInput8W( iface );
TRACE("(%p)->(%p, 0x%04x)\n", This, hinst, version);
@@ -1019,22 +1016,22 @@ static HRESULT WINAPI IDirectInput8AImpl_Initialize(LPDIRECTINPUT8A iface, HINST return initialize_directinput_instance(This, version); }
-static HRESULT WINAPI IDirectInput8WImpl_Initialize(LPDIRECTINPUT8W iface, HINSTANCE hinst, DWORD version) +static HRESULT WINAPI IDirectInput8AImpl_Initialize( IDirectInput8A *iface, HINSTANCE hinst, DWORD version ) { - IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInput8AImpl_Initialize( &This->IDirectInput8A_iface, hinst, version ); + IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); + return IDirectInput8_Initialize( &This->IDirectInput8W_iface, hinst, version ); }
static HRESULT WINAPI IDirectInput8AImpl_FindDevice(LPDIRECTINPUT8A iface, REFGUID rguid, LPCSTR pszName, LPGUID pguidInstance) { IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); - return IDirectInput2AImpl_FindDevice( &This->IDirectInput7A_iface, rguid, pszName, pguidInstance ); + return IDirectInput2_FindDevice( &This->IDirectInput7A_iface, rguid, pszName, pguidInstance ); }
static HRESULT WINAPI IDirectInput8WImpl_FindDevice(LPDIRECTINPUT8W iface, REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) { IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInput2WImpl_FindDevice( &This->IDirectInput7W_iface, rguid, pszName, pguidInstance ); + return IDirectInput2_FindDevice( &This->IDirectInput7W_iface, rguid, pszName, pguidInstance ); }
static BOOL should_enumerate_device(const WCHAR *username, DWORD dwFlags, @@ -1340,7 +1337,7 @@ static HRESULT WINAPI IDirectInput8AImpl_ConfigureDevices( diafW.rgoAction[i].u.lptszActionName = to; }
- hr = IDirectInput8WImpl_ConfigureDevices(&This->IDirectInput8W_iface, lpdiCallback, &diCDParamsW, dwFlags, pvRefData); + hr = IDirectInput8_ConfigureDevices( &This->IDirectInput8W_iface, lpdiCallback, &diCDParamsW, dwFlags, pvRefData );
/* Copy back configuration */ if (SUCCEEDED(hr)) @@ -1367,19 +1364,19 @@ static inline IDirectInputImpl *impl_from_IDirectInputJoyConfig8(IDirectInputJoy static HRESULT WINAPI JoyConfig8Impl_QueryInterface(IDirectInputJoyConfig8 *iface, REFIID riid, void** ppobj) { IDirectInputImpl *This = impl_from_IDirectInputJoyConfig8( iface ); - return IDirectInputAImpl_QueryInterface( &This->IDirectInput7A_iface, riid, ppobj ); + return IDirectInput_QueryInterface( &This->IDirectInput7W_iface, riid, ppobj ); }
static ULONG WINAPI JoyConfig8Impl_AddRef(IDirectInputJoyConfig8 *iface) { IDirectInputImpl *This = impl_from_IDirectInputJoyConfig8( iface ); - return IDirectInputAImpl_AddRef( &This->IDirectInput7A_iface ); + return IDirectInput_AddRef( &This->IDirectInput7W_iface ); }
static ULONG WINAPI JoyConfig8Impl_Release(IDirectInputJoyConfig8 *iface) { IDirectInputImpl *This = impl_from_IDirectInputJoyConfig8( iface ); - return IDirectInputAImpl_Release( &This->IDirectInput7A_iface ); + return IDirectInput_Release( &This->IDirectInput7W_iface ); }
static HRESULT WINAPI JoyConfig8Impl_Acquire(IDirectInputJoyConfig8 *iface) diff --git a/dlls/dinput/tests/dinput.c b/dlls/dinput/tests/dinput.c index 5947b17468b..c7fa0b76397 100644 --- a/dlls/dinput/tests/dinput.c +++ b/dlls/dinput/tests/dinput.c @@ -286,7 +286,7 @@ static void test_QueryInterface(void)
IDirectInputA *pDI; HRESULT hr; - IUnknown *pUnk; + IUnknown *pUnk, *iface, *tmp_iface; int i;
hr = DirectInputCreateA(hInstance, DIRECTINPUT_VERSION, &pDI, NULL); @@ -324,6 +324,34 @@ static void test_QueryInterface(void) ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk); }
+ hr = IUnknown_QueryInterface( pDI, &IID_IDirectInputA, (void **)&iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputA) failed: %08x\n", hr ); + hr = IUnknown_QueryInterface( pDI, &IID_IDirectInput2A, (void **)&tmp_iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInput2A) failed: %08x\n", hr ); + ok( tmp_iface == iface, "IID_IDirectInput2A iface differs from IID_IDirectInputA\n" ); + IUnknown_Release( tmp_iface ); + hr = IUnknown_QueryInterface( pDI, &IID_IDirectInput7A, (void **)&tmp_iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInput7A) failed: %08x\n", hr ); + ok( tmp_iface == iface, "IID_IDirectInput7A iface differs from IID_IDirectInputA\n" ); + IUnknown_Release( tmp_iface ); + IUnknown_Release( iface ); + + hr = IUnknown_QueryInterface( pDI, &IID_IUnknown, (void **)&iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IUnknown) failed: %08x\n", hr ); + hr = IUnknown_QueryInterface( pDI, &IID_IDirectInputW, (void **)&tmp_iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputW) failed: %08x\n", hr ); + ok( tmp_iface == iface, "IID_IDirectInputW iface differs from IID_IUnknown\n" ); + IUnknown_Release( tmp_iface ); + hr = IUnknown_QueryInterface( pDI, &IID_IDirectInput2W, (void **)&tmp_iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInput2W) failed: %08x\n", hr ); + ok( tmp_iface == iface, "IID_IDirectInput2W iface differs from IID_IUnknown\n" ); + IUnknown_Release( tmp_iface ); + hr = IUnknown_QueryInterface( pDI, &IID_IDirectInput7W, (void **)&tmp_iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInput7W) failed: %08x\n", hr ); + ok( tmp_iface == iface, "IID_IDirectInput7W iface differs from IID_IUnknown\n" ); + IUnknown_Release( tmp_iface ); + IUnknown_Release( iface ); + IDirectInput_Release(pDI); }
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/ansi.c | 251 ++++++++++++++++++++++++- dlls/dinput/dinput_main.c | 354 +---------------------------------- dlls/dinput/dinput_private.h | 5 +- 3 files changed, 249 insertions(+), 361 deletions(-)
diff --git a/dlls/dinput/ansi.c b/dlls/dinput/ansi.c index 910940f3257..f60aa8c729d 100644 --- a/dlls/dinput/ansi.c +++ b/dlls/dinput/ansi.c @@ -43,6 +43,22 @@ static IDirectInputDevice8W *IDirectInputDevice8W_from_impl( IDirectInputDeviceI return &impl->IDirectInputDevice8W_iface; }
+static inline IDirectInputDevice8A *IDirectInputDevice8A_from_IDirectInputDevice8W( IDirectInputDevice8W *iface ) +{ + if (!iface) return NULL; + return &CONTAINING_RECORD( iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface )->IDirectInputDevice8A_iface; +} + +static IDirectInputImpl *impl_from_IDirectInput8A( IDirectInput8A *iface ) +{ + return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInput8A_iface ); +} + +static IDirectInput8W *IDirectInput8W_from_impl( IDirectInputImpl *impl ) +{ + return &impl->IDirectInput8W_iface; +} + static void dideviceobjectinstance_wtoa( const DIDEVICEOBJECTINSTANCEW *in, DIDEVICEOBJECTINSTANCEA *out ) { out->guidType = in->guidType; @@ -135,14 +151,15 @@ static void diactionformat_wtoa( const DIACTIONFORMATW *in, DIACTIONFORMATA *out sizeof(out->tszActionMap), NULL, NULL ); }
-static void diactionformat_atow( const DIACTIONFORMATA *in, DIACTIONFORMATW *out ) +static HRESULT diactionformat_atow( const DIACTIONFORMATA *in, DIACTIONFORMATW *out, BOOL convert_names ) { + HRESULT hr = DI_OK; DWORD i;
out->dwDataSize = in->dwDataSize; out->dwNumActions = in->dwNumActions;
- for (i = 0; i < out->dwNumActions; ++i) + for (i = 0; i < out->dwNumActions && !FAILED(hr); ++i) { out->rgoAction[i].uAppData = in->rgoAction[i].uAppData; out->rgoAction[i].dwSemantic = in->rgoAction[i].dwSemantic; @@ -150,9 +167,13 @@ static void diactionformat_atow( const DIACTIONFORMATA *in, DIACTIONFORMATW *out out->rgoAction[i].guidInstance = in->rgoAction[i].guidInstance; out->rgoAction[i].dwObjID = in->rgoAction[i].dwObjID; out->rgoAction[i].dwHow = in->rgoAction[i].dwHow; - out->rgoAction[i].lptszActionName = 0; + if (!convert_names) out->rgoAction[i].lptszActionName = 0; + else if (in->hInstString) out->rgoAction[i].uResIdString = in->rgoAction[i].uResIdString; + else hr = string_atow( in->rgoAction[i].lptszActionName, (WCHAR **)&out->rgoAction[i].lptszActionName ); }
+ for (; i < out->dwNumActions; ++i) out->rgoAction[i].lptszActionName = 0; + out->guidActionMap = in->guidActionMap; out->dwGenre = in->dwGenre; out->dwBufferSize = in->dwBufferSize; @@ -164,6 +185,8 @@ static void diactionformat_atow( const DIACTIONFORMATA *in, DIACTIONFORMATW *out
MultiByteToWideChar( CP_ACP, 0, in->tszActionMap, -1, out->tszActionMap, sizeof(out->tszActionMap) / sizeof(WCHAR) ); + + return hr; }
static void dideviceimageinfo_wtoa( const DIDEVICEIMAGEINFOW *in, DIDEVICEIMAGEINFOA *out ) @@ -202,6 +225,33 @@ static void dideviceimageinfoheader_wtoa( const DIDEVICEIMAGEINFOHEADERW *in, DI } }
+static HRESULT diconfiguredevicesparams_atow( const DICONFIGUREDEVICESPARAMSA *in, DICONFIGUREDEVICESPARAMSW *out ) +{ + const char *name_a = in->lptszUserNames; + DWORD len_w, len_a; + + if (!in->lptszUserNames) out->lptszUserNames = NULL; + else + { + while (name_a[0] && name_a[1]) ++name_a; + len_a = name_a - in->lptszUserNames + 1; + len_w = MultiByteToWideChar( CP_ACP, 0, in->lptszUserNames, len_a, NULL, 0 ); + + out->lptszUserNames = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len_w * sizeof(WCHAR) ); + if (!out->lptszUserNames) return DIERR_OUTOFMEMORY; + + MultiByteToWideChar( CP_ACP, 0, in->lptszUserNames, len_a, out->lptszUserNames, len_w ); + } + + out->dwcUsers = in->dwcUsers; + out->dwcFormats = in->dwcFormats; + out->hwnd = in->hwnd; + out->dics = in->dics; + out->lpUnkDDSTarget = in->lpUnkDDSTarget; + + return DI_OK; +} + static HRESULT WINAPI dinput_device_a_QueryInterface( IDirectInputDevice8A *iface_a, REFIID iid, void **out ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); @@ -511,7 +561,7 @@ static HRESULT WINAPI dinput_device_a_BuildActionMap( IDirectInputDevice8A *ifac if (!format_w.rgoAction) hr = DIERR_OUTOFMEMORY; else { - diactionformat_atow( format_a, &format_w ); + diactionformat_atow( format_a, &format_w, FALSE ); hr = IDirectInputDevice8_BuildActionMap( iface_w, &format_w, username_w, flags ); diactionformat_wtoa( &format_w, format_a ); HeapFree( GetProcessHeap(), 0, format_w.rgoAction ); @@ -540,7 +590,7 @@ static HRESULT WINAPI dinput_device_a_SetActionMap( IDirectInputDevice8A *iface_ if (!format_w.rgoAction) hr = DIERR_OUTOFMEMORY; else { - diactionformat_atow( format_a, &format_w ); + diactionformat_atow( format_a, &format_w, FALSE ); hr = IDirectInputDevice8_SetActionMap( iface_w, &format_w, username_w, flags ); diactionformat_wtoa( &format_w, format_a ); HeapFree( GetProcessHeap(), 0, format_w.rgoAction ); @@ -611,3 +661,194 @@ const IDirectInputDevice8AVtbl dinput_device_a_vtbl = dinput_device_a_SetActionMap, dinput_device_a_GetImageInfo, }; + +static HRESULT WINAPI dinput8_a_QueryInterface( IDirectInput8A *iface_a, REFIID iid, void **out ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput8A( iface_a ); + IDirectInput8W *iface_w = IDirectInput8W_from_impl( impl ); + return IDirectInput8_QueryInterface( iface_w, iid, out ); +} + +static ULONG WINAPI dinput8_a_AddRef( IDirectInput8A *iface_a ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput8A( iface_a ); + IDirectInput8W *iface_w = IDirectInput8W_from_impl( impl ); + return IDirectInput8_AddRef( iface_w ); +} + +static ULONG WINAPI dinput8_a_Release( IDirectInput8A *iface_a ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput8A( iface_a ); + IDirectInput8W *iface_w = IDirectInput8W_from_impl( impl ); + return IDirectInput8_Release( iface_w ); +} + +static HRESULT WINAPI dinput8_a_CreateDevice( IDirectInput8A *iface_a, REFGUID guid, IDirectInputDevice8A **out, IUnknown *outer ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput8A( iface_a ); + IDirectInput8W *iface_w = IDirectInput8W_from_impl( impl ); + IDirectInputDevice8W *outw; + HRESULT hr; + + if (!out) return E_POINTER; + + hr = IDirectInput8_CreateDevice( iface_w, guid, &outw, outer ); + *out = IDirectInputDevice8A_from_IDirectInputDevice8W( outw ); + return hr; +} + +struct enum_devices_wtoa_params +{ + LPDIENUMDEVICESCALLBACKA callback; + void *ref; +}; + +static BOOL CALLBACK enum_devices_wtoa_callback( const DIDEVICEINSTANCEW *instance_w, void *data ) +{ + struct enum_devices_wtoa_params *params = data; + DIDEVICEINSTANCEA instance_a = {sizeof(instance_a)}; + + dideviceinstance_wtoa( instance_w, &instance_a ); + return params->callback( &instance_a, params->ref ); +} + +static HRESULT WINAPI dinput8_a_EnumDevices( IDirectInput8A *iface_a, DWORD type, LPDIENUMDEVICESCALLBACKA callback, + void *ref, DWORD flags ) +{ + struct enum_devices_wtoa_params params = {callback, ref}; + IDirectInputImpl *impl = impl_from_IDirectInput8A( iface_a ); + IDirectInput8W *iface_w = IDirectInput8W_from_impl( impl ); + + if (!callback) return DIERR_INVALIDPARAM; + + return IDirectInput8_EnumDevices( iface_w, type, enum_devices_wtoa_callback, ¶ms, flags ); +} + +static HRESULT WINAPI dinput8_a_GetDeviceStatus( IDirectInput8A *iface_a, REFGUID instance_guid ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput8A( iface_a ); + IDirectInput8W *iface_w = IDirectInput8W_from_impl( impl ); + return IDirectInput8_GetDeviceStatus( iface_w, instance_guid ); +} + +static HRESULT WINAPI dinput8_a_RunControlPanel( IDirectInput8A *iface_a, HWND owner, DWORD flags ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput8A( iface_a ); + IDirectInput8W *iface_w = IDirectInput8W_from_impl( impl ); + return IDirectInput8_RunControlPanel( iface_w, owner, flags ); +} + +static HRESULT WINAPI dinput8_a_Initialize( IDirectInput8A *iface_a, HINSTANCE instance, DWORD version ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput8A( iface_a ); + IDirectInput8W *iface_w = IDirectInput8W_from_impl( impl ); + return IDirectInput8_Initialize( iface_w, instance, version ); +} + +static HRESULT WINAPI dinput8_a_FindDevice( IDirectInput8A *iface_a, REFGUID guid, const char *name_a, GUID *instance_guid ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput8A( iface_a ); + IDirectInput8W *iface_w = IDirectInput8W_from_impl( impl ); + HRESULT hr; + WCHAR *name_w; + + if (FAILED(hr = string_atow( name_a, &name_w ))) return hr; + + hr = IDirectInput8_FindDevice( iface_w, guid, name_w, instance_guid ); + HeapFree( GetProcessHeap(), 0, name_w ); + return hr; +} + +struct enum_devices_by_semantics_wtoa_params +{ + LPDIENUMDEVICESBYSEMANTICSCBA callback; + void *ref; +}; + +static BOOL CALLBACK enum_devices_by_semantics_wtoa_callback( const DIDEVICEINSTANCEW *instance_w, IDirectInputDevice8W *iface_w, + DWORD flags, DWORD remaining, void *data ) +{ + struct enum_devices_by_semantics_wtoa_params *params = data; + IDirectInputDevice8A *iface_a = IDirectInputDevice8A_from_IDirectInputDevice8W( iface_w ); + DIDEVICEINSTANCEA instance_a = {sizeof(instance_a)}; + + dideviceinstance_wtoa( instance_w, &instance_a ); + return params->callback( &instance_a, iface_a, flags, remaining, params->ref ); +} + +static HRESULT WINAPI dinput8_a_EnumDevicesBySemantics( IDirectInput8A *iface_a, const char *username_a, DIACTIONFORMATA *format_a, + LPDIENUMDEVICESBYSEMANTICSCBA callback, void *ref, DWORD flags ) +{ + struct enum_devices_by_semantics_wtoa_params params = {callback, ref}; + IDirectInputImpl *impl = impl_from_IDirectInput8A( iface_a ); + DIACTIONFORMATW format_w = {sizeof(format_w), sizeof(DIACTIONW)}; + IDirectInput8W *iface_w = IDirectInput8W_from_impl( impl ); + HRESULT hr; + WCHAR *username_w; + + if (!callback) return DIERR_INVALIDPARAM; + if (FAILED(hr = string_atow( username_a, &username_w ))) return hr; + + format_w.dwNumActions = format_a->dwNumActions; + format_w.rgoAction = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, format_a->dwNumActions * sizeof(DIACTIONW) ); + if (!format_w.rgoAction) hr = DIERR_OUTOFMEMORY; + else + { + diactionformat_atow( format_a, &format_w, FALSE ); + hr = IDirectInput8_EnumDevicesBySemantics( iface_w, username_w, &format_w, enum_devices_by_semantics_wtoa_callback, + ¶ms, flags ); + HeapFree( GetProcessHeap(), 0, format_w.rgoAction ); + } + + HeapFree( GetProcessHeap(), 0, username_w ); + return hr; +} + +static HRESULT WINAPI dinput8_a_ConfigureDevices( IDirectInput8A *iface_a, LPDICONFIGUREDEVICESCALLBACK callback, + DICONFIGUREDEVICESPARAMSA *params_a, DWORD flags, void *ref ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput8A( iface_a ); + IDirectInput8W *iface_w = IDirectInput8W_from_impl( impl ); + DICONFIGUREDEVICESPARAMSW params_w = {sizeof(params_w)}; + DIACTIONFORMATA *format_a = params_a->lprgFormats; + DIACTIONFORMATW format_w = {sizeof(format_w), sizeof(DIACTIONW)}; + HRESULT hr; + DWORD i; + + if (!callback) return DIERR_INVALIDPARAM; + if (FAILED(hr = diconfiguredevicesparams_atow( params_a, ¶ms_w ))) return hr; + + format_w.dwNumActions = format_a->dwNumActions; + format_w.rgoAction = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, format_a->dwNumActions * sizeof(DIACTIONW) ); + if (!format_w.rgoAction) hr = DIERR_OUTOFMEMORY; + else + { + hr = diactionformat_atow( format_a, &format_w, TRUE ); + params_w.lprgFormats = &format_w; + + if (SUCCEEDED(hr)) hr = IDirectInput8_ConfigureDevices( iface_w, callback, ¶ms_w, flags, ref ); + + if (!format_w.hInstString) for (i = 0; i < format_w.dwNumActions; ++i) HeapFree( GetProcessHeap(), 0, (void *)format_w.rgoAction[i].lptszActionName ); + HeapFree( GetProcessHeap(), 0, format_w.rgoAction ); + } + + HeapFree( GetProcessHeap(), 0, params_w.lptszUserNames ); + return hr; +} + +const IDirectInput8AVtbl dinput8_a_vtbl = +{ + /*** IUnknown methods ***/ + dinput8_a_QueryInterface, + dinput8_a_AddRef, + dinput8_a_Release, + /*** IDirectInput8A methods ***/ + dinput8_a_CreateDevice, + dinput8_a_EnumDevices, + dinput8_a_GetDeviceStatus, + dinput8_a_RunControlPanel, + dinput8_a_Initialize, + dinput8_a_FindDevice, + dinput8_a_EnumDevicesBySemantics, + dinput8_a_ConfigureDevices, +}; diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 3b0de2fbde0..1591779544a 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -57,7 +57,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput);
static const IDirectInput7AVtbl ddi7avt; static const IDirectInput7WVtbl ddi7wvt; -static const IDirectInput8AVtbl ddi8avt; static const IDirectInput8WVtbl ddi8wvt; static const IDirectInputJoyConfig8Vtbl JoyConfig8vt;
@@ -71,11 +70,6 @@ static inline IDirectInputImpl *impl_from_IDirectInput7W( IDirectInput7W *iface return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInput7W_iface ); }
-static inline IDirectInputImpl *impl_from_IDirectInput8A( IDirectInput8A *iface ) -{ - return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInput8A_iface ); -} - static inline IDirectInputImpl *impl_from_IDirectInput8W( IDirectInput8W *iface ) { return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInput8W_iface ); @@ -144,7 +138,7 @@ static HRESULT create_directinput_instance(REFIID riid, LPVOID *ppDI, IDirectInp
This->IDirectInput7A_iface.lpVtbl = &ddi7avt; This->IDirectInput7W_iface.lpVtbl = &ddi7wvt; - This->IDirectInput8A_iface.lpVtbl = &ddi8avt; + This->IDirectInput8A_iface.lpVtbl = &dinput8_a_vtbl; This->IDirectInput8W_iface.lpVtbl = &ddi8wvt; This->IDirectInputJoyConfig8_iface.lpVtbl = &JoyConfig8vt;
@@ -321,110 +315,6 @@ static void _dump_EnumDevices_dwFlags(DWORD dwFlags) TRACE("\n"); }
-static void _dump_diactionformatA(LPDIACTIONFORMATA lpdiActionFormat) -{ - unsigned int i; - - TRACE("diaf.dwSize = %d\n", lpdiActionFormat->dwSize); - TRACE("diaf.dwActionSize = %d\n", lpdiActionFormat->dwActionSize); - TRACE("diaf.dwDataSize = %d\n", lpdiActionFormat->dwDataSize); - TRACE("diaf.dwNumActions = %d\n", lpdiActionFormat->dwNumActions); - TRACE("diaf.rgoAction = %p\n", lpdiActionFormat->rgoAction); - TRACE("diaf.guidActionMap = %s\n", debugstr_guid(&lpdiActionFormat->guidActionMap)); - TRACE("diaf.dwGenre = 0x%08x\n", lpdiActionFormat->dwGenre); - TRACE("diaf.dwBufferSize = %d\n", lpdiActionFormat->dwBufferSize); - TRACE("diaf.lAxisMin = %d\n", lpdiActionFormat->lAxisMin); - TRACE("diaf.lAxisMax = %d\n", lpdiActionFormat->lAxisMax); - TRACE("diaf.hInstString = %p\n", lpdiActionFormat->hInstString); - TRACE("diaf.ftTimeStamp ...\n"); - TRACE("diaf.dwCRC = 0x%x\n", lpdiActionFormat->dwCRC); - TRACE("diaf.tszActionMap = %s\n", debugstr_a(lpdiActionFormat->tszActionMap)); - for (i = 0; i < lpdiActionFormat->dwNumActions; i++) - { - TRACE("diaf.rgoAction[%u]:\n", i); - TRACE("\tuAppData=0x%lx\n", lpdiActionFormat->rgoAction[i].uAppData); - TRACE("\tdwSemantic=0x%08x\n", lpdiActionFormat->rgoAction[i].dwSemantic); - TRACE("\tdwFlags=0x%x\n", lpdiActionFormat->rgoAction[i].dwFlags); - TRACE("\tszActionName=%s\n", debugstr_a(lpdiActionFormat->rgoAction[i].u.lptszActionName)); - TRACE("\tguidInstance=%s\n", debugstr_guid(&lpdiActionFormat->rgoAction[i].guidInstance)); - TRACE("\tdwObjID=0x%x\n", lpdiActionFormat->rgoAction[i].dwObjID); - TRACE("\tdwHow=0x%x\n", lpdiActionFormat->rgoAction[i].dwHow); - } -} - -void _copy_diactionformatAtoW(LPDIACTIONFORMATW to, LPDIACTIONFORMATA from) -{ - int i; - - to->dwSize = sizeof(DIACTIONFORMATW); - to->dwActionSize = sizeof(DIACTIONW); - to->dwDataSize = from->dwDataSize; - to->dwNumActions = from->dwNumActions; - to->guidActionMap = from->guidActionMap; - to->dwGenre = from->dwGenre; - to->dwBufferSize = from->dwBufferSize; - to->lAxisMin = from->lAxisMin; - to->lAxisMax = from->lAxisMax; - to->dwCRC = from->dwCRC; - to->ftTimeStamp = from->ftTimeStamp; - - for (i=0; i < to->dwNumActions; i++) - { - to->rgoAction[i].uAppData = from->rgoAction[i].uAppData; - to->rgoAction[i].dwSemantic = from->rgoAction[i].dwSemantic; - to->rgoAction[i].dwFlags = from->rgoAction[i].dwFlags; - to->rgoAction[i].guidInstance = from->rgoAction[i].guidInstance; - to->rgoAction[i].dwObjID = from->rgoAction[i].dwObjID; - to->rgoAction[i].dwHow = from->rgoAction[i].dwHow; - } -} - -void _copy_diactionformatWtoA(LPDIACTIONFORMATA to, LPDIACTIONFORMATW from) -{ - int i; - - to->dwSize = sizeof(DIACTIONFORMATA); - to->dwActionSize = sizeof(DIACTIONA); - to->dwDataSize = from->dwDataSize; - to->dwNumActions = from->dwNumActions; - to->guidActionMap = from->guidActionMap; - to->dwGenre = from->dwGenre; - to->dwBufferSize = from->dwBufferSize; - to->lAxisMin = from->lAxisMin; - to->lAxisMax = from->lAxisMax; - to->dwCRC = from->dwCRC; - to->ftTimeStamp = from->ftTimeStamp; - - for (i=0; i < to->dwNumActions; i++) - { - to->rgoAction[i].uAppData = from->rgoAction[i].uAppData; - to->rgoAction[i].dwSemantic = from->rgoAction[i].dwSemantic; - to->rgoAction[i].dwFlags = from->rgoAction[i].dwFlags; - to->rgoAction[i].guidInstance = from->rgoAction[i].guidInstance; - to->rgoAction[i].dwObjID = from->rgoAction[i].dwObjID; - to->rgoAction[i].dwHow = from->rgoAction[i].dwHow; - } -} - -/* diactionformat_priority - * - * Given a DIACTIONFORMAT structure and a DI genre, returns the enumeration - * priority. Joysticks should pass the game genre, and mouse or keyboard their - * respective DI*_MASK - */ -static DWORD diactionformat_priorityA(LPDIACTIONFORMATA lpdiaf, DWORD genre) -{ - int i; - DWORD priorityFlags = 0; - - /* If there's at least one action for the device it's priority 1 */ - for(i=0; i < lpdiaf->dwNumActions; i++) - if ((lpdiaf->rgoAction[i].dwSemantic & genre) == genre) - priorityFlags |= DIEDBS_MAPPEDPRI1; - - return priorityFlags; -} - static DWORD diactionformat_priorityW(LPDIACTIONFORMATW lpdiaf, DWORD genre) { int i; @@ -910,49 +800,24 @@ static HRESULT WINAPI IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7W iface, REFG * DirectInput8 */
-static ULONG WINAPI IDirectInput8AImpl_AddRef(LPDIRECTINPUT8A iface) -{ - IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); - return IDirectInput_AddRef( &This->IDirectInput7A_iface ); -} - static ULONG WINAPI IDirectInput8WImpl_AddRef(LPDIRECTINPUT8W iface) { IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); return IDirectInput_AddRef( &This->IDirectInput7W_iface ); }
-static HRESULT WINAPI IDirectInput8AImpl_QueryInterface(LPDIRECTINPUT8A iface, REFIID riid, LPVOID *ppobj) -{ - IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); - return IDirectInput_QueryInterface( &This->IDirectInput7A_iface, riid, ppobj ); -} - static HRESULT WINAPI IDirectInput8WImpl_QueryInterface(LPDIRECTINPUT8W iface, REFIID riid, LPVOID *ppobj) { IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); return IDirectInput_QueryInterface( &This->IDirectInput7W_iface, riid, ppobj ); }
-static ULONG WINAPI IDirectInput8AImpl_Release(LPDIRECTINPUT8A iface) -{ - IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); - return IDirectInput_Release( &This->IDirectInput7A_iface ); -} - static ULONG WINAPI IDirectInput8WImpl_Release(LPDIRECTINPUT8W iface) { IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); return IDirectInput_Release( &This->IDirectInput7W_iface ); }
-static HRESULT WINAPI IDirectInput8AImpl_CreateDevice(LPDIRECTINPUT8A iface, REFGUID rguid, - LPDIRECTINPUTDEVICE8A* pdev, LPUNKNOWN punk) -{ - IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); - return IDirectInput7_CreateDeviceEx( &This->IDirectInput7A_iface, rguid, NULL, (LPVOID *)pdev, punk ); -} - static HRESULT WINAPI IDirectInput8WImpl_CreateDevice(LPDIRECTINPUT8W iface, REFGUID rguid, LPDIRECTINPUTDEVICE8W* pdev, LPUNKNOWN punk) { @@ -960,13 +825,6 @@ static HRESULT WINAPI IDirectInput8WImpl_CreateDevice(LPDIRECTINPUT8W iface, REF return IDirectInput7_CreateDeviceEx( &This->IDirectInput7W_iface, rguid, NULL, (LPVOID *)pdev, punk ); }
-static HRESULT WINAPI IDirectInput8AImpl_EnumDevices(LPDIRECTINPUT8A iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, - LPVOID pvRef, DWORD dwFlags) -{ - IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); - return IDirectInput_EnumDevices( &This->IDirectInput7A_iface, dwDevType, lpCallback, pvRef, dwFlags ); -} - static HRESULT WINAPI IDirectInput8WImpl_EnumDevices(LPDIRECTINPUT8W iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) { @@ -974,24 +832,12 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevices(LPDIRECTINPUT8W iface, DWOR return IDirectInput_EnumDevices( &This->IDirectInput7W_iface, dwDevType, lpCallback, pvRef, dwFlags ); }
-static HRESULT WINAPI IDirectInput8AImpl_GetDeviceStatus(LPDIRECTINPUT8A iface, REFGUID rguid) -{ - IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); - return IDirectInput_GetDeviceStatus( &This->IDirectInput7A_iface, rguid ); -} - static HRESULT WINAPI IDirectInput8WImpl_GetDeviceStatus(LPDIRECTINPUT8W iface, REFGUID rguid) { IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); return IDirectInput_GetDeviceStatus( &This->IDirectInput7W_iface, rguid ); }
-static HRESULT WINAPI IDirectInput8AImpl_RunControlPanel(LPDIRECTINPUT8A iface, HWND hwndOwner, DWORD dwFlags) -{ - IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); - return IDirectInput_RunControlPanel( &This->IDirectInput7A_iface, hwndOwner, dwFlags ); -} - static HRESULT WINAPI IDirectInput8WImpl_RunControlPanel(LPDIRECTINPUT8W iface, HWND hwndOwner, DWORD dwFlags) { IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); @@ -1016,18 +862,6 @@ static HRESULT WINAPI IDirectInput8WImpl_Initialize( IDirectInput8W *iface, HINS return initialize_directinput_instance(This, version); }
-static HRESULT WINAPI IDirectInput8AImpl_Initialize( IDirectInput8A *iface, HINSTANCE hinst, DWORD version ) -{ - IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); - return IDirectInput8_Initialize( &This->IDirectInput8W_iface, hinst, version ); -} - -static HRESULT WINAPI IDirectInput8AImpl_FindDevice(LPDIRECTINPUT8A iface, REFGUID rguid, LPCSTR pszName, LPGUID pguidInstance) -{ - IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); - return IDirectInput2_FindDevice( &This->IDirectInput7A_iface, rguid, pszName, pguidInstance ); -} - static HRESULT WINAPI IDirectInput8WImpl_FindDevice(LPDIRECTINPUT8W iface, REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) { IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); @@ -1075,130 +909,6 @@ static BOOL should_enumerate_device(const WCHAR *username, DWORD dwFlags, return should_enumerate; }
-static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics( - LPDIRECTINPUT8A iface, LPCSTR ptszUserName, LPDIACTIONFORMATA lpdiActionFormat, - LPDIENUMDEVICESBYSEMANTICSCBA lpCallback, - LPVOID pvRef, DWORD dwFlags -) -{ - static REFGUID guids[2] = { &GUID_SysKeyboard, &GUID_SysMouse }; - static const DWORD actionMasks[] = { DIKEYBOARD_MASK, DIMOUSE_MASK }; - IDirectInputImpl *This = impl_from_IDirectInput8A( iface ); - DIDEVICEINSTANCEA didevi; - LPDIRECTINPUTDEVICE8A lpdid; - DWORD callbackFlags; - int i, j; - int device_count = 0; - int remain; - DIDEVICEINSTANCEA *didevis = 0; - WCHAR *username_w = 0; - - FIXME("(this=%p,%s,%p,%p,%p,%04x): semi-stub\n", This, debugstr_a(ptszUserName), lpdiActionFormat, - lpCallback, pvRef, dwFlags); -#define X(x) if (dwFlags & x) FIXME("\tdwFlags |= "#x"\n"); - X(DIEDBSFL_ATTACHEDONLY) - X(DIEDBSFL_THISUSER) - X(DIEDBSFL_FORCEFEEDBACK) - X(DIEDBSFL_AVAILABLEDEVICES) - X(DIEDBSFL_MULTIMICEKEYBOARDS) - X(DIEDBSFL_NONGAMINGDEVICES) -#undef X - - _dump_diactionformatA(lpdiActionFormat); - - didevi.dwSize = sizeof(didevi); - - if (ptszUserName) - { - int len = MultiByteToWideChar(CP_ACP, 0, ptszUserName, -1, 0, 0); - - username_w = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len); - MultiByteToWideChar(CP_ACP, 0, ptszUserName, -1, username_w, len); - } - - /* Enumerate all the joysticks */ - for (i = 0; i < ARRAY_SIZE(dinput_devices); i++) - { - HRESULT enumSuccess; - - if (!dinput_devices[i]->enum_deviceA) 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_deviceA(DI8DEVCLASS_GAMECTRL, DIEDFL_ATTACHEDONLY | dwFlags, &didevi, This->dwVersion, j); - if (enumSuccess == S_OK && - should_enumerate_device(username_w, dwFlags, &This->device_players, &didevi.guidInstance)) - { - if (device_count++) - didevis = HeapReAlloc(GetProcessHeap(), 0, didevis, sizeof(DIDEVICEINSTANCEA)*device_count); - else - didevis = HeapAlloc(GetProcessHeap(), 0, sizeof(DIDEVICEINSTANCEA)*device_count); - didevis[device_count-1] = didevi; - } - } - } - - remain = device_count; - /* Add keyboard and mouse to remaining device count */ - if (!(dwFlags & DIEDBSFL_FORCEFEEDBACK)) - { - for (i = 0; i < ARRAY_SIZE(guids); i++) - { - if (should_enumerate_device(username_w, dwFlags, &This->device_players, guids[i])) - remain++; - } - } - - for (i = 0; i < device_count; i++) - { - callbackFlags = diactionformat_priorityA(lpdiActionFormat, lpdiActionFormat->dwGenre); - IDirectInput_CreateDevice(iface, &didevis[i].guidInstance, &lpdid, NULL); - - if (lpCallback(&didevis[i], lpdid, callbackFlags, --remain, pvRef) == DIENUM_STOP) - { - IDirectInputDevice_Release(lpdid); - HeapFree(GetProcessHeap(), 0, didevis); - HeapFree(GetProcessHeap(), 0, username_w); - return DI_OK; - } - IDirectInputDevice_Release(lpdid); - } - - HeapFree(GetProcessHeap(), 0, didevis); - - if (dwFlags & DIEDBSFL_FORCEFEEDBACK) - { - HeapFree(GetProcessHeap(), 0, username_w); - return DI_OK; - } - - /* Enumerate keyboard and mouse */ - for (i = 0; i < ARRAY_SIZE(guids); i++) - { - if (should_enumerate_device(username_w, dwFlags, &This->device_players, guids[i])) - { - callbackFlags = diactionformat_priorityA(lpdiActionFormat, actionMasks[i]); - - IDirectInput_CreateDevice(iface, guids[i], &lpdid, NULL); - IDirectInputDevice_GetDeviceInfo(lpdid, &didevi); - - if (lpCallback(&didevi, lpdid, callbackFlags, --remain, pvRef) == DIENUM_STOP) - { - IDirectInputDevice_Release(lpdid); - HeapFree(GetProcessHeap(), 0, username_w); - return DI_OK; - } - IDirectInputDevice_Release(lpdid); - } - } - - HeapFree(GetProcessHeap(), 0, username_w); - return DI_OK; -} - static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics( LPDIRECTINPUT8W iface, LPCWSTR ptszUserName, LPDIACTIONFORMATW lpdiActionFormat, LPDIENUMDEVICESBYSEMANTICSCBW lpCallback, @@ -1304,54 +1014,6 @@ static HRESULT WINAPI IDirectInput8WImpl_ConfigureDevices( return _configure_devices(iface, lpdiCallback, lpdiCDParams, dwFlags, pvRefData); }
-static HRESULT WINAPI IDirectInput8AImpl_ConfigureDevices( - LPDIRECTINPUT8A iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback, - LPDICONFIGUREDEVICESPARAMSA lpdiCDParams, DWORD dwFlags, LPVOID pvRefData -) -{ - IDirectInputImpl *This = impl_from_IDirectInput8A(iface); - DIACTIONFORMATW diafW; - DICONFIGUREDEVICESPARAMSW diCDParamsW; - HRESULT hr; - int i; - - FIXME("(this=%p,%p,%p,%04x,%p): stub\n", This, lpdiCallback, lpdiCDParams, dwFlags, pvRefData); - - /* Copy parameters */ - diCDParamsW.dwSize = sizeof(DICONFIGUREDEVICESPARAMSW); - diCDParamsW.dwcFormats = lpdiCDParams->dwcFormats; - diCDParamsW.lprgFormats = &diafW; - diCDParamsW.hwnd = lpdiCDParams->hwnd; - - diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiCDParams->lprgFormats->dwNumActions); - _copy_diactionformatAtoW(&diafW, lpdiCDParams->lprgFormats); - - /* Copy action names */ - for (i=0; i < diafW.dwNumActions; i++) - { - const char* from = lpdiCDParams->lprgFormats->rgoAction[i].u.lptszActionName; - int len = MultiByteToWideChar(CP_ACP, 0, from , -1, NULL , 0); - WCHAR *to = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len); - - MultiByteToWideChar(CP_ACP, 0, from , -1, to , len); - diafW.rgoAction[i].u.lptszActionName = to; - } - - hr = IDirectInput8_ConfigureDevices( &This->IDirectInput8W_iface, lpdiCallback, &diCDParamsW, dwFlags, pvRefData ); - - /* Copy back configuration */ - if (SUCCEEDED(hr)) - _copy_diactionformatWtoA(lpdiCDParams->lprgFormats, &diafW); - - /* Free memory */ - for (i=0; i < diafW.dwNumActions; i++) - HeapFree(GetProcessHeap(), 0, (void*) diafW.rgoAction[i].u.lptszActionName); - - HeapFree(GetProcessHeap(), 0, diafW.rgoAction); - - return hr; -} - /***************************************************************************** * IDirectInputJoyConfig8 interface */ @@ -1539,20 +1201,6 @@ static const IDirectInput7WVtbl ddi7wvt = { IDirectInput7WImpl_CreateDeviceEx };
-static const IDirectInput8AVtbl ddi8avt = { - IDirectInput8AImpl_QueryInterface, - IDirectInput8AImpl_AddRef, - IDirectInput8AImpl_Release, - IDirectInput8AImpl_CreateDevice, - IDirectInput8AImpl_EnumDevices, - IDirectInput8AImpl_GetDeviceStatus, - IDirectInput8AImpl_RunControlPanel, - IDirectInput8AImpl_Initialize, - IDirectInput8AImpl_FindDevice, - IDirectInput8AImpl_EnumDevicesBySemantics, - IDirectInput8AImpl_ConfigureDevices -}; - static const IDirectInput8WVtbl ddi8wvt = { IDirectInput8WImpl_QueryInterface, IDirectInput8WImpl_AddRef, diff --git a/dlls/dinput/dinput_private.h b/dlls/dinput/dinput_private.h index 3df20a424ab..a8087195f96 100644 --- a/dlls/dinput/dinput_private.h +++ b/dlls/dinput/dinput_private.h @@ -49,6 +49,8 @@ struct IDirectInputImpl struct list device_players; /* device instance guid to player name */ };
+extern const IDirectInput8AVtbl dinput8_a_vtbl DECLSPEC_HIDDEN; + /* Function called by all devices that Wine supports */ struct dinput_device { const char *name; @@ -79,9 +81,6 @@ extern void dinput_mouse_rawinput_hook( IDirectInputDevice8W *iface, WPARAM wpar extern void check_dinput_hooks(LPDIRECTINPUTDEVICE8W, BOOL) DECLSPEC_HIDDEN; extern void check_dinput_events(void) DECLSPEC_HIDDEN;
-extern void _copy_diactionformatAtoW(LPDIACTIONFORMATW, LPDIACTIONFORMATA) DECLSPEC_HIDDEN; -extern void _copy_diactionformatWtoA(LPDIACTIONFORMATA, LPDIACTIONFORMATW) DECLSPEC_HIDDEN; - extern HRESULT _configure_devices(IDirectInput8W *iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback, LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData) DECLSPEC_HIDDEN;
extern WCHAR* get_mapping_path(const WCHAR *device, const WCHAR *username) DECLSPEC_HIDDEN;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/ansi.c | 122 ++++++++++++++++++++++++++++++++++ dlls/dinput/dinput_main.c | 124 +---------------------------------- dlls/dinput/dinput_private.h | 1 + 3 files changed, 124 insertions(+), 123 deletions(-)
diff --git a/dlls/dinput/ansi.c b/dlls/dinput/ansi.c index f60aa8c729d..431b812aeb2 100644 --- a/dlls/dinput/ansi.c +++ b/dlls/dinput/ansi.c @@ -49,6 +49,21 @@ static inline IDirectInputDevice8A *IDirectInputDevice8A_from_IDirectInputDevice return &CONTAINING_RECORD( iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface )->IDirectInputDevice8A_iface; }
+static inline IDirectInputDeviceA *IDirectInputDeviceA_from_IDirectInputDeviceW( IDirectInputDeviceW *iface ) +{ + return (IDirectInputDeviceA *)IDirectInputDevice8A_from_IDirectInputDevice8W( (IDirectInputDevice8W *)iface ); +} + +static IDirectInputImpl *impl_from_IDirectInput7A( IDirectInput7A *iface ) +{ + return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInput7A_iface ); +} + +static IDirectInput7W *IDirectInput7W_from_impl( IDirectInputImpl *impl ) +{ + return &impl->IDirectInput7W_iface; +} + static IDirectInputImpl *impl_from_IDirectInput8A( IDirectInput8A *iface ) { return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInput8A_iface ); @@ -852,3 +867,110 @@ const IDirectInput8AVtbl dinput8_a_vtbl = dinput8_a_EnumDevicesBySemantics, dinput8_a_ConfigureDevices, }; + +static HRESULT WINAPI dinput7_a_QueryInterface( IDirectInput7A *iface_a, REFIID iid, void **out ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + return IDirectInput7_QueryInterface( iface_w, iid, out ); +} + +static ULONG WINAPI dinput7_a_AddRef( IDirectInput7A *iface_a ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + return IDirectInput7_AddRef( iface_w ); +} + +static ULONG WINAPI dinput7_a_Release( IDirectInput7A *iface_a ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + return IDirectInput7_Release( iface_w ); +} + +static HRESULT WINAPI dinput7_a_CreateDevice( IDirectInput7A *iface_a, REFGUID guid, IDirectInputDeviceA **out_a, IUnknown *outer ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + IDirectInputDeviceW *out_w; + HRESULT hr; + + if (!out_a) return E_POINTER; + + hr = IDirectInput7_CreateDevice( iface_w, guid, &out_w, outer ); + *out_a = IDirectInputDeviceA_from_IDirectInputDeviceW( out_w ); + return hr; +} + +static HRESULT WINAPI dinput7_a_EnumDevices( IDirectInput7A *iface_a, DWORD type, LPDIENUMDEVICESCALLBACKA callback, + void *ref, DWORD flags ) +{ + struct enum_devices_wtoa_params params = {callback, ref}; + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + + if (!callback) return DIERR_INVALIDPARAM; + + return IDirectInput7_EnumDevices( iface_w, type, enum_devices_wtoa_callback, ¶ms, flags ); +} + +static HRESULT WINAPI dinput7_a_GetDeviceStatus( IDirectInput7A *iface_a, REFGUID instance_guid ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + return IDirectInput7_GetDeviceStatus( iface_w, instance_guid ); +} + +static HRESULT WINAPI dinput7_a_RunControlPanel( IDirectInput7A *iface_a, HWND owner, DWORD flags ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + return IDirectInput7_RunControlPanel( iface_w, owner, flags ); +} + +static HRESULT WINAPI dinput7_a_Initialize( IDirectInput7A *iface_a, HINSTANCE instance, DWORD version ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + return IDirectInput7_Initialize( iface_w, instance, version ); +} + +static HRESULT WINAPI dinput7_a_FindDevice( IDirectInput7A *iface_a, REFGUID guid, const char *name_a, GUID *instance_guid ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + HRESULT hr; + WCHAR *name_w; + + if (FAILED(hr = string_atow( name_a, &name_w ))) return hr; + + hr = IDirectInput7_FindDevice( iface_w, guid, name_w, instance_guid ); + HeapFree( GetProcessHeap(), 0, name_w ); + return hr; +} + +static HRESULT WINAPI dinput7_a_CreateDeviceEx( IDirectInput7A *iface_a, REFGUID guid, REFIID iid, void **out, IUnknown *outer ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + return IDirectInput7_CreateDeviceEx( iface_w, guid, iid, out, outer ); +} + +const IDirectInput7AVtbl dinput7_a_vtbl = +{ + /*** IUnknown methods ***/ + dinput7_a_QueryInterface, + dinput7_a_AddRef, + dinput7_a_Release, + /*** IDirectInputA methods ***/ + dinput7_a_CreateDevice, + dinput7_a_EnumDevices, + dinput7_a_GetDeviceStatus, + dinput7_a_RunControlPanel, + dinput7_a_Initialize, + /*** IDirectInput2A methods ***/ + dinput7_a_FindDevice, + /*** IDirectInput7A methods ***/ + dinput7_a_CreateDeviceEx, +}; diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 1591779544a..85de9f79b81 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -55,16 +55,10 @@
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
-static const IDirectInput7AVtbl ddi7avt; static const IDirectInput7WVtbl ddi7wvt; static const IDirectInput8WVtbl ddi8wvt; static const IDirectInputJoyConfig8Vtbl JoyConfig8vt;
-static inline IDirectInputImpl *impl_from_IDirectInput7A( IDirectInput7A *iface ) -{ - return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInput7A_iface ); -} - static inline IDirectInputImpl *impl_from_IDirectInput7W( IDirectInput7W *iface ) { return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInput7W_iface ); @@ -136,7 +130,7 @@ static HRESULT create_directinput_instance(REFIID riid, LPVOID *ppDI, IDirectInp if (!This) return E_OUTOFMEMORY;
- This->IDirectInput7A_iface.lpVtbl = &ddi7avt; + This->IDirectInput7A_iface.lpVtbl = &dinput7_a_vtbl; This->IDirectInput7W_iface.lpVtbl = &ddi7wvt; This->IDirectInput8A_iface.lpVtbl = &dinput8_a_vtbl; This->IDirectInput8W_iface.lpVtbl = &ddi8wvt; @@ -361,47 +355,6 @@ __ASM_GLOBAL_FUNC( enum_callback_wrapper, #define enum_callback_wrapper(callback, instance, ref) (callback)((instance), (ref)) #endif
-/****************************************************************************** - * IDirectInputA_EnumDevices - */ -static HRESULT WINAPI IDirectInputAImpl_EnumDevices( - LPDIRECTINPUT7A iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, - LPVOID pvRef, DWORD dwFlags) -{ - IDirectInputImpl *This = impl_from_IDirectInput7A(iface); - DIDEVICEINSTANCEA devInstance; - unsigned int i; - int j; - HRESULT r; - - TRACE("(this=%p,0x%04x '%s',%p,%p,0x%04x)\n", - This, dwDevType, _dump_DIDEVTYPE_value(dwDevType, This->dwVersion), - lpCallback, pvRef, dwFlags); - _dump_EnumDevices_dwFlags(dwFlags); - - if (!lpCallback || - dwFlags & ~(DIEDFL_ATTACHEDONLY | DIEDFL_FORCEFEEDBACK | DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS | DIEDFL_INCLUDEHIDDEN) || - (dwDevType > DI8DEVCLASS_GAMECTRL && dwDevType < DI8DEVTYPE_DEVICE) || dwDevType > DI8DEVTYPE_SUPPLEMENTAL) - return DIERR_INVALIDPARAM; - - if (!This->initialized) - return DIERR_NOTINITIALIZED; - - for (i = 0; i < ARRAY_SIZE(dinput_devices); i++) { - if (!dinput_devices[i]->enum_deviceA) continue; - - TRACE(" Checking device %u ('%s')\n", i, dinput_devices[i]->name); - for (j = 0, r = S_OK; SUCCEEDED(r); j++) { - devInstance.dwSize = sizeof(devInstance); - r = dinput_devices[i]->enum_deviceA(dwDevType, dwFlags, &devInstance, This->dwVersion, j); - if (r == S_OK) - if (enum_callback_wrapper(lpCallback, &devInstance, pvRef) == DIENUM_STOP) - return S_OK; - } - } - - return S_OK; -} /****************************************************************************** * IDirectInputW_EnumDevices */ @@ -452,12 +405,6 @@ static ULONG WINAPI IDirectInputWImpl_AddRef( IDirectInput7W *iface ) return ref; }
-static ULONG WINAPI IDirectInputAImpl_AddRef( IDirectInput7A *iface ) -{ - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); - return IDirectInput_AddRef( &This->IDirectInput7W_iface ); -} - static ULONG WINAPI IDirectInputWImpl_Release( IDirectInput7W *iface ) { IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); @@ -474,12 +421,6 @@ static ULONG WINAPI IDirectInputWImpl_Release( IDirectInput7W *iface ) return ref; }
-static ULONG WINAPI IDirectInputAImpl_Release( IDirectInput7A *iface ) -{ - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); - return IDirectInput_Release( &This->IDirectInput7W_iface ); -} - static HRESULT WINAPI IDirectInputWImpl_QueryInterface( IDirectInput7W *iface, REFIID riid, LPVOID *ppobj ) { IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); @@ -525,12 +466,6 @@ static HRESULT WINAPI IDirectInputWImpl_QueryInterface( IDirectInput7W *iface, R return E_NOINTERFACE; }
-static HRESULT WINAPI IDirectInputAImpl_QueryInterface( IDirectInput7A *iface, REFIID riid, LPVOID *ppobj ) -{ - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); - return IDirectInput_QueryInterface( &This->IDirectInput7W_iface, riid, ppobj ); -} - static LRESULT WINAPI di_em_win_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { IDirectInputDeviceImpl *dev; @@ -655,12 +590,6 @@ static HRESULT WINAPI IDirectInputWImpl_Initialize( IDirectInput7W *iface, HINST return initialize_directinput_instance(This, version); }
-static HRESULT WINAPI IDirectInputAImpl_Initialize( IDirectInput7A *iface, HINSTANCE hinst, DWORD version ) -{ - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); - return IDirectInput_Initialize( &This->IDirectInput7W_iface, hinst, version ); -} - static HRESULT WINAPI IDirectInputWImpl_GetDeviceStatus( IDirectInput7W *iface, REFGUID rguid ) { IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); @@ -681,12 +610,6 @@ static HRESULT WINAPI IDirectInputWImpl_GetDeviceStatus( IDirectInput7W *iface, return DI_OK; }
-static HRESULT WINAPI IDirectInputAImpl_GetDeviceStatus( IDirectInput7A *iface, REFGUID rguid ) -{ - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); - return IDirectInput_GetDeviceStatus( &This->IDirectInput7W_iface, rguid ); -} - static HRESULT WINAPI IDirectInputWImpl_RunControlPanel( IDirectInput7W *iface, HWND hwndOwner, DWORD dwFlags ) { IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); @@ -711,22 +634,6 @@ static HRESULT WINAPI IDirectInputWImpl_RunControlPanel( IDirectInput7W *iface, return DI_OK; }
-static HRESULT WINAPI IDirectInputAImpl_RunControlPanel( IDirectInput7A *iface, HWND hwndOwner, DWORD dwFlags ) -{ - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); - return IDirectInput_RunControlPanel( &This->IDirectInput7W_iface, hwndOwner, dwFlags ); -} - -static HRESULT WINAPI IDirectInput2AImpl_FindDevice(LPDIRECTINPUT7A iface, REFGUID rguid, - LPCSTR pszName, LPGUID pguidInstance) -{ - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); - - FIXME( "(%p)->(%s, %s, %p): stub\n", This, debugstr_guid(rguid), pszName, pguidInstance ); - - return DI_OK; -} - static HRESULT WINAPI IDirectInput2WImpl_FindDevice(LPDIRECTINPUT7W iface, REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) { @@ -764,16 +671,6 @@ static HRESULT create_device(IDirectInputImpl *This, REFGUID rguid, REFIID riid, return DIERR_DEVICENOTREG; }
-static HRESULT WINAPI IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface, REFGUID rguid, - REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter) -{ - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); - - TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter); - - return create_device(This, rguid, riid, pvOut, FALSE); -} - static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, REFGUID rguid, REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter) { @@ -784,12 +681,6 @@ static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, R return create_device(This, rguid, riid, pvOut, TRUE); }
-static HRESULT WINAPI IDirectInputAImpl_CreateDevice(LPDIRECTINPUT7A iface, REFGUID rguid, - LPDIRECTINPUTDEVICEA* pdev, LPUNKNOWN punk) -{ - return IDirectInput7_CreateDeviceEx( iface, rguid, NULL, (LPVOID *)pdev, punk ); -} - static HRESULT WINAPI IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7W iface, REFGUID rguid, LPDIRECTINPUTDEVICEW* pdev, LPUNKNOWN punk) { @@ -1175,19 +1066,6 @@ static HRESULT WINAPI JoyConfig8Impl_OpenAppStatusKey(IDirectInputJoyConfig8 *if return E_NOTIMPL; }
-static const IDirectInput7AVtbl ddi7avt = { - IDirectInputAImpl_QueryInterface, - IDirectInputAImpl_AddRef, - IDirectInputAImpl_Release, - IDirectInputAImpl_CreateDevice, - IDirectInputAImpl_EnumDevices, - IDirectInputAImpl_GetDeviceStatus, - IDirectInputAImpl_RunControlPanel, - IDirectInputAImpl_Initialize, - IDirectInput2AImpl_FindDevice, - IDirectInput7AImpl_CreateDeviceEx -}; - static const IDirectInput7WVtbl ddi7wvt = { IDirectInputWImpl_QueryInterface, IDirectInputWImpl_AddRef, diff --git a/dlls/dinput/dinput_private.h b/dlls/dinput/dinput_private.h index a8087195f96..256c30d3dc0 100644 --- a/dlls/dinput/dinput_private.h +++ b/dlls/dinput/dinput_private.h @@ -49,6 +49,7 @@ struct IDirectInputImpl struct list device_players; /* device instance guid to player name */ };
+extern const IDirectInput7AVtbl dinput7_a_vtbl DECLSPEC_HIDDEN; extern const IDirectInput8AVtbl dinput8_a_vtbl DECLSPEC_HIDDEN;
/* Function called by all devices that Wine supports */