Commit bfc80519 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dinput: Move IDirectInput8 WtoA wrappers to ansi.c.

parent 5ef24d12
......@@ -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, &params, 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,
&params, 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, &params_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, &params_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,
};
......@@ -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,
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment