dinput: Factor out IDirectInputDevice_GetDeviceInfo WtoA conversions.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
7713050c77
commit
27ea33baf9
|
@ -64,6 +64,23 @@ static void dideviceobjectinstance_wtoa( const DIDEVICEOBJECTINSTANCEW *in, DIDE
|
|||
out->wReserved = in->wReserved;
|
||||
}
|
||||
|
||||
static void dideviceinstance_wtoa( const DIDEVICEINSTANCEW *in, DIDEVICEINSTANCEA *out )
|
||||
{
|
||||
out->guidInstance = in->guidInstance;
|
||||
out->guidProduct = in->guidProduct;
|
||||
out->dwDevType = in->dwDevType;
|
||||
WideCharToMultiByte( CP_ACP, 0, in->tszInstanceName, -1, out->tszInstanceName,
|
||||
sizeof(out->tszInstanceName), NULL, NULL );
|
||||
WideCharToMultiByte( CP_ACP, 0, in->tszProductName, -1, out->tszProductName,
|
||||
sizeof(out->tszProductName), NULL, NULL );
|
||||
|
||||
if (out->dwSize <= FIELD_OFFSET( DIDEVICEINSTANCEA, guidFFDriver )) return;
|
||||
|
||||
out->guidFFDriver = in->guidFFDriver;
|
||||
out->wUsagePage = in->wUsagePage;
|
||||
out->wUsage = in->wUsage;
|
||||
}
|
||||
|
||||
static void dieffectinfo_wtoa( const DIEFFECTINFOW *in, DIEFFECTINFOA *out )
|
||||
{
|
||||
out->guid = in->guid;
|
||||
|
@ -247,6 +264,23 @@ HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo( IDirectInputDevice8A *ifa
|
|||
return hr;
|
||||
}
|
||||
|
||||
HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo( IDirectInputDevice8A *iface_a, DIDEVICEINSTANCEA *instance_a )
|
||||
{
|
||||
IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a );
|
||||
IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl );
|
||||
DIDEVICEINSTANCEW instance_w = {sizeof(instance_w)};
|
||||
HRESULT hr;
|
||||
|
||||
if (!instance_a) return E_POINTER;
|
||||
if (instance_a->dwSize != sizeof(DIDEVICEINSTANCEA) && instance_a->dwSize != sizeof(DIDEVICEINSTANCE_DX3A))
|
||||
return DIERR_INVALIDPARAM;
|
||||
|
||||
hr = IDirectInputDevice8_GetDeviceInfo( iface_w, &instance_w );
|
||||
dideviceinstance_wtoa( &instance_w, instance_a );
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel( IDirectInputDevice8A *iface_a, HWND owner, DWORD flags )
|
||||
{
|
||||
IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a );
|
||||
|
|
|
@ -173,6 +173,7 @@ extern HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(LPDIRECTINPUTDEVICE
|
|||
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,
|
||||
|
|
|
@ -637,54 +637,6 @@ HRESULT WINAPI JoystickWGenericImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REF
|
|||
return DI_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* GetDeviceInfo : get information about a device's identity
|
||||
*/
|
||||
HRESULT WINAPI JoystickAGenericImpl_GetDeviceInfo(
|
||||
LPDIRECTINPUTDEVICE8A iface,
|
||||
LPDIDEVICEINSTANCEA pdidi)
|
||||
{
|
||||
JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface);
|
||||
DIPROPDWORD pd;
|
||||
DWORD index = 0;
|
||||
|
||||
TRACE("(%p,%p)\n", This, pdidi);
|
||||
|
||||
if (pdidi == NULL) {
|
||||
WARN("invalid pointer\n");
|
||||
return E_POINTER;
|
||||
}
|
||||
|
||||
if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3A)) &&
|
||||
(pdidi->dwSize != sizeof(DIDEVICEINSTANCEA))) {
|
||||
WARN("invalid parameter: pdidi->dwSize = %d\n", pdidi->dwSize);
|
||||
return DIERR_INVALIDPARAM;
|
||||
}
|
||||
|
||||
/* Try to get joystick index */
|
||||
pd.diph.dwSize = sizeof(pd);
|
||||
pd.diph.dwHeaderSize = sizeof(pd.diph);
|
||||
pd.diph.dwObj = 0;
|
||||
pd.diph.dwHow = DIPH_DEVICE;
|
||||
if (SUCCEEDED(IDirectInputDevice2_GetProperty(iface, DIPROP_JOYSTICKID, &pd.diph)))
|
||||
index = pd.dwData;
|
||||
|
||||
/* Return joystick */
|
||||
pdidi->guidInstance = This->base.guid;
|
||||
pdidi->guidProduct = This->guidProduct;
|
||||
/* we only support traditional joysticks for now */
|
||||
pdidi->dwDevType = This->devcaps.dwDevType;
|
||||
snprintf(pdidi->tszInstanceName, MAX_PATH, "Joystick %d", index);
|
||||
lstrcpynA(pdidi->tszProductName, This->name, MAX_PATH);
|
||||
if (pdidi->dwSize > sizeof(DIDEVICEINSTANCE_DX3A)) {
|
||||
pdidi->guidFFDriver = GUID_NULL;
|
||||
pdidi->wUsagePage = 0;
|
||||
pdidi->wUsage = 0;
|
||||
}
|
||||
|
||||
return DI_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* GetDeviceInfo : get information about a device's identity
|
||||
*/
|
||||
|
|
|
@ -103,11 +103,6 @@ struct JoystickImpl
|
|||
POINTL povs[4];
|
||||
};
|
||||
|
||||
static inline JoystickImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface),
|
||||
JoystickGenericImpl, base), JoystickImpl, generic);
|
||||
}
|
||||
static inline JoystickImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface),
|
||||
|
@ -764,25 +759,6 @@ static HRESULT WINAPI JoystickLinuxWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface
|
|||
/******************************************************************************
|
||||
* GetDeviceInfo : get information about a device's identity
|
||||
*/
|
||||
static HRESULT WINAPI JoystickLinuxAImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8A iface, LPDIDEVICEINSTANCEA ddi)
|
||||
{
|
||||
JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
|
||||
|
||||
TRACE("(%p) %p\n", This, ddi);
|
||||
|
||||
if (ddi == NULL) return E_POINTER;
|
||||
if ((ddi->dwSize != sizeof(DIDEVICEINSTANCE_DX3A)) &&
|
||||
(ddi->dwSize != sizeof(DIDEVICEINSTANCEA)))
|
||||
return DIERR_INVALIDPARAM;
|
||||
|
||||
fill_joystick_dideviceinstanceA( ddi, This->generic.base.dinput->dwVersion,
|
||||
get_joystick_index(&This->generic.base.guid) );
|
||||
|
||||
ddi->guidInstance = This->generic.base.guid;
|
||||
|
||||
return DI_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI JoystickLinuxWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW ddi)
|
||||
{
|
||||
JoystickImpl *This = impl_from_IDirectInputDevice8W(iface);
|
||||
|
@ -919,7 +895,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt =
|
|||
IDirectInputDevice2AImpl_SetEventNotification,
|
||||
IDirectInputDevice2AImpl_SetCooperativeLevel,
|
||||
IDirectInputDevice2AImpl_GetObjectInfo,
|
||||
JoystickLinuxAImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2AImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2AImpl_RunControlPanel,
|
||||
IDirectInputDevice2AImpl_Initialize,
|
||||
IDirectInputDevice2AImpl_CreateEffect,
|
||||
|
|
|
@ -136,11 +136,6 @@ struct JoystickImpl
|
|||
int ff_gain;
|
||||
};
|
||||
|
||||
static inline JoystickImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface),
|
||||
JoystickGenericImpl, base), JoystickImpl, generic);
|
||||
}
|
||||
static inline JoystickImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface),
|
||||
|
@ -1293,26 +1288,6 @@ static HRESULT WINAPI JoystickWImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE
|
|||
/******************************************************************************
|
||||
* GetDeviceInfo : get information about a device's identity
|
||||
*/
|
||||
static HRESULT WINAPI JoystickAImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8A iface,
|
||||
LPDIDEVICEINSTANCEA pdidi)
|
||||
{
|
||||
JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
|
||||
|
||||
TRACE("(%p) %p\n", This, pdidi);
|
||||
|
||||
if (pdidi == NULL) return E_POINTER;
|
||||
if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3A)) &&
|
||||
(pdidi->dwSize != sizeof(DIDEVICEINSTANCEA)))
|
||||
return DIERR_INVALIDPARAM;
|
||||
|
||||
fill_joystick_dideviceinstanceA(pdidi, This->generic.base.dinput->dwVersion,
|
||||
get_joystick_index(&This->generic.base.guid));
|
||||
|
||||
pdidi->guidInstance = This->generic.base.guid;
|
||||
|
||||
return DI_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI JoystickWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface,
|
||||
LPDIDEVICEINSTANCEW pdidi)
|
||||
{
|
||||
|
@ -1350,7 +1325,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt =
|
|||
IDirectInputDevice2AImpl_SetEventNotification,
|
||||
IDirectInputDevice2AImpl_SetCooperativeLevel,
|
||||
IDirectInputDevice2AImpl_GetObjectInfo,
|
||||
JoystickAImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2AImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2AImpl_RunControlPanel,
|
||||
IDirectInputDevice2AImpl_Initialize,
|
||||
IDirectInputDevice2AImpl_CreateEffect,
|
||||
|
|
|
@ -116,11 +116,6 @@ struct JoystickImpl
|
|||
struct list effects;
|
||||
};
|
||||
|
||||
static inline JoystickImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface),
|
||||
JoystickGenericImpl, base), JoystickImpl, generic);
|
||||
}
|
||||
static inline JoystickImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface),
|
||||
|
@ -1591,7 +1586,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt =
|
|||
IDirectInputDevice2AImpl_SetEventNotification,
|
||||
IDirectInputDevice2AImpl_SetCooperativeLevel,
|
||||
IDirectInputDevice2AImpl_GetObjectInfo,
|
||||
JoystickAGenericImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2AImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2AImpl_RunControlPanel,
|
||||
IDirectInputDevice2AImpl_Initialize,
|
||||
IDirectInputDevice2AImpl_CreateEffect,
|
||||
|
|
|
@ -70,9 +70,6 @@ void _dump_DIDEVCAPS(const DIDEVCAPS *lpDIDevCaps) DECLSPEC_HIDDEN;
|
|||
|
||||
HRESULT WINAPI JoystickWGenericImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIPROPHEADER ph) DECLSPEC_HIDDEN;
|
||||
|
||||
HRESULT WINAPI JoystickAGenericImpl_GetDeviceInfo( LPDIRECTINPUTDEVICE8A iface,
|
||||
LPDIDEVICEINSTANCEA pdidi) DECLSPEC_HIDDEN;
|
||||
|
||||
HRESULT WINAPI JoystickWGenericImpl_GetDeviceInfo( LPDIRECTINPUTDEVICE8W iface,
|
||||
LPDIDEVICEINSTANCEW pdidi) DECLSPEC_HIDDEN;
|
||||
|
||||
|
|
|
@ -471,18 +471,6 @@ static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface
|
|||
/******************************************************************************
|
||||
* GetDeviceInfo : get information about a device's identity
|
||||
*/
|
||||
static HRESULT WINAPI SysKeyboardAImpl_GetDeviceInfo(
|
||||
LPDIRECTINPUTDEVICE8A iface,
|
||||
LPDIDEVICEINSTANCEA pdidi)
|
||||
{
|
||||
SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
|
||||
TRACE("(this=%p,%p)\n", This, pdidi);
|
||||
|
||||
fill_keyboard_dideviceinstanceA(pdidi, This->base.dinput->dwVersion, This->subtype);
|
||||
|
||||
return DI_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi)
|
||||
{
|
||||
SysKeyboardImpl *This = impl_from_IDirectInputDevice8W(iface);
|
||||
|
@ -653,7 +641,7 @@ static const IDirectInputDevice8AVtbl SysKeyboardAvt =
|
|||
IDirectInputDevice2AImpl_SetEventNotification,
|
||||
IDirectInputDevice2AImpl_SetCooperativeLevel,
|
||||
IDirectInputDevice2AImpl_GetObjectInfo,
|
||||
SysKeyboardAImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2AImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2AImpl_RunControlPanel,
|
||||
IDirectInputDevice2AImpl_Initialize,
|
||||
IDirectInputDevice2AImpl_CreateEffect,
|
||||
|
|
|
@ -782,18 +782,6 @@ static HRESULT WINAPI SysMouseWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
|
|||
/******************************************************************************
|
||||
* GetDeviceInfo : get information about a device's identity
|
||||
*/
|
||||
static HRESULT WINAPI SysMouseAImpl_GetDeviceInfo(
|
||||
LPDIRECTINPUTDEVICE8A iface,
|
||||
LPDIDEVICEINSTANCEA pdidi)
|
||||
{
|
||||
SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
|
||||
TRACE("(this=%p,%p)\n", This, pdidi);
|
||||
|
||||
fill_mouse_dideviceinstanceA(pdidi, This->base.dinput->dwVersion);
|
||||
|
||||
return DI_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI SysMouseWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi)
|
||||
{
|
||||
SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface);
|
||||
|
@ -906,7 +894,7 @@ static const IDirectInputDevice8AVtbl SysMouseAvt =
|
|||
IDirectInputDevice2AImpl_SetEventNotification,
|
||||
IDirectInputDevice2AImpl_SetCooperativeLevel,
|
||||
IDirectInputDevice2AImpl_GetObjectInfo,
|
||||
SysMouseAImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2AImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2AImpl_RunControlPanel,
|
||||
IDirectInputDevice2AImpl_Initialize,
|
||||
IDirectInputDevice2AImpl_CreateEffect,
|
||||
|
|
Loading…
Reference in New Issue