dinput: Factor out IDirectInputDevice_GetObjectInfo 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
49c66a3a94
commit
08d07c4cc2
|
@ -169,6 +169,25 @@ HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel( IDirectInputDevice8
|
|||
return IDirectInputDevice8_SetCooperativeLevel( iface_w, window, flags );
|
||||
}
|
||||
|
||||
HRESULT WINAPI IDirectInputDevice2AImpl_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 );
|
||||
DIDEVICEOBJECTINSTANCEW instance_w = {sizeof(instance_w)};
|
||||
HRESULT hr;
|
||||
|
||||
if (!instance_a) return E_POINTER;
|
||||
if (instance_a->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) &&
|
||||
instance_a->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A))
|
||||
return DIERR_INVALIDPARAM;
|
||||
|
||||
hr = IDirectInputDevice8_GetObjectInfo( iface_w, &instance_w, obj, how );
|
||||
dideviceobjectinstance_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 );
|
||||
|
|
|
@ -1447,38 +1447,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetProperty(
|
|||
return DI_OK;
|
||||
}
|
||||
|
||||
HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
|
||||
LPDIRECTINPUTDEVICE8A iface,
|
||||
LPDIDEVICEOBJECTINSTANCEA pdidoi,
|
||||
DWORD dwObj,
|
||||
DWORD dwHow)
|
||||
{
|
||||
IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
|
||||
DIDEVICEOBJECTINSTANCEW didoiW;
|
||||
HRESULT res;
|
||||
|
||||
if (!pdidoi) return E_POINTER;
|
||||
if (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) &&
|
||||
pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A))
|
||||
return DIERR_INVALIDPARAM;
|
||||
|
||||
didoiW.dwSize = sizeof(didoiW);
|
||||
res = IDirectInputDevice2WImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This), &didoiW, dwObj, dwHow);
|
||||
if (res == DI_OK)
|
||||
{
|
||||
DWORD dwSize = pdidoi->dwSize;
|
||||
|
||||
memset(pdidoi, 0, pdidoi->dwSize);
|
||||
pdidoi->dwSize = dwSize;
|
||||
pdidoi->guidType = didoiW.guidType;
|
||||
pdidoi->dwOfs = didoiW.dwOfs;
|
||||
pdidoi->dwType = didoiW.dwType;
|
||||
pdidoi->dwFlags = didoiW.dwFlags;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(
|
||||
LPDIRECTINPUTDEVICE8W iface,
|
||||
LPDIDEVICEOBJECTINSTANCEW pdidoi,
|
||||
|
|
|
@ -574,33 +574,6 @@ HRESULT WINAPI JoystickWGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
|
|||
return res;
|
||||
}
|
||||
|
||||
HRESULT WINAPI JoystickAGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface,
|
||||
LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow)
|
||||
{
|
||||
JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface);
|
||||
HRESULT res;
|
||||
DIDEVICEOBJECTINSTANCEW didoiW;
|
||||
DWORD dwSize;
|
||||
|
||||
if (!pdidoi) return E_POINTER;
|
||||
if (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) &&
|
||||
pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A))
|
||||
return DIERR_INVALIDPARAM;
|
||||
|
||||
didoiW.dwSize = sizeof(didoiW);
|
||||
res = JoystickWGenericImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This), &didoiW, dwObj, dwHow);
|
||||
if (res != DI_OK) return res;
|
||||
|
||||
dwSize = pdidoi->dwSize;
|
||||
memset(pdidoi, 0, pdidoi->dwSize);
|
||||
memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName));
|
||||
pdidoi->dwSize = dwSize;
|
||||
WideCharToMultiByte(CP_ACP, 0, didoiW.tszName, -1, pdidoi->tszName,
|
||||
sizeof(pdidoi->tszName), NULL, NULL);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* GetProperty : get input device properties
|
||||
*/
|
||||
|
|
|
@ -918,7 +918,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt =
|
|||
IDirectInputDevice2AImpl_SetDataFormat,
|
||||
IDirectInputDevice2AImpl_SetEventNotification,
|
||||
IDirectInputDevice2AImpl_SetCooperativeLevel,
|
||||
JoystickAGenericImpl_GetObjectInfo,
|
||||
IDirectInputDevice2AImpl_GetObjectInfo,
|
||||
JoystickLinuxAImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2AImpl_RunControlPanel,
|
||||
IDirectInputDevice2AImpl_Initialize,
|
||||
|
|
|
@ -1439,7 +1439,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt =
|
|||
IDirectInputDevice2AImpl_SetDataFormat,
|
||||
IDirectInputDevice2AImpl_SetEventNotification,
|
||||
IDirectInputDevice2AImpl_SetCooperativeLevel,
|
||||
JoystickAGenericImpl_GetObjectInfo,
|
||||
IDirectInputDevice2AImpl_GetObjectInfo,
|
||||
JoystickAImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2AImpl_RunControlPanel,
|
||||
IDirectInputDevice2AImpl_Initialize,
|
||||
|
|
|
@ -1590,7 +1590,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt =
|
|||
IDirectInputDevice2AImpl_SetDataFormat,
|
||||
IDirectInputDevice2AImpl_SetEventNotification,
|
||||
IDirectInputDevice2AImpl_SetCooperativeLevel,
|
||||
JoystickAGenericImpl_GetObjectInfo,
|
||||
IDirectInputDevice2AImpl_GetObjectInfo,
|
||||
JoystickAGenericImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2AImpl_RunControlPanel,
|
||||
IDirectInputDevice2AImpl_Initialize,
|
||||
|
|
|
@ -62,9 +62,6 @@ BOOL device_disabled_registry(const char* name) DECLSPEC_HIDDEN;
|
|||
HRESULT WINAPI JoystickWGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
|
||||
LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) DECLSPEC_HIDDEN;
|
||||
|
||||
HRESULT WINAPI JoystickAGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface,
|
||||
LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) DECLSPEC_HIDDEN;
|
||||
|
||||
HRESULT WINAPI JoystickWGenericImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph) DECLSPEC_HIDDEN;
|
||||
|
||||
HRESULT WINAPI JoystickAGenericImpl_GetCapabilities(LPDIRECTINPUTDEVICE8A iface, LPDIDEVCAPS lpDIDevCaps) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -463,29 +463,6 @@ static DWORD map_dik_to_scan(DWORD dik_code, DWORD subtype)
|
|||
* GetObjectInfo : get information about a device object such as a button
|
||||
* or axis
|
||||
*/
|
||||
static HRESULT WINAPI
|
||||
SysKeyboardAImpl_GetObjectInfo(
|
||||
LPDIRECTINPUTDEVICE8A iface,
|
||||
LPDIDEVICEOBJECTINSTANCEA pdidoi,
|
||||
DWORD dwObj,
|
||||
DWORD dwHow)
|
||||
{
|
||||
SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
|
||||
HRESULT res;
|
||||
LONG scan;
|
||||
|
||||
res = IDirectInputDevice2AImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
|
||||
if (res != DI_OK) return res;
|
||||
|
||||
scan = map_dik_to_scan(DIDFT_GETINSTANCE(pdidoi->dwType), This->subtype);
|
||||
if (!GetKeyNameTextA((scan & 0x80) << 17 | (scan & 0x7f) << 16,
|
||||
pdidoi->tszName, sizeof(pdidoi->tszName)))
|
||||
return DIERR_OBJECTNOTFOUND;
|
||||
|
||||
_dump_OBJECTINSTANCEA(pdidoi);
|
||||
return res;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
|
||||
LPDIDEVICEOBJECTINSTANCEW pdidoi,
|
||||
DWORD dwObj,
|
||||
|
@ -691,7 +668,7 @@ static const IDirectInputDevice8AVtbl SysKeyboardAvt =
|
|||
IDirectInputDevice2AImpl_SetDataFormat,
|
||||
IDirectInputDevice2AImpl_SetEventNotification,
|
||||
IDirectInputDevice2AImpl_SetCooperativeLevel,
|
||||
SysKeyboardAImpl_GetObjectInfo,
|
||||
IDirectInputDevice2AImpl_GetObjectInfo,
|
||||
SysKeyboardAImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2AImpl_RunControlPanel,
|
||||
IDirectInputDevice2AImpl_Initialize,
|
||||
|
|
|
@ -796,33 +796,6 @@ static HRESULT WINAPI SysMouseWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
|
|||
return res;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI SysMouseAImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface,
|
||||
LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow)
|
||||
{
|
||||
SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
|
||||
HRESULT res;
|
||||
DIDEVICEOBJECTINSTANCEW didoiW;
|
||||
DWORD dwSize;
|
||||
|
||||
if (!pdidoi) return E_POINTER;
|
||||
if (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) &&
|
||||
pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A))
|
||||
return DIERR_INVALIDPARAM;
|
||||
|
||||
didoiW.dwSize = sizeof(didoiW);
|
||||
res = SysMouseWImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This), &didoiW, dwObj, dwHow);
|
||||
if (res != DI_OK) return res;
|
||||
|
||||
dwSize = pdidoi->dwSize;
|
||||
memset(pdidoi, 0, pdidoi->dwSize);
|
||||
memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName));
|
||||
pdidoi->dwSize = dwSize;
|
||||
WideCharToMultiByte(CP_ACP, 0, didoiW.tszName, -1, pdidoi->tszName,
|
||||
sizeof(pdidoi->tszName), NULL, NULL);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* GetDeviceInfo : get information about a device's identity
|
||||
*/
|
||||
|
@ -949,7 +922,7 @@ static const IDirectInputDevice8AVtbl SysMouseAvt =
|
|||
IDirectInputDevice2AImpl_SetDataFormat,
|
||||
IDirectInputDevice2AImpl_SetEventNotification,
|
||||
IDirectInputDevice2AImpl_SetCooperativeLevel,
|
||||
SysMouseAImpl_GetObjectInfo,
|
||||
IDirectInputDevice2AImpl_GetObjectInfo,
|
||||
SysMouseAImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2AImpl_RunControlPanel,
|
||||
IDirectInputDevice2AImpl_Initialize,
|
||||
|
|
Loading…
Reference in New Issue