Commit c405019e authored by Raphael Junqueira's avatar Raphael Junqueira Committed by Alexandre Julliard

- DInput WideChar classes support. This time all dinput versions have

widechar classes. - fix a stupid bug in callback handling caught by Lionel. - add some forgotten IID on class factory (better if we want to active the code) - many cleanups on COM Macros (don't need A and W variants as they are the same)
parent bf2121a3
......@@ -28,6 +28,7 @@
#include <string.h>
#include "wine/debug.h"
#include "wine/unicode.h"
#include "winbase.h"
#include "winerror.h"
#include "windef.h"
......@@ -107,6 +108,13 @@ void _dump_OBJECTINSTANCEA(DIDEVICEOBJECTINSTANCEA *ddoi) {
}
}
void _dump_OBJECTINSTANCEW(DIDEVICEOBJECTINSTANCEW *ddoi) {
if (TRACE_ON(dinput)) {
DPRINTF(" - enumerating : %s - %2ld - 0x%08lx - %s\n",
debugstr_guid(&ddoi->guidType), ddoi->dwOfs, ddoi->dwType, debugstr_w(ddoi->tszName));
}
}
/* Conversion between internal data buffer and external data buffer */
void fill_DataFormat(void *out, void *in, DataFormat *df) {
int i;
......@@ -267,6 +275,39 @@ DataFormat *create_DataFormat(DIDATAFORMAT *wine_format, LPCDIDATAFORMAT asked_f
return ret;
}
BOOL DIEnumDevicesCallbackAtoW(LPCDIDEVICEOBJECTINSTANCEA lpddi, LPVOID lpvRef) {
DIDEVICEOBJECTINSTANCEW ddtmp;
device_enumobjects_AtoWcb_data* data;
data = (device_enumobjects_AtoWcb_data*) lpvRef;
memset(&ddtmp, 0, sizeof(DIDEVICEINSTANCEW));
ddtmp.dwSize = sizeof(DIDEVICEINSTANCEW);
ddtmp.guidType = lpddi->guidType;
ddtmp.dwOfs = lpddi->dwOfs;
ddtmp.dwType = lpddi->dwType;
ddtmp.dwFlags = lpddi->dwFlags;
MultiByteToWideChar(CP_ACP, 0, lpddi->tszName, -1, ddtmp.tszName, MAX_PATH);
if (lpddi->dwSize == sizeof(DIDEVICEINSTANCEA)) {
/**
* if dwSize < sizeof(DIDEVICEINSTANCEA of DInput version >= 5)
* force feedback and other newer datas aren't available
*/
ddtmp.dwFFMaxForce = lpddi->dwFFMaxForce;
ddtmp.dwFFForceResolution = lpddi->dwFFForceResolution;
ddtmp.wCollectionNumber = lpddi->wCollectionNumber;
ddtmp.wDesignatorIndex = lpddi->wDesignatorIndex;
ddtmp.wUsagePage = lpddi->wUsagePage;
ddtmp.wUsage = lpddi->wUsage;
ddtmp.dwDimension = lpddi->dwDimension;
ddtmp.wExponent = lpddi->wExponent;
ddtmp.wReserved = lpddi->wReserved;
}
return data->lpCallBack(&ddtmp, data->lpvRef);
}
/******************************************************************************
* IDirectInputDeviceA
*/
......@@ -355,6 +396,37 @@ HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(
return E_FAIL;
}
HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(
LPDIRECTINPUTDEVICE8W iface,REFIID riid,LPVOID *ppobj
)
{
ICOM_THIS(IDirectInputDevice2AImpl,iface);
TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (IsEqualGUID(&IID_IUnknown,riid)) {
IDirectInputDevice2_AddRef(iface);
*ppobj = This;
return DI_OK;
}
if (IsEqualGUID(&IID_IDirectInputDeviceW,riid)) {
IDirectInputDevice2_AddRef(iface);
*ppobj = This;
return DI_OK;
}
if (IsEqualGUID(&IID_IDirectInputDevice2W,riid)) {
IDirectInputDevice2_AddRef(iface);
*ppobj = This;
return DI_OK;
}
if (IsEqualGUID(&IID_IDirectInputDevice7W,riid)) {
IDirectInputDevice7_AddRef(iface);
*ppobj = This;
return DI_OK;
}
TRACE("Unsupported interface !\n");
return E_FAIL;
}
ULONG WINAPI IDirectInputDevice2AImpl_AddRef(
LPDIRECTINPUTDEVICE8A iface)
{
......@@ -378,6 +450,22 @@ HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(
LPDIRECTINPUTDEVICE8W iface,
LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
LPVOID lpvRef,
DWORD dwFlags)
{
FIXME("(this=%p,%p,%p,%08lx): stub!\n", iface, lpCallback, lpvRef, dwFlags);
if (TRACE_ON(dinput)) {
DPRINTF(" - flags = ");
_dump_EnumObjects_flags(dwFlags);
DPRINTF("\n");
}
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(
LPDIRECTINPUTDEVICE8A iface,
REFGUID rguid,
......@@ -404,6 +492,18 @@ HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(
LPDIRECTINPUTDEVICE8W iface,
LPDIDEVICEOBJECTINSTANCEW pdidoi,
DWORD dwObj,
DWORD dwHow)
{
FIXME("(this=%p,%p,%ld,0x%08lx): stub!\n",
iface, pdidoi, dwObj, dwHow);
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo(
LPDIRECTINPUTDEVICE8A iface,
LPDIDEVICEINSTANCEA pdidi)
......@@ -413,6 +513,15 @@ HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo(
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceInfo(
LPDIRECTINPUTDEVICE8W iface,
LPDIDEVICEINSTANCEW pdidi)
{
FIXME("(this=%p,%p): stub!\n",
iface, pdidi);
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(
LPDIRECTINPUTDEVICE8A iface,
......@@ -466,6 +575,20 @@ HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects(
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects(
LPDIRECTINPUTDEVICE8W iface,
LPDIENUMEFFECTSCALLBACKW lpCallback,
LPVOID lpvRef,
DWORD dwFlags)
{
FIXME("(this=%p,%p,%p,0x%08lx): stub!\n",
iface, lpCallback, lpvRef, dwFlags);
if (lpCallback)
lpCallback(NULL, lpvRef);
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo(
LPDIRECTINPUTDEVICE8A iface,
LPDIEFFECTINFOA lpdei,
......@@ -476,6 +599,16 @@ HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo(
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo(
LPDIRECTINPUTDEVICE8W iface,
LPDIEFFECTINFOW lpdei,
REFGUID rguid)
{
FIXME("(this=%p,%p,%s): stub!\n",
iface, lpdei, debugstr_guid(rguid));
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(
LPDIRECTINPUTDEVICE8A iface,
LPDWORD pdwOut)
......@@ -547,6 +680,17 @@ HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8W iface,
LPCWSTR lpszFileName,
LPDIENUMEFFECTSINFILECALLBACK pec,
LPVOID pvRef,
DWORD dwFlags)
{
FIXME("(%p)->(%s,%p,%p,%08lx): stub !\n", iface, debugstr_w(lpszFileName), pec, pvRef, dwFlags);
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface,
LPCSTR lpszFileName,
DWORD dwEntries,
......@@ -558,6 +702,17 @@ HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice7WImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8W iface,
LPCWSTR lpszFileName,
DWORD dwEntries,
LPDIFILEEFFECT rgDiFileEft,
DWORD dwFlags)
{
FIXME("(%p)->(%s,%08lx,%p,%08lx): stub !\n", iface, debugstr_w(lpszFileName), dwEntries, rgDiFileEft, dwFlags);
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
LPDIACTIONFORMATA lpdiaf,
LPCSTR lpszUserName,
......@@ -568,6 +723,16 @@ HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A ifa
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
LPDIACTIONFORMATW lpdiaf,
LPCWSTR lpszUserName,
DWORD dwFlags)
{
FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
LPDIACTIONFORMATA lpdiaf,
LPCSTR lpszUserName,
......@@ -578,6 +743,16 @@ HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
LPDIACTIONFORMATW lpdiaf,
LPCWSTR lpszUserName,
DWORD dwFlags)
{
FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface,
LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader)
{
......@@ -585,3 +760,11 @@ HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface,
LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader)
{
FIXME("(%p)->(%p): stub !\n", iface, lpdiDevImageInfoHeader);
return DI_OK;
}
......@@ -70,12 +70,24 @@ extern DataFormat *create_DataFormat(DIDATAFORMAT *wine_format, LPCDIDATAFORMAT
} \
}
/**
* Callback Data used by specific callback
* for EnumObject on 'W' interfaces
*/
typedef struct {
LPDIENUMDEVICEOBJECTSCALLBACKW lpCallBack;
LPVOID lpvRef;
} device_enumobjects_AtoWcb_data;
extern BOOL DIEnumDevicesCallbackAtoW(LPCDIDEVICEOBJECTINSTANCEA, LPVOID);
/* Various debug tools */
extern void _dump_cooperativelevel_DI(DWORD dwFlags) ;
extern void _dump_EnumObjects_flags(DWORD dwFlags) ;
extern void _dump_DIPROPHEADER(DIPROPHEADER *diph) ;
extern void _dump_OBJECTINSTANCEA(DIDEVICEOBJECTINSTANCEA *ddoi) ;
extern void _dump_OBJECTINSTANCEW(DIDEVICEOBJECTINSTANCEW *ddoi) ;
/* And the stubs */
extern HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(
......@@ -85,8 +97,8 @@ extern HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(
extern HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(
LPDIRECTINPUTDEVICE8A iface,HANDLE hnd ) ;
extern ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface) ;
extern HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(
LPDIRECTINPUTDEVICE8A iface,REFIID riid,LPVOID *ppobj ) ;
extern HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(LPDIRECTINPUTDEVICE8A iface,REFIID riid,LPVOID *ppobj);
extern HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(LPDIRECTINPUTDEVICE8W iface,REFIID riid,LPVOID *ppobj);
extern ULONG WINAPI IDirectInputDevice2AImpl_AddRef(
LPDIRECTINPUTDEVICE8A iface) ;
extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(
......@@ -94,6 +106,11 @@ extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(
LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
LPVOID lpvRef,
DWORD dwFlags) ;
extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(
LPDIRECTINPUTDEVICE8W iface,
LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
LPVOID lpvRef,
DWORD dwFlags) ;
extern HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(
LPDIRECTINPUTDEVICE8A iface,
REFGUID rguid,
......@@ -103,9 +120,16 @@ extern HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
LPDIDEVICEOBJECTINSTANCEA pdidoi,
DWORD dwObj,
DWORD dwHow) ;
extern HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
LPDIDEVICEOBJECTINSTANCEW pdidoi,
DWORD dwObj,
DWORD dwHow);
extern HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo(
LPDIRECTINPUTDEVICE8A iface,
LPDIDEVICEINSTANCEA pdidi) ;
extern HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceInfo(
LPDIRECTINPUTDEVICE8W iface,
LPDIDEVICEINSTANCEW pdidi) ;
extern HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(
LPDIRECTINPUTDEVICE8A iface,
HWND hwndOwner,
......@@ -126,10 +150,19 @@ extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects(
LPDIENUMEFFECTSCALLBACKA lpCallback,
LPVOID lpvRef,
DWORD dwFlags) ;
extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects(
LPDIRECTINPUTDEVICE8W iface,
LPDIENUMEFFECTSCALLBACKW lpCallback,
LPVOID lpvRef,
DWORD dwFlags) ;
extern HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo(
LPDIRECTINPUTDEVICE8A iface,
LPDIEFFECTINFOA lpdei,
REFGUID rguid) ;
extern HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo(
LPDIRECTINPUTDEVICE8W iface,
LPDIEFFECTINFOW lpdei,
REFGUID rguid) ;
extern HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(
LPDIRECTINPUTDEVICE8A iface,
LPDWORD pdwOut) ;
......@@ -157,20 +190,40 @@ extern HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDE
LPDIENUMEFFECTSINFILECALLBACK pec,
LPVOID pvRef,
DWORD dwFlags) ;
extern HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8W iface,
LPCWSTR lpszFileName,
LPDIENUMEFFECTSINFILECALLBACK pec,
LPVOID pvRef,
DWORD dwFlags) ;
extern HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface,
LPCSTR lpszFileName,
DWORD dwEntries,
LPDIFILEEFFECT rgDiFileEft,
DWORD dwFlags) ;
extern HRESULT WINAPI IDirectInputDevice7WImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8W iface,
LPCWSTR lpszFileName,
DWORD dwEntries,
LPDIFILEEFFECT rgDiFileEft,
DWORD dwFlags) ;
extern HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
LPDIACTIONFORMATA lpdiaf,
LPCSTR lpszUserName,
DWORD dwFlags);
extern HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
LPDIACTIONFORMATW lpdiaf,
LPCWSTR lpszUserName,
DWORD dwFlags);
extern HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
LPDIACTIONFORMATA lpdiaf,
LPCSTR lpszUserName,
DWORD dwFlags);
extern HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
LPDIACTIONFORMATW lpdiaf,
LPCWSTR lpszUserName,
DWORD dwFlags);
extern HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface,
LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader);
extern HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface,
LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader);
#endif /* __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H */
@ stdcall DirectInputCreateA(long long ptr ptr)
@ stub DirectInputCreateW
@ stdcall DirectInputCreateW(long long ptr ptr)
@ stdcall DirectInputCreateEx(long long ptr ptr ptr)
@ stdcall DllCanUnloadNow() DINPUT_DllCanUnloadNow
@ stdcall DllGetClassObject(ptr ptr ptr) DINPUT_DllGetClassObject
......
......@@ -34,6 +34,7 @@
#include <string.h>
#include "wine/debug.h"
#include "wine/unicode.h"
#include "winbase.h"
#include "winuser.h"
#include "winerror.h"
......@@ -43,7 +44,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
static ICOM_VTABLE(IDirectInput7A) ddi7avt;
static ICOM_VTABLE(IDirectInput7W) ddi7wvt;
static ICOM_VTABLE(IDirectInput8A) ddi8avt;
static ICOM_VTABLE(IDirectInput8W) ddi8wvt;
/* This array will be filled a dinput.so loading */
#define MAX_WINE_DINPUT_DEVICES 4
......@@ -94,17 +97,16 @@ void dinput_register_device(dinput_device *device) {
*/
HRESULT WINAPI DirectInputCreateEx(
HINSTANCE hinst, DWORD dwVersion, REFIID riid, LPVOID *ppDI,
LPUNKNOWN punkOuter
) {
IDirectInputAImpl* This;
LPUNKNOWN punkOuter)
{
IDirectInputImpl* This;
TRACE("(0x%08lx,%04lx,%s,%p,%p)\n", (DWORD)hinst,dwVersion,debugstr_guid(riid),ppDI,punkOuter);
TRACE("(0x%08lx,%04lx,%s,%p,%p)\n",
(DWORD)hinst,dwVersion,debugstr_guid(riid),ppDI,punkOuter
);
if (IsEqualGUID(&IID_IDirectInputA,riid) ||
IsEqualGUID(&IID_IDirectInput2A,riid) ||
IsEqualGUID(&IID_IDirectInput7A,riid)) {
This = (IDirectInputAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputAImpl));
This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi7avt;
This->ref = 1;
This->version = 1;
......@@ -113,9 +115,20 @@ HRESULT WINAPI DirectInputCreateEx(
return DI_OK;
}
if (IsEqualGUID(&IID_IDirectInputW,riid) ||
IsEqualGUID(&IID_IDirectInput2W,riid) ||
IsEqualGUID(&IID_IDirectInput7W,riid)) {
This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi7wvt;
This->ref = 1;
This->version = 1;
*ppDI = This;
return DI_OK;
}
if (IsEqualGUID(&IID_IDirectInput8A,riid)) {
This = (IDirectInputAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputAImpl));
This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi8avt;
This->ref = 1;
This->version = 8;
......@@ -124,6 +137,16 @@ HRESULT WINAPI DirectInputCreateEx(
return DI_OK;
}
if (IsEqualGUID(&IID_IDirectInput8W,riid)) {
This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi8wvt;
This->ref = 1;
This->version = 8;
*ppDI = This;
return DI_OK;
}
return DIERR_OLDDIRECTINPUTVERSION;
}
......@@ -132,26 +155,39 @@ HRESULT WINAPI DirectInputCreateEx(
*/
HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter)
{
IDirectInputAImpl* This;
TRACE("(0x%08lx,%04lx,%p,%p)\n",
(DWORD)hinst,dwVersion,ppDI,punkOuter
);
This = (IDirectInputAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputAImpl));
IDirectInputImpl* This;
TRACE("(0x%08lx,%04lx,%p,%p)\n", (DWORD)hinst,dwVersion,ppDI,punkOuter);
This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi7avt;
This->ref = 1;
*ppDI=(IDirectInputA*)This;
*ppDI = (IDirectInputA*)This;
return 0;
}
/******************************************************************************
* DirectInputCreateW (DINPUT.@)
*/
HRESULT WINAPI DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTW *ppDI, LPUNKNOWN punkOuter)
{
IDirectInputImpl* This;
TRACE("(0x%08lx,%04lx,%p,%p)\n", (DWORD)hinst,dwVersion,ppDI,punkOuter);
This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi7wvt;
This->ref = 1;
*ppDI = (IDirectInputW*)This;
return 0;
}
/******************************************************************************
* IDirectInputA_EnumDevices
*/
static HRESULT WINAPI IDirectInputAImpl_EnumDevices(
LPDIRECTINPUT7A iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback,
LPVOID pvRef, DWORD dwFlags
)
LPVOID pvRef, DWORD dwFlags)
{
ICOM_THIS(IDirectInputAImpl,iface);
ICOM_THIS(IDirectInputImpl,iface);
DIDEVICEINSTANCEA devInstance;
int i;
......@@ -159,7 +195,7 @@ static HRESULT WINAPI IDirectInputAImpl_EnumDevices(
for (i = 0; i < nrof_dinput_devices; i++) {
devInstance.dwSize = sizeof(devInstance);
if (dinput_devices[i]->enum_device(dwDevType, dwFlags, &devInstance, This->version)) {
if (dinput_devices[i]->enum_deviceA(dwDevType, dwFlags, &devInstance, This->version)) {
if (lpCallback(&devInstance,pvRef) == DIENUM_STOP)
return 0;
}
......@@ -167,34 +203,39 @@ static HRESULT WINAPI IDirectInputAImpl_EnumDevices(
return 0;
}
/******************************************************************************
* IDirectInputW_EnumDevices
*/
static HRESULT WINAPI IDirectInputWImpl_EnumDevices(
LPDIRECTINPUT7W iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback,
LPVOID pvRef, DWORD dwFlags)
{
ICOM_THIS(IDirectInputImpl,iface);
DIDEVICEINSTANCEW devInstance;
int i;
static HRESULT WINAPI IDirectInputAImpl_QueryInterface(
LPDIRECTINPUT7A iface,REFIID riid,LPVOID *ppobj
) {
ICOM_THIS(IDirectInputAImpl,iface);
TRACE("(this=%p,0x%04lx,%p,%p,%04lx)\n", This, dwDevType, lpCallback, pvRef, dwFlags);
TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (IsEqualGUID(&IID_IUnknown,riid) ||
IsEqualGUID(&IID_IDirectInputA,riid) ||
IsEqualGUID(&IID_IDirectInput2A,riid) ||
IsEqualGUID(&IID_IDirectInput7A,riid)) {
IDirectInputA_AddRef(iface);
*ppobj = This;
return 0;
for (i = 0; i < nrof_dinput_devices; i++) {
devInstance.dwSize = sizeof(devInstance);
if (dinput_devices[i]->enum_deviceW(dwDevType, dwFlags, &devInstance, This->version)) {
if (lpCallback(&devInstance,pvRef) == DIENUM_STOP)
return 0;
}
}
TRACE("Unsupported interface !\n");
return E_FAIL;
return 0;
}
static ULONG WINAPI IDirectInputAImpl_AddRef(LPDIRECTINPUT7A iface)
{
ICOM_THIS(IDirectInputAImpl,iface);
ICOM_THIS(IDirectInputImpl,iface);
return ++(This->ref);
}
static ULONG WINAPI IDirectInputAImpl_Release(LPDIRECTINPUT7A iface)
{
ICOM_THIS(IDirectInputAImpl,iface);
ICOM_THIS(IDirectInputImpl,iface);
if (!(--This->ref)) {
HeapFree(GetProcessHeap(),0,This);
return 0;
......@@ -202,11 +243,43 @@ static ULONG WINAPI IDirectInputAImpl_Release(LPDIRECTINPUT7A iface)
return This->ref;
}
static HRESULT WINAPI IDirectInputAImpl_QueryInterface(LPDIRECTINPUT7A iface, REFIID riid, LPVOID *ppobj) {
ICOM_THIS(IDirectInputImpl,iface);
TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (IsEqualGUID(&IID_IUnknown,riid) ||
IsEqualGUID(&IID_IDirectInputA,riid) ||
IsEqualGUID(&IID_IDirectInput2A,riid) ||
IsEqualGUID(&IID_IDirectInput7A,riid)) {
IDirectInputAImpl_AddRef(iface);
*ppobj = This;
return 0;
}
TRACE("Unsupported interface !\n");
return E_FAIL;
}
static HRESULT WINAPI IDirectInputWImpl_QueryInterface(LPDIRECTINPUT7W iface, REFIID riid, LPVOID *ppobj) {
ICOM_THIS(IDirectInputImpl,iface);
TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (IsEqualGUID(&IID_IUnknown,riid) ||
IsEqualGUID(&IID_IDirectInputW,riid) ||
IsEqualGUID(&IID_IDirectInput2W,riid) ||
IsEqualGUID(&IID_IDirectInput7W,riid)) {
IDirectInputAImpl_AddRef((LPDIRECTINPUT7A) iface);
*ppobj = This;
return 0;
}
TRACE("Unsupported interface !\n");
return E_FAIL;
}
static HRESULT WINAPI IDirectInputAImpl_CreateDevice(
LPDIRECTINPUT7A iface,REFGUID rguid,LPDIRECTINPUTDEVICEA* pdev,
LPUNKNOWN punk
) {
ICOM_THIS(IDirectInputAImpl,iface);
ICOM_THIS(IDirectInputImpl,iface);
HRESULT ret_value = DIERR_DEVICENOTREG;
int i;
......@@ -215,7 +288,7 @@ static HRESULT WINAPI IDirectInputAImpl_CreateDevice(
/* Loop on all the devices to see if anyone matches the given GUID */
for (i = 0; i < nrof_dinput_devices; i++) {
HRESULT ret;
if ((ret = dinput_devices[i]->create_device(This, rguid, NULL, pdev)) == DI_OK)
if ((ret = dinput_devices[i]->create_deviceA(This, rguid, NULL, pdev)) == DI_OK)
return DI_OK;
if (ret == DIERR_NOINTERFACE)
......@@ -225,15 +298,34 @@ static HRESULT WINAPI IDirectInputAImpl_CreateDevice(
return ret_value;
}
static HRESULT WINAPI IDirectInputAImpl_Initialize(
LPDIRECTINPUT7A iface,HINSTANCE hinst,DWORD x
) {
static HRESULT WINAPI IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7A iface,
REFGUID rguid, LPDIRECTINPUTDEVICEW* pdev, LPUNKNOWN punk) {
ICOM_THIS(IDirectInputImpl,iface);
HRESULT ret_value = DIERR_DEVICENOTREG;
int i;
TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
/* Loop on all the devices to see if anyone matches the given GUID */
for (i = 0; i < nrof_dinput_devices; i++) {
HRESULT ret;
if ((ret = dinput_devices[i]->create_deviceW(This, rguid, NULL, pdev)) == DI_OK)
return DI_OK;
if (ret == DIERR_NOINTERFACE)
ret_value = DIERR_NOINTERFACE;
}
return ret_value;
}
static HRESULT WINAPI IDirectInputAImpl_Initialize(LPDIRECTINPUT7A iface, HINSTANCE hinst, DWORD x) {
return DIERR_ALREADYINITIALIZED;
}
static HRESULT WINAPI IDirectInputAImpl_GetDeviceStatus(LPDIRECTINPUT7A iface,
REFGUID rguid) {
ICOM_THIS(IDirectInputAImpl,iface);
ICOM_THIS(IDirectInputImpl,iface);
FIXME("(%p)->(%s): stub\n",This,debugstr_guid(rguid));
......@@ -243,7 +335,7 @@ static HRESULT WINAPI IDirectInputAImpl_GetDeviceStatus(LPDIRECTINPUT7A iface,
static HRESULT WINAPI IDirectInputAImpl_RunControlPanel(LPDIRECTINPUT7A iface,
HWND hwndOwner,
DWORD dwFlags) {
ICOM_THIS(IDirectInputAImpl,iface);
ICOM_THIS(IDirectInputImpl,iface);
FIXME("(%p)->(%08lx,%08lx): stub\n",This, (DWORD) hwndOwner, dwFlags);
return DI_OK;
......@@ -251,16 +343,24 @@ static HRESULT WINAPI IDirectInputAImpl_RunControlPanel(LPDIRECTINPUT7A iface,
static HRESULT WINAPI IDirectInput2AImpl_FindDevice(LPDIRECTINPUT7A iface, REFGUID rguid,
LPCSTR pszName, LPGUID pguidInstance) {
ICOM_THIS(IDirectInputAImpl,iface);
ICOM_THIS(IDirectInputImpl,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) {
ICOM_THIS(IDirectInputImpl,iface);
FIXME("(%p)->(%s, %s, %p): stub\n", This, debugstr_guid(rguid), debugstr_w(pszName), pguidInstance);
return DI_OK;
}
static HRESULT WINAPI IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface, REFGUID rguid,
REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter)
{
ICOM_THIS(IDirectInputAImpl,iface);
ICOM_THIS(IDirectInputImpl,iface);
HRESULT ret_value = DIERR_DEVICENOTREG;
int i;
......@@ -269,7 +369,7 @@ static HRESULT WINAPI IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface, R
/* Loop on all the devices to see if anyone matches the given GUID */
for (i = 0; i < nrof_dinput_devices; i++) {
HRESULT ret;
if ((ret = dinput_devices[i]->create_device(This, rguid, riid, (LPDIRECTINPUTDEVICEA*) pvOut)) == DI_OK)
if ((ret = dinput_devices[i]->create_deviceA(This, rguid, riid, (LPDIRECTINPUTDEVICEA*) pvOut)) == DI_OK)
return DI_OK;
if (ret == DIERR_NOINTERFACE)
......@@ -279,20 +379,54 @@ static HRESULT WINAPI IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface, R
return ret_value;
}
static HRESULT WINAPI IDirectInput8AImpl_QueryInterface(
LPDIRECTINPUT8A iface,REFIID riid,LPVOID *ppobj
) {
ICOM_THIS(IDirectInputAImpl,iface);
static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, REFGUID rguid,
REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter)
{
ICOM_THIS(IDirectInputImpl,iface);
HRESULT ret_value = DIERR_DEVICENOTREG;
int i;
TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
/* Loop on all the devices to see if anyone matches the given GUID */
for (i = 0; i < nrof_dinput_devices; i++) {
HRESULT ret;
if ((ret = dinput_devices[i]->create_deviceW(This, rguid, riid, (LPDIRECTINPUTDEVICEW*) pvOut)) == DI_OK)
return DI_OK;
if (ret == DIERR_NOINTERFACE)
ret_value = DIERR_NOINTERFACE;
}
return ret_value;
}
static HRESULT WINAPI IDirectInput8AImpl_QueryInterface(LPDIRECTINPUT8A iface, REFIID riid, LPVOID *ppobj) {
ICOM_THIS(IDirectInputImpl,iface);
TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (IsEqualGUID(&IID_IUnknown,riid) ||
IsEqualGUID(&IID_IDirectInput8A,riid)) {
IDirectInputA_AddRef(iface);
IDirectInputAImpl_AddRef((LPDIRECTINPUT7A) iface);
*ppobj = This;
return 0;
}
TRACE("Unsupported interface !\n");
return E_NOINTERFACE;
}
static HRESULT WINAPI IDirectInput8WImpl_QueryInterface(LPDIRECTINPUT8W iface, REFIID riid, LPVOID *ppobj) {
ICOM_THIS(IDirectInputImpl,iface);
TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (IsEqualGUID(&IID_IUnknown,riid) ||
IsEqualGUID(&IID_IDirectInput8W,riid)) {
IDirectInputAImpl_AddRef((LPDIRECTINPUT7A) iface);
*ppobj = This;
return 0;
}
TRACE("Unsupported interface !\n");
return E_FAIL;
return E_NOINTERFACE;
}
static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics(
......@@ -301,19 +435,44 @@ static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics(
LPVOID pvRef, DWORD dwFlags
)
{
ICOM_THIS(IDirectInputAImpl,iface);
ICOM_THIS(IDirectInputImpl,iface);
FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This, ptszUserName, lpdiActionFormat,
lpCallback, pvRef, dwFlags);
return 0;
}
static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics(
LPDIRECTINPUT8W iface, LPCWSTR ptszUserName, LPDIACTIONFORMATW lpdiActionFormat,
LPDIENUMDEVICESBYSEMANTICSCBW lpCallback,
LPVOID pvRef, DWORD dwFlags
)
{
ICOM_THIS(IDirectInputImpl,iface);
FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This, debugstr_w(ptszUserName), lpdiActionFormat,
lpCallback, pvRef, dwFlags);
return 0;
}
static HRESULT WINAPI IDirectInput8AImpl_ConfigureDevices(
LPDIRECTINPUT8A iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback,
LPDICONFIGUREDEVICESPARAMSA lpdiCDParams, DWORD dwFlags, LPVOID pvRefData
)
{
ICOM_THIS(IDirectInputAImpl,iface);
ICOM_THIS(IDirectInputImpl,iface);
FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This, lpdiCallback, lpdiCDParams,
dwFlags, pvRefData);
return 0;
}
static HRESULT WINAPI IDirectInput8WImpl_ConfigureDevices(
LPDIRECTINPUT8W iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback,
LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData
)
{
ICOM_THIS(IDirectInputImpl,iface);
FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This, lpdiCallback, lpdiCDParams,
dwFlags, pvRefData);
......@@ -337,7 +496,28 @@ static ICOM_VTABLE(IDirectInput7A) ddi7avt = {
XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
XCAST(Initialize)IDirectInputAImpl_Initialize,
XCAST(FindDevice)IDirectInput2AImpl_FindDevice,
IDirectInput7AImpl_CreateDeviceEx
XCAST(CreateDeviceEx)IDirectInput7AImpl_CreateDeviceEx
};
#undef XCAST
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(ddi7wvt.fun))
#else
# define XCAST(fun) (void*)
#endif
static ICOM_VTABLE(IDirectInput7W) ddi7wvt = {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
XCAST(QueryInterface)IDirectInputWImpl_QueryInterface,
XCAST(AddRef)IDirectInputAImpl_AddRef,
XCAST(Release)IDirectInputAImpl_Release,
XCAST(CreateDevice)IDirectInputWImpl_CreateDevice,
XCAST(EnumDevices)IDirectInputWImpl_EnumDevices,
XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
XCAST(Initialize)IDirectInputAImpl_Initialize,
XCAST(FindDevice)IDirectInput2WImpl_FindDevice,
XCAST(CreateDeviceEx)IDirectInput7WImpl_CreateDeviceEx
};
#undef XCAST
......@@ -358,8 +538,29 @@ static ICOM_VTABLE(IDirectInput8A) ddi8avt = {
XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
XCAST(Initialize)IDirectInputAImpl_Initialize,
XCAST(FindDevice)IDirectInput2AImpl_FindDevice,
IDirectInput8AImpl_EnumDevicesBySemantics,
IDirectInput8AImpl_ConfigureDevices
XCAST(EnumDevicesBySemantics)IDirectInput8AImpl_EnumDevicesBySemantics,
XCAST(ConfigureDevices)IDirectInput8AImpl_ConfigureDevices
};
#undef XCAST
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(ddi8wvt.fun))
#else
# define XCAST(fun) (void*)
#endif
static ICOM_VTABLE(IDirectInput8W) ddi8wvt = {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
XCAST(QueryInterface)IDirectInput8WImpl_QueryInterface,
XCAST(AddRef)IDirectInputAImpl_AddRef,
XCAST(Release)IDirectInputAImpl_Release,
XCAST(CreateDevice)IDirectInputWImpl_CreateDevice,
XCAST(EnumDevices)IDirectInputWImpl_EnumDevices,
XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
XCAST(Initialize)IDirectInputAImpl_Initialize,
XCAST(FindDevice)IDirectInput2WImpl_FindDevice,
XCAST(EnumDevicesBySemantics)IDirectInput8WImpl_EnumDevicesBySemantics,
XCAST(ConfigureDevices)IDirectInput8WImpl_ConfigureDevices
};
#undef XCAST
......@@ -398,9 +599,13 @@ static HRESULT WINAPI DICF_CreateInstance(
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
if ( IsEqualGUID( &IID_IDirectInputA, riid ) ||
IsEqualGUID( &IID_IDirectInputW, riid ) ||
IsEqualGUID( &IID_IDirectInput2A, riid ) ||
IsEqualGUID( &IID_IDirectInput2W, riid ) ||
IsEqualGUID( &IID_IDirectInput7A, riid ) ||
IsEqualGUID( &IID_IDirectInput8A, riid ) ) {
IsEqualGUID( &IID_IDirectInput7W, riid ) ||
IsEqualGUID( &IID_IDirectInput8A, riid ) ||
IsEqualGUID( &IID_IDirectInput8W, riid ) ) {
/* FIXME: reuse already created dinput if present? */
return DirectInputCreateEx(0,0,riid,ppobj,pOuter);
}
......
......@@ -23,8 +23,8 @@
#include "dinput.h"
/* Implementation specification */
typedef struct IDirectInputAImpl IDirectInputAImpl;
struct IDirectInputAImpl
typedef struct IDirectInputImpl IDirectInputImpl;
struct IDirectInputImpl
{
LPVOID lpVtbl;
DWORD ref;
......@@ -38,11 +38,13 @@ struct IDirectInputAImpl
/* Function called by all devices that Wine supports */
typedef struct dinput_device {
INT pref;
BOOL (*enum_device)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version);
HRESULT (*create_device)(IDirectInputAImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev);
BOOL (*enum_deviceA)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version);
BOOL (*enum_deviceW)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version);
HRESULT (*create_deviceA)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev);
HRESULT (*create_deviceW)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev);
} dinput_device;
extern void dinput_register_device(dinput_device *device) ;
extern void dinput_register_device(dinput_device *device);
extern HINSTANCE DINPUT_instance;
......
......@@ -47,6 +47,7 @@
#define JOYDEV "/dev/js0"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "winbase.h"
#include "winerror.h"
#include "windef.h"
......@@ -61,16 +62,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput);
#define WINE_JOYSTICK_AXIS_BASE 0
#define WINE_JOYSTICK_BUTTON_BASE 8
typedef struct JoystickAImpl JoystickAImpl;
typedef struct JoystickImpl JoystickImpl;
static ICOM_VTABLE(IDirectInputDevice8A) JoystickAvt;
struct JoystickAImpl
static ICOM_VTABLE(IDirectInputDevice8W) JoystickWvt;
struct JoystickImpl
{
LPVOID lpVtbl;
DWORD ref;
GUID guid;
/* The 'parent' DInput */
IDirectInputAImpl *dinput;
IDirectInputImpl *dinput;
/* joystick private */
int joyfd;
......@@ -89,7 +91,7 @@ static GUID DInput_Wine_Joystick_GUID = { /* 9e573ed9-7734-11d2-8d4a-23903fb6bdf
{0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
};
static BOOL joydev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version)
static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version)
{
int fd = -1;
......@@ -121,11 +123,43 @@ static BOOL joydev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANC
return FALSE;
}
static JoystickAImpl *alloc_device(REFGUID rguid, LPVOID jvt, IDirectInputAImpl *dinput)
static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version)
{
JoystickAImpl* newDevice;
int fd = -1;
if (dwFlags & DIEDFL_FORCEFEEDBACK)
return FALSE;
if ((dwDevType==0) || (GET_DIDEVICE_TYPE(dwDevType)==DIDEVTYPE_JOYSTICK)) {
/* check whether we have a joystick */
if ((fd = open(JOYDEV,O_RDONLY) != -1) || (errno!=ENODEV && errno!=ENOENT)) {
TRACE("Enumerating the linux Joystick device\n");
/* Return joystick */
lpddi->guidInstance = GUID_Joystick;
lpddi->guidProduct = DInput_Wine_Joystick_GUID;
/* we only support traditional joysticks for now */
lpddi->dwDevType = DIDEVTYPE_JOYSTICK |
(DIDEVTYPEJOYSTICK_TRADITIONAL<<8);
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickAImpl));
MultiByteToWideChar(CP_ACP, 0, "Joystick", -1, lpddi->tszInstanceName, MAX_PATH);
/* ioctl JSIOCGNAME(len) */
MultiByteToWideChar(CP_ACP, 0, "Wine Joystick", -1, lpddi->tszProductName, MAX_PATH);
lpddi->guidFFDriver = GUID_NULL;
if (fd != -1)
close(fd);
return TRUE;
}
}
return FALSE;
}
static JoystickImpl *alloc_device(REFGUID rguid, LPVOID jvt, IDirectInputImpl *dinput)
{
JoystickImpl* newDevice;
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl));
newDevice->lpVtbl = jvt;
newDevice->ref = 1;
newDevice->joyfd = -1;
......@@ -137,7 +171,7 @@ static JoystickAImpl *alloc_device(REFGUID rguid, LPVOID jvt, IDirectInputAImpl
return newDevice;
}
static HRESULT joydev_create_device(IDirectInputAImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
{
if ((IsEqualGUID(&GUID_Joystick,rguid)) ||
(IsEqualGUID(&DInput_Wine_Joystick_GUID,rguid))) {
......@@ -157,10 +191,32 @@ static HRESULT joydev_create_device(IDirectInputAImpl *dinput, REFGUID rguid, RE
return DIERR_DEVICENOTREG;
}
static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
{
if ((IsEqualGUID(&GUID_Joystick,rguid)) ||
(IsEqualGUID(&DInput_Wine_Joystick_GUID,rguid))) {
if ((riid == NULL) ||
IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
*pdev = (IDirectInputDeviceW*) alloc_device(rguid, &JoystickWvt, dinput);
TRACE("Creating a Joystick device (%p)\n", *pdev);
return DI_OK;
} else
return DIERR_NOINTERFACE;
}
return DIERR_DEVICENOTREG;
}
static dinput_device joydev = {
10,
joydev_enum_device,
joydev_create_device
joydev_enum_deviceA,
joydev_enum_deviceW,
joydev_create_deviceA,
joydev_create_deviceW
};
DECL_GLOBAL_CONSTRUCTOR(joydev_register) { dinput_register_device(&joydev); }
......@@ -170,7 +226,7 @@ DECL_GLOBAL_CONSTRUCTOR(joydev_register) { dinput_register_device(&joydev); }
*/
static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
{
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
This->ref--;
if (This->ref)
......@@ -195,7 +251,7 @@ static HRESULT WINAPI JoystickAImpl_SetDataFormat(
LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df
)
{
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
int i;
TRACE("(this=%p,%p)\n",This,df);
......@@ -227,7 +283,7 @@ static HRESULT WINAPI JoystickAImpl_SetDataFormat(
*/
static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
{
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
TRACE("(this=%p)\n",This);
if (This->joyfd!=-1)
......@@ -243,7 +299,7 @@ static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
*/
static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
{
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
TRACE("(this=%p)\n",This);
if (This->joyfd!=-1) {
......@@ -255,7 +311,7 @@ static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
#define map_axis(val) ((val+32768)*(This->lMax-This->lMin)/65536+This->lMin)
static void joy_polldev(JoystickAImpl *This) {
static void joy_polldev(JoystickImpl *This) {
struct timeval tv;
fd_set readfds;
struct js_event jse;
......@@ -305,7 +361,7 @@ static void joy_polldev(JoystickAImpl *This) {
static HRESULT WINAPI JoystickAImpl_GetDeviceState(
LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
) {
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
joy_polldev(This);
TRACE("(this=%p,0x%08lx,%p)\n",This,len,ptr);
......@@ -327,7 +383,7 @@ static HRESULT WINAPI JoystickAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
LPDWORD entries,
DWORD flags
) {
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
FIXME("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx),STUB!\n",This,dodsize,*entries,flags);
......@@ -348,7 +404,7 @@ static HRESULT WINAPI JoystickAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface,
REFGUID rguid,
LPCDIPROPHEADER ph)
{
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
FIXME("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
FIXME("ph.dwSize = %ld, ph.dwHeaderSize =%ld, ph.dwObj = %ld, ph.dwHow= %ld\n",ph->dwSize, ph->dwHeaderSize,ph->dwObj,ph->dwHow);
......@@ -390,7 +446,7 @@ static HRESULT WINAPI JoystickAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface,
static HRESULT WINAPI JoystickAImpl_SetEventNotification(
LPDIRECTINPUTDEVICE8A iface, HANDLE hnd
) {
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
TRACE("(this=%p,0x%08lx)\n",This,(DWORD)hnd);
This->hEvent = hnd;
......@@ -401,7 +457,7 @@ static HRESULT WINAPI JoystickAImpl_GetCapabilities(
LPDIRECTINPUTDEVICE8A iface,
LPDIDEVCAPS lpDIDevCaps)
{
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
BYTE axes,buttons;
int xfd = This->joyfd;
......@@ -425,7 +481,7 @@ static HRESULT WINAPI JoystickAImpl_GetCapabilities(
return DI_OK;
}
static HRESULT WINAPI JoystickAImpl_Poll(LPDIRECTINPUTDEVICE8A iface) {
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
TRACE("(),stub!\n");
joy_polldev(This);
......@@ -441,7 +497,7 @@ static HRESULT WINAPI JoystickAImpl_EnumObjects(
LPVOID lpvRef,
DWORD dwFlags)
{
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
DIDEVICEOBJECTINSTANCEA ddoi;
int xfd = This->joyfd;
......@@ -518,13 +574,32 @@ static HRESULT WINAPI JoystickAImpl_EnumObjects(
}
/******************************************************************************
* EnumObjects : enumerate the different buttons and axis...
*/
static HRESULT WINAPI JoystickWImpl_EnumObjects(
LPDIRECTINPUTDEVICE8W iface,
LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
LPVOID lpvRef,
DWORD dwFlags)
{
ICOM_THIS(JoystickImpl,iface);
device_enumobjects_AtoWcb_data data;
data.lpCallBack = lpCallback;
data.lpvRef = lpvRef;
return JoystickAImpl_EnumObjects((LPDIRECTINPUTDEVICE8A) This, (LPDIENUMDEVICEOBJECTSCALLBACKA) DIEnumDevicesCallbackAtoW, (LPVOID) &data, dwFlags);
}
/******************************************************************************
* GetProperty : get input device properties
*/
static HRESULT WINAPI JoystickAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
REFGUID rguid,
LPDIPROPHEADER pdiph)
{
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
TRACE("(this=%p,%s,%p): stub!\n",
iface, debugstr_guid(rguid), pdiph);
......@@ -602,4 +677,48 @@ static ICOM_VTABLE(IDirectInputDevice8A) JoystickAvt =
IDirectInputDevice8AImpl_GetImageInfo
};
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(SysJoystickWvt.fun))
#else
# define XCAST(fun) (void*)
#endif
static ICOM_VTABLE(IDirectInputDevice8W) SysJoystickWvt =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectInputDevice2WImpl_QueryInterface,
XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
XCAST(Release)JoystickAImpl_Release,
XCAST(GetCapabilities)JoystickAImpl_GetCapabilities,
JoystickWImpl_EnumObjects,
XCAST(GetProperty)JoystickAImpl_GetProperty,
XCAST(SetProperty)JoystickAImpl_SetProperty,
XCAST(Acquire)JoystickAImpl_Acquire,
XCAST(Unacquire)JoystickAImpl_Unacquire,
XCAST(GetDeviceState)JoystickAImpl_GetDeviceState,
XCAST(GetDeviceData)JoystickAImpl_GetDeviceData,
XCAST(SetDataFormat)JoystickAImpl_SetDataFormat,
XCAST(SetEventNotification)JoystickAImpl_SetEventNotification,
XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
IDirectInputDevice2WImpl_GetObjectInfo,
IDirectInputDevice2WImpl_GetDeviceInfo,
XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
IDirectInputDevice2WImpl_EnumEffects,
IDirectInputDevice2WImpl_GetEffectInfo,
XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
XCAST(Escape)IDirectInputDevice2AImpl_Escape,
XCAST(Poll)JoystickAImpl_Poll,
XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
IDirectInputDevice7WImpl_EnumEffectsInFile,
IDirectInputDevice7WImpl_WriteEffectToFile,
IDirectInputDevice8WImpl_BuildActionMap,
IDirectInputDevice8WImpl_SetActionMap,
IDirectInputDevice8WImpl_GetImageInfo
};
#undef XCAST
#endif /* HAVE_LINUX_22_JOYSTICK_API */
......@@ -53,6 +53,7 @@
#define EVDEVPREFIX "/dev/input/event"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "winbase.h"
#include "winerror.h"
#include "windef.h"
......@@ -67,9 +68,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput);
#define WINE_JOYSTICK_AXIS_BASE 0
#define WINE_JOYSTICK_BUTTON_BASE 8
typedef struct JoystickAImpl JoystickAImpl;
typedef struct JoystickImpl JoystickImpl;
static ICOM_VTABLE(IDirectInputDevice8A) JoystickAvt;
struct JoystickAImpl
static ICOM_VTABLE(IDirectInputDevice8W) JoystickWvt;
struct JoystickImpl
{
LPVOID lpVtbl;
DWORD ref;
......@@ -77,7 +79,7 @@ struct JoystickAImpl
/* The 'parent' DInput */
IDirectInputAImpl *dinput;
IDirectInputImpl *dinput;
/* joystick private */
/* what range and deadzone the game wants */
......@@ -122,15 +124,10 @@ static GUID DInput_Wine_Joystick_GUID = { /* 9e573eda-7734-11d2-8d4a-23903fb6bdf
#define test_bit(arr,bit) (((BYTE*)arr)[bit>>3]&(1<<(bit&7)))
static BOOL joydev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version)
static int joydev_have(void)
{
int i, fd, havejoy = 0;
if ((dwDevType != 0) && (GET_DIDEVICE_TYPE(dwDevType) != DIDEVTYPE_JOYSTICK))
return FALSE;
if (dwFlags & DIEDFL_FORCEFEEDBACK)
return FALSE;
int i, fd;
int havejoy = 0;
for (i=0;i<64;i++) {
char buf[200];
......@@ -164,6 +161,20 @@ static BOOL joydev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANC
if (havejoy || (errno==ENODEV))
break;
}
return havejoy;
}
static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version)
{
int havejoy = 0;
if ((dwDevType != 0) && (GET_DIDEVICE_TYPE(dwDevType) != DIDEVTYPE_JOYSTICK))
return FALSE;
if (dwFlags & DIEDFL_FORCEFEEDBACK)
return FALSE;
havejoy = joydev_have();
if (!havejoy)
return FALSE;
......@@ -175,21 +186,50 @@ static BOOL joydev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANC
lpddi->guidProduct = DInput_Wine_Joystick_GUID;
lpddi->guidFFDriver = GUID_NULL;
lpddi->dwDevType = DIDEVTYPE_JOYSTICK |
(DIDEVTYPEJOYSTICK_TRADITIONAL<<8);
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL<<8);
strcpy(lpddi->tszInstanceName, "Joystick");
strcpy(lpddi->tszInstanceName, "Joystick");
/* ioctl JSIOCGNAME(len) */
strcpy(lpddi->tszProductName, "Wine Joystick");
return TRUE;
}
static JoystickAImpl *alloc_device(REFGUID rguid, LPVOID jvt, IDirectInputAImpl *dinput)
static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version)
{
int havejoy = 0;
if ((dwDevType != 0) && (GET_DIDEVICE_TYPE(dwDevType) != DIDEVTYPE_JOYSTICK))
return FALSE;
if (dwFlags & DIEDFL_FORCEFEEDBACK)
return FALSE;
havejoy = joydev_have();
if (!havejoy)
return FALSE;
TRACE("Enumerating the linuxinput Joystick device\n");
/* Return joystick */
lpddi->guidInstance = GUID_Joystick;
lpddi->guidProduct = DInput_Wine_Joystick_GUID;
lpddi->guidFFDriver = GUID_NULL;
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL<<8);
MultiByteToWideChar(CP_ACP, 0, "Joystick", -1, lpddi->tszInstanceName, MAX_PATH);
/* ioctl JSIOCGNAME(len) */
MultiByteToWideChar(CP_ACP, 0, "Wine Joystick", -1, lpddi->tszProductName, MAX_PATH);
return TRUE;
}
static JoystickImpl *alloc_device(REFGUID rguid, LPVOID jvt, IDirectInputImpl *dinput)
{
JoystickAImpl* newDevice;
JoystickImpl* newDevice;
int i;
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickAImpl));
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl));
newDevice->lpVtbl = jvt;
newDevice->ref = 1;
newDevice->joyfd = -1;
......@@ -203,42 +243,11 @@ static JoystickAImpl *alloc_device(REFGUID rguid, LPVOID jvt, IDirectInputAImpl
return newDevice;
}
static HRESULT joydev_create_device(IDirectInputAImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
{
int i, fd, havejoy = 0;
int havejoy = 0;
for (i=0;i<64;i++) {
char buf[200];
BYTE absbits[(ABS_MAX+7)/8],keybits[(KEY_MAX+7)/8];
sprintf(buf,EVDEVPREFIX"%d",i);
if (-1!=(fd=open(buf,O_RDONLY))) {
if (-1==ioctl(fd,EVIOCGBIT(EV_ABS,sizeof(absbits)),absbits)) {
perror("EVIOCGBIT EV_ABS");
close(fd);
continue;
}
if (-1==ioctl(fd,EVIOCGBIT(EV_KEY,sizeof(keybits)),keybits)) {
perror("EVIOCGBIT EV_KEY");
close(fd);
continue;
}
/* A true joystick has at least axis X and Y, and at least 1
* button. copied from linux/drivers/input/joydev.c */
if (test_bit(absbits,ABS_X) && test_bit(absbits,ABS_Y) &&
( test_bit(keybits,BTN_TRIGGER) ||
test_bit(keybits,BTN_A) ||
test_bit(keybits,BTN_1)
)
) {
FIXME("found a joystick at %s!\n",buf);
havejoy = 1;
}
close(fd);
}
if (havejoy || (errno==ENODEV))
break;
}
havejoy = joydev_have();
if (!havejoy)
return DIERR_DEVICENOTREG;
......@@ -250,7 +259,34 @@ static HRESULT joydev_create_device(IDirectInputAImpl *dinput, REFGUID rguid, RE
IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
*pdev=(IDirectInputDeviceA*) alloc_device(rguid, &JoystickAvt, dinput);
*pdev = (IDirectInputDeviceA*) alloc_device(rguid, &JoystickAvt, dinput);
TRACE("Creating a Joystick device (%p)\n", *pdev);
return DI_OK;
} else
return DIERR_NOINTERFACE;
}
return DIERR_DEVICENOTREG;
}
static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
{
int havejoy = 0;
havejoy = joydev_have();
if (!havejoy)
return DIERR_DEVICENOTREG;
if ((IsEqualGUID(&GUID_Joystick,rguid)) ||
(IsEqualGUID(&DInput_Wine_Joystick_GUID,rguid))) {
if ((riid == NULL) ||
IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
*pdev = (IDirectInputDeviceW*) alloc_device(rguid, &JoystickWvt, dinput);
TRACE("Creating a Joystick device (%p)\n", *pdev);
return DI_OK;
} else
......@@ -262,8 +298,10 @@ static HRESULT joydev_create_device(IDirectInputAImpl *dinput, REFGUID rguid, RE
static dinput_device joydev = {
20,
joydev_enum_device,
joydev_create_device
joydev_enum_deviceA,
joydev_enum_deviceW,
joydev_create_deviceA,
joydev_create_deviceW
};
DECL_GLOBAL_CONSTRUCTOR(joydev_register) { dinput_register_device(&joydev); }
......@@ -273,7 +311,7 @@ DECL_GLOBAL_CONSTRUCTOR(joydev_register) { dinput_register_device(&joydev); }
*/
static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
{
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
This->ref--;
if (This->ref)
......@@ -298,7 +336,7 @@ static HRESULT WINAPI JoystickAImpl_SetDataFormat(
LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df
)
{
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
int i;
TRACE("(this=%p,%p)\n",This,df);
......@@ -331,7 +369,7 @@ static HRESULT WINAPI JoystickAImpl_SetDataFormat(
static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
{
int i;
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
char buf[200];
TRACE("(this=%p)\n",This);
......@@ -387,7 +425,7 @@ static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
*/
static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
{
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
TRACE("(this=%p)\n",This);
if (This->joyfd!=-1) {
......@@ -403,7 +441,7 @@ static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
* adapts values accordingly.
*/
static int
map_axis(JoystickAImpl* This, int axis, int val) {
map_axis(JoystickImpl* This, int axis, int val) {
int xmid = This->axes[axis][AXE_ABS];
int xmin = This->axes[axis][AXE_ABSMIN];
int xmax = This->axes[axis][AXE_ABSMAX];
......@@ -436,7 +474,7 @@ map_axis(JoystickAImpl* This, int axis, int val) {
return ret;
}
static void joy_polldev(JoystickAImpl *This) {
static void joy_polldev(JoystickImpl *This) {
struct timeval tv;
fd_set readfds;
struct input_event ie;
......@@ -515,7 +553,7 @@ static void joy_polldev(JoystickAImpl *This) {
static HRESULT WINAPI JoystickAImpl_GetDeviceState(
LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
) {
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
joy_polldev(This);
......@@ -538,7 +576,7 @@ static HRESULT WINAPI JoystickAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
LPDWORD entries,
DWORD flags
) {
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
FIXME("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx),STUB!\n",This,dodsize,*entries,flags);
......@@ -559,7 +597,7 @@ static HRESULT WINAPI JoystickAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface,
REFGUID rguid,
LPCDIPROPHEADER ph)
{
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
FIXME("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
FIXME("ph.dwSize = %ld, ph.dwHeaderSize =%ld, ph.dwObj = %ld, ph.dwHow= %ld\n",ph->dwSize, ph->dwHeaderSize,ph->dwObj,ph->dwHow);
......@@ -612,7 +650,7 @@ static HRESULT WINAPI JoystickAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface,
static HRESULT WINAPI JoystickAImpl_SetEventNotification(
LPDIRECTINPUTDEVICE8A iface, HANDLE hnd
) {
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
TRACE("(this=%p,0x%08lx)\n",This,(DWORD)hnd);
This->hEvent = hnd;
......@@ -623,7 +661,7 @@ static HRESULT WINAPI JoystickAImpl_GetCapabilities(
LPDIRECTINPUTDEVICE8A iface,
LPDIDEVCAPS lpDIDevCaps)
{
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
int xfd = This->joyfd;
int i,axes,buttons;
int wasacquired = 1;
......@@ -653,7 +691,7 @@ static HRESULT WINAPI JoystickAImpl_GetCapabilities(
}
static HRESULT WINAPI JoystickAImpl_Poll(LPDIRECTINPUTDEVICE8A iface) {
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
TRACE("(),stub!\n");
joy_polldev(This);
......@@ -669,7 +707,7 @@ static HRESULT WINAPI JoystickAImpl_EnumObjects(
LPVOID lpvRef,
DWORD dwFlags)
{
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
DIDEVICEOBJECTINSTANCEA ddoi;
int xfd = This->joyfd;
......@@ -825,6 +863,21 @@ static HRESULT WINAPI JoystickAImpl_EnumObjects(
return DI_OK;
}
static HRESULT WINAPI JoystickWImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface,
LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
LPVOID lpvRef,
DWORD dwFlags)
{
ICOM_THIS(JoystickImpl,iface);
device_enumobjects_AtoWcb_data data;
data.lpCallBack = lpCallback;
data.lpvRef = lpvRef;
return JoystickAImpl_EnumObjects((LPDIRECTINPUTDEVICE8A) This, (LPDIENUMDEVICEOBJECTSCALLBACKA) DIEnumDevicesCallbackAtoW, (LPVOID) &data, dwFlags);
}
/******************************************************************************
* GetProperty : get input device properties
*/
......@@ -832,7 +885,7 @@ static HRESULT WINAPI JoystickAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
REFGUID rguid,
LPDIPROPHEADER pdiph)
{
ICOM_THIS(JoystickAImpl,iface);
ICOM_THIS(JoystickImpl,iface);
TRACE("(this=%p,%s,%p): stub!\n",
iface, debugstr_guid(rguid), pdiph);
......@@ -908,6 +961,50 @@ static ICOM_VTABLE(IDirectInputDevice8A) JoystickAvt =
IDirectInputDevice8AImpl_GetImageInfo
};
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(JoystickWvt.fun))
#else
# define XCAST(fun) (void*)
#endif
static ICOM_VTABLE(IDirectInputDevice8W) JoystickWvt =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectInputDevice2WImpl_QueryInterface,
XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
XCAST(Release)JoystickAImpl_Release,
XCAST(GetCapabilities)JoystickAImpl_GetCapabilities,
JoystickWImpl_EnumObjects,
XCAST(GetProperty)JoystickAImpl_GetProperty,
XCAST(SetProperty)JoystickAImpl_SetProperty,
XCAST(Acquire)JoystickAImpl_Acquire,
XCAST(Unacquire)JoystickAImpl_Unacquire,
XCAST(GetDeviceState)JoystickAImpl_GetDeviceState,
XCAST(GetDeviceData)JoystickAImpl_GetDeviceData,
XCAST(SetDataFormat)JoystickAImpl_SetDataFormat,
XCAST(SetEventNotification)JoystickAImpl_SetEventNotification,
XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
IDirectInputDevice2WImpl_GetObjectInfo,
IDirectInputDevice2WImpl_GetDeviceInfo,
XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
IDirectInputDevice2WImpl_EnumEffects,
IDirectInputDevice2WImpl_GetEffectInfo,
XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
XCAST(Escape)IDirectInputDevice2AImpl_Escape,
XCAST(Poll)JoystickAImpl_Poll,
XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
IDirectInputDevice7WImpl_EnumEffectsInFile,
IDirectInputDevice7WImpl_WriteEffectToFile,
IDirectInputDevice8WImpl_BuildActionMap,
IDirectInputDevice8WImpl_SetActionMap,
IDirectInputDevice8WImpl_GetImageInfo
};
#undef XCAST
#endif /* HAVE_LINUX_INPUT_H */
#endif
......@@ -31,19 +31,21 @@
#include "dinput_private.h"
#include "device_private.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
static ICOM_VTABLE(IDirectInputDevice8A) SysKeyboardAvt;
static ICOM_VTABLE(IDirectInputDevice8W) SysKeyboardWvt;
typedef struct SysKeyboardAImpl SysKeyboardAImpl;
struct SysKeyboardAImpl
typedef struct SysKeyboardImpl SysKeyboardImpl;
struct SysKeyboardImpl
{
LPVOID lpVtbl;
DWORD ref;
GUID guid;
IDirectInputAImpl *dinput;
IDirectInputImpl* dinput;
HANDLE hEvent;
/* SysKeyboardAImpl */
......@@ -61,7 +63,7 @@ struct SysKeyboardAImpl
CRITICAL_SECTION crit;
};
SysKeyboardAImpl *current; /* Today's acquired device
SysKeyboardImpl *current; /* Today's acquired device
FIXME: currently this can be only one.
Maybe this should be a linked list or st.
I don't know what the rules are for multiple acquired keyboards,
......@@ -138,7 +140,7 @@ static GUID DInput_Wine_Keyboard_GUID = { /* 0ab8648a-7735-11d2-8c73-71df54a9644
{0x8c, 0x73, 0x71, 0xdf, 0x54, 0xa9, 0x64, 0x41}
};
static void fill_keyboard_dideviceinstancea(LPDIDEVICEINSTANCEA lpddi, int version) {
static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int version) {
DWORD dwSize;
DIDEVICEINSTANCEA ddi;
......@@ -162,14 +164,53 @@ static void fill_keyboard_dideviceinstancea(LPDIDEVICEINSTANCEA lpddi, int versi
memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
}
static BOOL keyboarddev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version)
static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int version) {
DWORD dwSize;
DIDEVICEINSTANCEW ddi;
dwSize = lpddi->dwSize;
TRACE("%ld %p\n", dwSize, lpddi);
memset(lpddi, 0, dwSize);
memset(&ddi, 0, sizeof(ddi));
ddi.dwSize = dwSize;
ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
if (version >= 8)
ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
else
ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
MultiByteToWideChar(CP_ACP, 0, "Keyboard", -1, ddi.tszInstanceName, MAX_PATH);
MultiByteToWideChar(CP_ACP, 0, "Wine Keyboard", -1, ddi.tszProductName, MAX_PATH);
memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
}
static BOOL keyboarddev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version)
{
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 8)) ||
((dwDevType == DI8DEVTYPE_KEYBOARD) && (version >= 8))) {
TRACE("Enumerating the Keyboard device\n");
fill_keyboard_dideviceinstanceA(lpddi, version);
return TRUE;
}
return FALSE;
}
static BOOL keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version)
{
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 8)) ||
((dwDevType == DI8DEVTYPE_KEYBOARD) && (version >= 8))) {
TRACE("Enumerating the Keyboard device\n");
fill_keyboard_dideviceinstancea(lpddi, version);
fill_keyboard_dideviceinstanceW(lpddi, version);
return TRUE;
}
......@@ -177,10 +218,10 @@ static BOOL keyboarddev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEIN
return FALSE;
}
static SysKeyboardAImpl *alloc_device(REFGUID rguid, LPVOID kvt, IDirectInputAImpl *dinput)
static SysKeyboardImpl *alloc_device(REFGUID rguid, LPVOID kvt, IDirectInputImpl *dinput)
{
SysKeyboardAImpl* newDevice;
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardAImpl));
SysKeyboardImpl* newDevice;
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl));
newDevice->lpVtbl = kvt;
newDevice->ref = 1;
memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
......@@ -195,7 +236,7 @@ static SysKeyboardAImpl *alloc_device(REFGUID rguid, LPVOID kvt, IDirectInputAIm
}
static HRESULT keyboarddev_create_device(IDirectInputAImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
static HRESULT keyboarddev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
{
if ((IsEqualGUID(&GUID_SysKeyboard,rguid)) || /* Generic Keyboard */
(IsEqualGUID(&DInput_Wine_Keyboard_GUID,rguid))) { /* Wine Keyboard */
......@@ -204,27 +245,46 @@ static HRESULT keyboarddev_create_device(IDirectInputAImpl *dinput, REFGUID rgui
IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
*pdev=(IDirectInputDeviceA*) alloc_device(rguid, &SysKeyboardAvt, dinput);
*pdev = (IDirectInputDeviceA*) alloc_device(rguid, &SysKeyboardAvt, dinput);
TRACE("Creating a Keyboard device (%p)\n", *pdev);
return DI_OK;
} else
return DIERR_NOINTERFACE;
}
return DIERR_DEVICENOTREG;
}
static HRESULT keyboarddev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
{
if ((IsEqualGUID(&GUID_SysKeyboard,rguid)) || /* Generic Keyboard */
(IsEqualGUID(&DInput_Wine_Keyboard_GUID,rguid))) { /* Wine Keyboard */
if ((riid == NULL) ||
IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
*pdev = (IDirectInputDeviceW*) alloc_device(rguid, &SysKeyboardWvt, dinput);
TRACE("Creating a Keyboard device (%p)\n", *pdev);
return DI_OK;
} else
return DIERR_NOINTERFACE;
}
return DIERR_DEVICENOTREG;
}
static dinput_device keyboarddev = {
100,
keyboarddev_enum_device,
keyboarddev_create_device
keyboarddev_enum_deviceA,
keyboarddev_enum_deviceW,
keyboarddev_create_deviceA,
keyboarddev_create_deviceW
};
DECL_GLOBAL_CONSTRUCTOR(keyboarddev_register) { dinput_register_device(&keyboarddev); }
static ULONG WINAPI SysKeyboardAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
{
ICOM_THIS(SysKeyboardAImpl,iface);
ICOM_THIS(SysKeyboardImpl,iface);
This->ref--;
if (This->ref)
......@@ -251,7 +311,7 @@ static HRESULT WINAPI SysKeyboardAImpl_SetProperty(
LPDIRECTINPUTDEVICE8A iface,REFGUID rguid,LPCDIPROPHEADER ph
)
{
ICOM_THIS(SysKeyboardAImpl,iface);
ICOM_THIS(SysKeyboardImpl,iface);
TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
TRACE("(size=%ld,headersize=%ld,obj=%ld,how=%ld\n",
......@@ -299,7 +359,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceData(
LPDWORD entries,DWORD flags
)
{
ICOM_THIS(SysKeyboardAImpl,iface);
ICOM_THIS(SysKeyboardImpl,iface);
int ret = DI_OK, i = 0;
TRACE("(this=%p,%ld,%p,%p(%ld)),0x%08lx)\n",
......@@ -360,7 +420,7 @@ static HRESULT WINAPI SysKeyboardAImpl_EnumObjects(
LPVOID lpvRef,
DWORD dwFlags)
{
ICOM_THIS(SysKeyboardAImpl,iface);
ICOM_THIS(SysKeyboardImpl,iface);
DIDEVICEOBJECTINSTANCEA ddoi;
int i;
......@@ -388,11 +448,26 @@ static HRESULT WINAPI SysKeyboardAImpl_EnumObjects(
return DI_OK;
}
static HRESULT WINAPI SysKeyboardWImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface,
LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
LPVOID lpvRef,
DWORD dwFlags)
{
ICOM_THIS(SysKeyboardImpl,iface);
device_enumobjects_AtoWcb_data data;
data.lpCallBack = lpCallback;
data.lpvRef = lpvRef;
return SysKeyboardAImpl_EnumObjects((LPDIRECTINPUTDEVICE8A) This, (LPDIENUMDEVICEOBJECTSCALLBACKA) DIEnumDevicesCallbackAtoW, (LPVOID) &data, dwFlags);
}
static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface);
static HRESULT WINAPI SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
{
ICOM_THIS(SysKeyboardAImpl,iface);
ICOM_THIS(SysKeyboardImpl,iface);
TRACE("(this=%p)\n",This);
......@@ -426,7 +501,7 @@ static HRESULT WINAPI SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
{
ICOM_THIS(SysKeyboardAImpl,iface);
ICOM_THIS(SysKeyboardImpl,iface);
TRACE("(this=%p)\n",This);
if (This->acquired == 0)
......@@ -451,7 +526,7 @@ static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
static HRESULT WINAPI SysKeyboardAImpl_SetEventNotification(LPDIRECTINPUTDEVICE8A iface,
HANDLE hnd) {
ICOM_THIS(SysKeyboardAImpl,iface);
ICOM_THIS(SysKeyboardImpl,iface);
TRACE("(this=%p,0x%08lx)\n",This,(DWORD)hnd);
......@@ -466,7 +541,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities(
LPDIRECTINPUTDEVICE8A iface,
LPDIDEVCAPS lpDIDevCaps)
{
ICOM_THIS(SysKeyboardAImpl,iface);
ICOM_THIS(SysKeyboardImpl,iface);
TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
......@@ -503,7 +578,7 @@ SysKeyboardAImpl_GetObjectInfo(
DWORD dwObj,
DWORD dwHow)
{
ICOM_THIS(SysKeyboardAImpl,iface);
ICOM_THIS(SysKeyboardImpl,iface);
DIDEVICEOBJECTINSTANCEA ddoi;
DWORD dwSize = pdidoi->dwSize;
......@@ -531,6 +606,39 @@ SysKeyboardAImpl_GetObjectInfo(
return DI_OK;
}
static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
LPDIDEVICEOBJECTINSTANCEW pdidoi,
DWORD dwObj,
DWORD dwHow)
{
ICOM_THIS(SysKeyboardImpl,iface);
DIDEVICEOBJECTINSTANCEW ddoi;
DWORD dwSize = pdidoi->dwSize;
TRACE("(this=%p,%p,%ld,0x%08lx)\n", This, pdidoi, dwObj, dwHow);
if (dwHow == DIPH_BYID) {
WARN(" querying by id not supported yet...\n");
return DI_OK;
}
memset(pdidoi, 0, dwSize);
memset(&ddoi, 0, sizeof(ddoi));
ddoi.dwSize = dwSize;
ddoi.guidType = GUID_Key;
ddoi.dwOfs = dwObj;
ddoi.dwType = DIDFT_MAKEINSTANCE(dwObj) | DIDFT_BUTTON;
GetKeyNameTextW(((dwObj & 0x7f) << 16) | ((dwObj & 0x80) << 17), ddoi.tszName, sizeof(ddoi.tszName));
/* And return our just filled device object instance structure */
memcpy(pdidoi, &ddoi, (dwSize < sizeof(ddoi) ? dwSize : sizeof(ddoi)));
_dump_OBJECTINSTANCEW(pdidoi);
return DI_OK;
}
/******************************************************************************
* GetDeviceInfo : get information about a device's identity
*/
......@@ -538,7 +646,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceInfo(
LPDIRECTINPUTDEVICE8A iface,
LPDIDEVICEINSTANCEA pdidi)
{
ICOM_THIS(SysKeyboardAImpl,iface);
ICOM_THIS(SysKeyboardImpl,iface);
TRACE("(this=%p,%p)\n", This, pdidi);
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA)) {
......@@ -546,11 +654,25 @@ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceInfo(
return DI_OK;
}
fill_keyboard_dideviceinstancea(pdidi, This->dinput->version);
fill_keyboard_dideviceinstanceA(pdidi, This->dinput->version);
return DI_OK;
}
static HRESULT WINAPI SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi)
{
ICOM_THIS(SysKeyboardImpl,iface);
TRACE("(this=%p,%p)\n", This, pdidi);
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
WARN(" dinput3 not supporte yet...\n");
return DI_OK;
}
fill_keyboard_dideviceinstanceW(pdidi, This->dinput->version);
return DI_OK;
}
static ICOM_VTABLE(IDirectInputDevice8A) SysKeyboardAvt =
{
......@@ -588,3 +710,47 @@ static ICOM_VTABLE(IDirectInputDevice8A) SysKeyboardAvt =
IDirectInputDevice8AImpl_SetActionMap,
IDirectInputDevice8AImpl_GetImageInfo
};
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(SysKeyboardWvt.fun))
#else
# define XCAST(fun) (void*)
#endif
static ICOM_VTABLE(IDirectInputDevice8W) SysKeyboardWvt =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectInputDevice2WImpl_QueryInterface,
XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
XCAST(Release)SysKeyboardAImpl_Release,
XCAST(GetCapabilities)SysKeyboardAImpl_GetCapabilities,
SysKeyboardWImpl_EnumObjects,
XCAST(GetProperty)IDirectInputDevice2AImpl_GetProperty,
XCAST(SetProperty)SysKeyboardAImpl_SetProperty,
XCAST(Acquire)SysKeyboardAImpl_Acquire,
XCAST(Unacquire)SysKeyboardAImpl_Unacquire,
XCAST(GetDeviceState)SysKeyboardAImpl_GetDeviceState,
XCAST(GetDeviceData)SysKeyboardAImpl_GetDeviceData,
XCAST(SetDataFormat)IDirectInputDevice2AImpl_SetDataFormat,
XCAST(SetEventNotification)SysKeyboardAImpl_SetEventNotification,
XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
SysKeyboardWImpl_GetObjectInfo,
SysKeyboardWImpl_GetDeviceInfo,
XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
IDirectInputDevice2WImpl_EnumEffects,
IDirectInputDevice2WImpl_GetEffectInfo,
XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
XCAST(Escape)IDirectInputDevice2AImpl_Escape,
XCAST(Poll)IDirectInputDevice2AImpl_Poll,
XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
IDirectInputDevice7WImpl_EnumEffectsInFile,
IDirectInputDevice7WImpl_WriteEffectToFile,
IDirectInputDevice8WImpl_BuildActionMap,
IDirectInputDevice8WImpl_SetActionMap,
IDirectInputDevice8WImpl_GetImageInfo
};
#undef XCAST
......@@ -33,6 +33,7 @@
#include "dinput_private.h"
#include "device_private.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#define MOUSE_HACK
......@@ -92,7 +93,9 @@ static DIDATAFORMAT Wine_InternalMouseFormat = {
};
static ICOM_VTABLE(IDirectInputDevice8A) SysMouseAvt;
typedef struct SysMouseAImpl SysMouseAImpl;
static ICOM_VTABLE(IDirectInputDevice8W) SysMouseWvt;
typedef struct SysMouseImpl SysMouseImpl;
typedef enum {
WARP_NEEDED, /* Warping is needed */
......@@ -100,13 +103,13 @@ typedef enum {
WARP_DONE /* Warping has been done */
} WARP_STATUS;
struct SysMouseAImpl
struct SysMouseImpl
{
LPVOID lpVtbl;
DWORD ref;
GUID guid;
IDirectInputAImpl *dinput;
IDirectInputImpl *dinput;
/* The current data format and the conversion between internal
and external data formats */
......@@ -146,7 +149,7 @@ static GUID DInput_Wine_Mouse_GUID = { /* 9e573ed8-7734-11d2-8d4a-23903fb6bdf7 *
{0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
};
static void fill_mouse_dideviceinstancea(LPDIDEVICEINSTANCEA lpddi, int version) {
static void fill_mouse_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int version) {
DWORD dwSize;
DIDEVICEINSTANCEA ddi;
......@@ -170,14 +173,53 @@ static void fill_mouse_dideviceinstancea(LPDIDEVICEINSTANCEA lpddi, int version)
memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
}
static BOOL mousedev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version)
static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int version) {
DWORD dwSize;
DIDEVICEINSTANCEW ddi;
dwSize = lpddi->dwSize;
TRACE("%ld %p\n", dwSize, lpddi);
memset(lpddi, 0, dwSize);
memset(&ddi, 0, sizeof(ddi));
ddi.dwSize = dwSize;
ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */
ddi.guidProduct = DInput_Wine_Mouse_GUID; /* Vendor's GUID */
if (version >= 8)
ddi.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
else
ddi.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
MultiByteToWideChar(CP_ACP, 0, "Mouse", -1, ddi.tszInstanceName, MAX_PATH);
MultiByteToWideChar(CP_ACP, 0, "Wine Mouse", -1, ddi.tszProductName, MAX_PATH);
memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
}
static BOOL mousedev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version)
{
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_MOUSE) && (version < 8)) ||
((dwDevType == DI8DEVTYPE_MOUSE) && (version >= 8))) {
TRACE("Enumerating the mouse device\n");
fill_mouse_dideviceinstanceA(lpddi, version);
return TRUE;
}
return FALSE;
}
static BOOL mousedev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version)
{
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_MOUSE) && (version < 8)) ||
((dwDevType == DI8DEVTYPE_MOUSE) && (version >= 8))) {
TRACE("Enumerating the mouse device\n");
fill_mouse_dideviceinstancea(lpddi, version);
fill_mouse_dideviceinstanceW(lpddi, version);
return TRUE;
}
......@@ -185,7 +227,7 @@ static BOOL mousedev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTA
return FALSE;
}
static SysMouseAImpl *alloc_device(REFGUID rguid, LPVOID mvt, IDirectInputAImpl *dinput)
static SysMouseImpl *alloc_device(REFGUID rguid, LPVOID mvt, IDirectInputImpl *dinput)
{
int offset_array[WINE_INTERNALMOUSE_NUM_OBJS] = {
FIELD_OFFSET(Wine_InternalMouseData, lX),
......@@ -195,8 +237,8 @@ static SysMouseAImpl *alloc_device(REFGUID rguid, LPVOID mvt, IDirectInputAImpl
FIELD_OFFSET(Wine_InternalMouseData, rgbButtons) + 1,
FIELD_OFFSET(Wine_InternalMouseData, rgbButtons) + 2
};
SysMouseAImpl* newDevice;
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseAImpl));
SysMouseImpl* newDevice;
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseImpl));
newDevice->ref = 1;
newDevice->lpVtbl = mvt;
InitializeCriticalSection(&(newDevice->crit));
......@@ -214,7 +256,7 @@ static SysMouseAImpl *alloc_device(REFGUID rguid, LPVOID mvt, IDirectInputAImpl
return newDevice;
}
static HRESULT mousedev_create_device(IDirectInputAImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
static HRESULT mousedev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
{
if ((IsEqualGUID(&GUID_SysMouse,rguid)) || /* Generic Mouse */
(IsEqualGUID(&DInput_Wine_Mouse_GUID,rguid))) { /* Wine Mouse */
......@@ -223,7 +265,7 @@ static HRESULT mousedev_create_device(IDirectInputAImpl *dinput, REFGUID rguid,
IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
*pdev=(IDirectInputDeviceA*) alloc_device(rguid, &SysMouseAvt, dinput);
*pdev = (IDirectInputDeviceA*) alloc_device(rguid, &SysMouseAvt, dinput);
TRACE("Creating a Mouse device (%p)\n", *pdev);
return DI_OK;
} else
......@@ -233,10 +275,30 @@ static HRESULT mousedev_create_device(IDirectInputAImpl *dinput, REFGUID rguid,
return DIERR_DEVICENOTREG;
}
static HRESULT mousedev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
{
if ((IsEqualGUID(&GUID_SysMouse,rguid)) || /* Generic Mouse */
(IsEqualGUID(&DInput_Wine_Mouse_GUID,rguid))) { /* Wine Mouse */
if ((riid == NULL) ||
IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
*pdev = (IDirectInputDeviceW*) alloc_device(rguid, &SysMouseWvt, dinput);
TRACE("Creating a Mouse device (%p)\n", *pdev);
return DI_OK;
} else
return DIERR_NOINTERFACE;
}
return DIERR_DEVICENOTREG;
}
static dinput_device mousedev = {
100,
mousedev_enum_device,
mousedev_create_device
mousedev_enum_deviceA,
mousedev_enum_deviceW,
mousedev_create_deviceA,
mousedev_create_deviceW
};
DECL_GLOBAL_CONSTRUCTOR(mousedev_register) { dinput_register_device(&mousedev); }
......@@ -250,7 +312,7 @@ DECL_GLOBAL_CONSTRUCTOR(mousedev_register) { dinput_register_device(&mousedev);
*/
static ULONG WINAPI SysMouseAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
{
ICOM_THIS(SysMouseAImpl,iface);
ICOM_THIS(SysMouseImpl,iface);
This->ref--;
if (This->ref)
......@@ -286,7 +348,7 @@ static HRESULT WINAPI SysMouseAImpl_SetCooperativeLevel(
LPDIRECTINPUTDEVICE8A iface,HWND hwnd,DWORD dwflags
)
{
ICOM_THIS(SysMouseAImpl,iface);
ICOM_THIS(SysMouseImpl,iface);
TRACE("(this=%p,0x%08lx,0x%08lx)\n",This,(DWORD)hwnd,dwflags);
......@@ -316,7 +378,7 @@ static HRESULT WINAPI SysMouseAImpl_SetDataFormat(
LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df
)
{
ICOM_THIS(SysMouseAImpl,iface);
ICOM_THIS(SysMouseImpl,iface);
int i;
TRACE("(this=%p,%p)\n",This,df);
......@@ -357,7 +419,7 @@ static LRESULT CALLBACK dinput_mouse_hook( int code, WPARAM wparam, LPARAM lpara
{
LRESULT ret;
MSLLHOOKSTRUCT *hook = (MSLLHOOKSTRUCT *)lparam;
SysMouseAImpl* This = (SysMouseAImpl*) current_lock;
SysMouseImpl* This = (SysMouseImpl*) current_lock;
DWORD dwCoop;
static long last_event = 0;
int wdata;
......@@ -489,7 +551,7 @@ end:
}
static void dinput_window_check(SysMouseAImpl* This)
static void dinput_window_check(SysMouseImpl* This)
{
RECT rect;
DWORD centerX, centerY;
......@@ -513,7 +575,7 @@ static void dinput_window_check(SysMouseAImpl* This)
*/
static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
{
ICOM_THIS(SysMouseAImpl,iface);
ICOM_THIS(SysMouseImpl,iface);
RECT rect;
TRACE("(this=%p)\n",This);
......@@ -575,7 +637,7 @@ static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
*/
static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
{
ICOM_THIS(SysMouseAImpl,iface);
ICOM_THIS(SysMouseImpl,iface);
TRACE("(this=%p)\n",This);
......@@ -610,7 +672,7 @@ static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
) {
ICOM_THIS(SysMouseAImpl,iface);
ICOM_THIS(SysMouseImpl,iface);
EnterCriticalSection(&(This->crit));
TRACE("(this=%p,0x%08lx,%p): \n",This,len,ptr);
......@@ -656,7 +718,7 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
LPDWORD entries,
DWORD flags
) {
ICOM_THIS(SysMouseAImpl,iface);
ICOM_THIS(SysMouseImpl,iface);
DWORD len, nqtail;
TRACE("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx)\n",This,dodsize,*entries,flags);
......@@ -731,7 +793,7 @@ static HRESULT WINAPI SysMouseAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface,
REFGUID rguid,
LPCDIPROPHEADER ph)
{
ICOM_THIS(SysMouseAImpl,iface);
ICOM_THIS(SysMouseImpl,iface);
TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
......@@ -771,7 +833,7 @@ static HRESULT WINAPI SysMouseAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
REFGUID rguid,
LPDIPROPHEADER pdiph)
{
ICOM_THIS(SysMouseAImpl,iface);
ICOM_THIS(SysMouseImpl,iface);
TRACE("(this=%p,%s,%p): stub!\n",
iface, debugstr_guid(rguid), pdiph);
......@@ -831,7 +893,7 @@ static HRESULT WINAPI SysMouseAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
*/
static HRESULT WINAPI SysMouseAImpl_SetEventNotification(LPDIRECTINPUTDEVICE8A iface,
HANDLE hnd) {
ICOM_THIS(SysMouseAImpl,iface);
ICOM_THIS(SysMouseImpl,iface);
TRACE("(this=%p,0x%08lx)\n",This,(DWORD)hnd);
......@@ -847,7 +909,7 @@ static HRESULT WINAPI SysMouseAImpl_GetCapabilities(
LPDIRECTINPUTDEVICE8A iface,
LPDIDEVCAPS lpDIDevCaps)
{
ICOM_THIS(SysMouseAImpl,iface);
ICOM_THIS(SysMouseImpl,iface);
TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
......@@ -883,7 +945,7 @@ static HRESULT WINAPI SysMouseAImpl_EnumObjects(
LPVOID lpvRef,
DWORD dwFlags)
{
ICOM_THIS(SysMouseAImpl,iface);
ICOM_THIS(SysMouseImpl,iface);
DIDEVICEOBJECTINSTANCEA ddoi;
TRACE("(this=%p,%p,%p,%08lx)\n", This, lpCallback, lpvRef, dwFlags);
......@@ -954,6 +1016,18 @@ static HRESULT WINAPI SysMouseAImpl_EnumObjects(
return DI_OK;
}
static HRESULT WINAPI SysMouseWImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface, LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID lpvRef,DWORD dwFlags)
{
ICOM_THIS(SysMouseImpl,iface);
device_enumobjects_AtoWcb_data data;
data.lpCallBack = lpCallback;
data.lpvRef = lpvRef;
return SysMouseAImpl_EnumObjects((LPDIRECTINPUTDEVICE8A) This, (LPDIENUMDEVICEOBJECTSCALLBACKA) DIEnumDevicesCallbackAtoW, (LPVOID) &data, dwFlags);
}
/******************************************************************************
* GetDeviceInfo : get information about a device's identity
*/
......@@ -961,7 +1035,7 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceInfo(
LPDIRECTINPUTDEVICE8A iface,
LPDIDEVICEINSTANCEA pdidi)
{
ICOM_THIS(SysMouseAImpl,iface);
ICOM_THIS(SysMouseImpl,iface);
TRACE("(this=%p,%p)\n", This, pdidi);
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA)) {
......@@ -969,11 +1043,27 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceInfo(
return DI_OK;
}
fill_mouse_dideviceinstancea(pdidi, This->dinput->version);
fill_mouse_dideviceinstanceA(pdidi, This->dinput->version);
return DI_OK;
}
static HRESULT WINAPI SysMouseWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi)
{
ICOM_THIS(SysMouseImpl,iface);
TRACE("(this=%p,%p)\n", This, pdidi);
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
WARN(" dinput3 not supporte yet...\n");
return DI_OK;
}
fill_mouse_dideviceinstanceW(pdidi, This->dinput->version);
return DI_OK;
}
static ICOM_VTABLE(IDirectInputDevice8A) SysMouseAvt =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
......@@ -1010,3 +1100,47 @@ static ICOM_VTABLE(IDirectInputDevice8A) SysMouseAvt =
IDirectInputDevice8AImpl_SetActionMap,
IDirectInputDevice8AImpl_GetImageInfo
};
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(SysMouseWvt.fun))
#else
# define XCAST(fun) (void*)
#endif
static ICOM_VTABLE(IDirectInputDevice8W) SysMouseWvt =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectInputDevice2WImpl_QueryInterface,
XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
XCAST(Release)SysMouseAImpl_Release,
XCAST(GetCapabilities)SysMouseAImpl_GetCapabilities,
SysMouseWImpl_EnumObjects,
XCAST(GetProperty)SysMouseAImpl_GetProperty,
XCAST(SetProperty)SysMouseAImpl_SetProperty,
XCAST(Acquire)SysMouseAImpl_Acquire,
XCAST(Unacquire)SysMouseAImpl_Unacquire,
XCAST(GetDeviceState)SysMouseAImpl_GetDeviceState,
XCAST(GetDeviceData)SysMouseAImpl_GetDeviceData,
XCAST(SetDataFormat)SysMouseAImpl_SetDataFormat,
XCAST(SetEventNotification)SysMouseAImpl_SetEventNotification,
XCAST(SetCooperativeLevel)SysMouseAImpl_SetCooperativeLevel,
IDirectInputDevice2WImpl_GetObjectInfo,
SysMouseWImpl_GetDeviceInfo,
XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
IDirectInputDevice2WImpl_EnumEffects,
IDirectInputDevice2WImpl_GetEffectInfo,
XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
XCAST(Escape)IDirectInputDevice2AImpl_Escape,
XCAST(Poll)IDirectInputDevice2AImpl_Poll,
XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
IDirectInputDevice7WImpl_EnumEffectsInFile,
IDirectInputDevice7WImpl_WriteEffectToFile,
IDirectInputDevice8WImpl_BuildActionMap,
IDirectInputDevice8WImpl_SetActionMap,
IDirectInputDevice8WImpl_GetImageInfo
};
#undef XCAST
......@@ -1196,6 +1196,30 @@ ICOM_DEFINE(IDirectInputEffect,IUnknown)
ICOM_DEFINE(IDirectInputDeviceA,IUnknown)
#undef INTERFACE
/*****************************************************************************
* IDirectInputDeviceW interface
*/
#define INTERFACE IDirectInputDeviceW
#define IDirectInputDeviceW_METHODS \
IUnknown_METHODS \
STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE; \
STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; \
STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE; \
STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE; \
STDMETHOD(Acquire)(THIS) PURE; \
STDMETHOD(Unacquire)(THIS) PURE; \
STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE; \
STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE; \
STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE; \
STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE; \
STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE; \
STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE; \
STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE; \
STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; \
STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
ICOM_DEFINE(IDirectInputDeviceW,IUnknown)
#undef INTERFACE
#ifdef COBJMACROS
/*** IUnknown methods ***/
#define IDirectInputDevice_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
......@@ -1238,6 +1262,24 @@ ICOM_DEFINE(IDirectInputDeviceA,IUnknown)
ICOM_DEFINE(IDirectInputDevice2A,IDirectInputDeviceA)
#undef INTERFACE
/*****************************************************************************
* IDirectInputDevice2W interface
*/
#define INTERFACE IDirectInputDevice2W
#define IDirectInputDevice2W_METHODS \
IDirectInputDeviceW_METHODS \
STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE; \
STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType) PURE; \
STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW pdei, REFGUID rguid) PURE; \
STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE; \
STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE; \
STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE; \
STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE; \
STDMETHOD(Poll)(THIS) PURE; \
STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
ICOM_DEFINE(IDirectInputDevice2W,IDirectInputDeviceW)
#undef INTERFACE
#ifdef COBJMACROS
/*** IUnknown methods ***/
#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
......@@ -1283,6 +1325,17 @@ ICOM_DEFINE(IDirectInputDevice2A,IDirectInputDeviceA)
ICOM_DEFINE(IDirectInputDevice7A,IDirectInputDevice2A)
#undef INTERFACE
/*****************************************************************************
* IDirectInputDevice7W interface
*/
#define INTERFACE IDirectInputDevice7W
#define IDirectInputDevice7W_METHODS \
IDirectInputDevice2W_METHODS \
STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE; \
STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE;
ICOM_DEFINE(IDirectInputDevice7W,IDirectInputDevice2W)
#undef INTERFACE
#ifdef COBJMACROS
/*** IUnknown methods ***/
#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
......@@ -1334,6 +1387,18 @@ ICOM_DEFINE(IDirectInputDevice7A,IDirectInputDevice2A)
ICOM_DEFINE(IDirectInputDevice8A,IDirectInputDevice7A)
#undef INTERFACE
/*****************************************************************************
* IDirectInputDevice8W interface
*/
#define INTERFACE IDirectInputDevice8W
#define IDirectInputDevice8W_METHODS \
IDirectInputDevice7W_METHODS \
STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) PURE; \
STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) PURE; \
STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader) PURE;
ICOM_DEFINE(IDirectInputDevice8W,IDirectInputDevice7W)
#undef INTERFACE
#ifdef COBJMACROS
/*** IUnknown methods ***/
#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
......@@ -1426,17 +1491,31 @@ extern const DIDATAFORMAT c_dfDIJoystick2;
ICOM_DEFINE(IDirectInputA,IUnknown)
#undef INTERFACE
/*****************************************************************************
* IDirectInputW interface
*/
#define INTERFACE IDirectInputW
#define IDirectInputW_METHODS \
IUnknown_METHODS \
STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEW *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; \
STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; \
STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; \
STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; \
STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
ICOM_DEFINE(IDirectInputW,IUnknown)
#undef INTERFACE
#ifdef COBJMACROS
/*** IUnknown methods ***/
#define IDirectInputA_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectInputA_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectInputA_Release(p) (p)->lpVtbl->Release(p)
/*** IDirectInputA methods ***/
#define IDirectInputA_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c)
#define IDirectInputA_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
#define IDirectInputA_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a)
#define IDirectInputA_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
#define IDirectInputA_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
#define IDirectInput_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectInput_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectInput_Release(p) (p)->lpVtbl->Release(p)
/*** IDirectInput methods ***/
#define IDirectInput_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c)
#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
#define IDirectInput_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a)
#define IDirectInput_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
#define IDirectInput_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
#endif
/*****************************************************************************
......@@ -1449,19 +1528,29 @@ ICOM_DEFINE(IDirectInputA,IUnknown)
ICOM_DEFINE(IDirectInput2A,IDirectInputA)
#undef INTERFACE
/*****************************************************************************
* IDirectInput2W interface
*/
#define INTERFACE IDirectInput2W
#define IDirectInput2W_METHODS \
IDirectInputW_METHODS \
STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) PURE;
ICOM_DEFINE(IDirectInput2W,IDirectInputW)
#undef INTERFACE
#ifdef COBJMACROS
/*** IUnknown methods ***/
#define IDirectInput2A_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectInput2A_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectInput2A_Release(p) (p)->lpVtbl->Release(p)
/*** IDirectInputA methods ***/
#define IDirectInput2A_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c)
#define IDirectInput2A_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
#define IDirectInput2A_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a)
#define IDirectInput2A_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
#define IDirectInput2A_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
/*** IDirectInput2A methods ***/
#define IDirectInput2A_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c)
#define IDirectInput2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectInput2_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectInput2_Release(p) (p)->lpVtbl->Release(p)
/*** IDirectInput methods ***/
#define IDirectInput2_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c)
#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
#define IDirectInput2_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a)
#define IDirectInput2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
#define IDirectInput2_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
/*** IDirectInput2 methods ***/
#define IDirectInput2_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c)
#endif
#if DIRECTINPUT_VERSION >= 0x0700
......@@ -1475,21 +1564,31 @@ ICOM_DEFINE(IDirectInput2A,IDirectInputA)
ICOM_DEFINE(IDirectInput7A,IDirectInput2A)
#undef INTERFACE
/*****************************************************************************
* IDirectInput7W interface
*/
#define INTERFACE IDirectInput7W
#define IDirectInput7W_METHODS \
IDirectInput2W_METHODS \
STDMETHOD(CreateDeviceEx)(THIS_ REFGUID rguid, REFIID riid, LPVOID *pvOut, LPUNKNOWN lpUnknownOuter) PURE;
ICOM_DEFINE(IDirectInput7W,IDirectInput2W)
#undef INTERFACE
#ifdef COBJMACROS
/*** IUnknown methods ***/
#define IDirectInput7A_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectInput7A_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectInput7A_Release(p) (p)->lpVtbl->Release(p)
/*** IDirectInputA methods ***/
#define IDirectInput7A_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c)
#define IDirectInput7A_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
#define IDirectInput7A_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a)
#define IDirectInput7A_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
#define IDirectInput7A_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
/*** IDirectInput2A methods ***/
#define IDirectInput7A_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c)
/*** IDirectInput7A methods ***/
#define IDirectInput7A_CreateDeviceEx(p,a,b,c,d) (p)->lpVtbl->CreateDeviceEx(p,a,b,c,d)
#define IDirectInput7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectInput7_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectInput7_Release(p) (p)->lpVtbl->Release(p)
/*** IDirectInput methods ***/
#define IDirectInput7_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c)
#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
#define IDirectInput7_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a)
#define IDirectInput7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
#define IDirectInput7_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
/*** IDirectInput2 methods ***/
#define IDirectInput7_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c)
/*** IDirectInput7 methods ***/
#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->lpVtbl->CreateDeviceEx(p,a,b,c,d)
#endif
#endif /* DI7 */
......@@ -1512,20 +1611,37 @@ ICOM_DEFINE(IDirectInput7A,IDirectInput2A)
ICOM_DEFINE(IDirectInput8A,IUnknown)
#undef INTERFACE
/*****************************************************************************
* IDirectInput8W interface
*/
#define INTERFACE IDirectInput8W
#define IDirectInput8W_METHODS \
IUnknown_METHODS \
STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICE8W *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; \
STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; \
STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; \
STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; \
STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE; \
STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) PURE; \
STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCWSTR ptszUserName, LPDIACTIONFORMATW lpdiActionFormat, LPDIENUMDEVICESBYSEMANTICSCBW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; \
STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK lpdiCallback, LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData) PURE;
ICOM_DEFINE(IDirectInput8W,IUnknown)
#undef INTERFACE
#ifdef COBJMACROS
/*** IUnknown methods ***/
#define IDirectInput8A_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectInput8A_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectInput8A_Release(p) (p)->lpVtbl->Release(p)
/*** IDirectInput8A methods ***/
#define IDirectInput8A_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c)
#define IDirectInput8A_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
#define IDirectInput8A_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a)
#define IDirectInput8A_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
#define IDirectInput8A_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
#define IDirectInput8A_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c)
#define IDirectInput8A_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->lpVtbl->EnumDevicesBySemantics(p,a,b,c,d,e)
#define IDirectInput8A_ConfigureDevices(p,a,b,c,d) (p)->lpVtbl->ConfigureDevices(p,a,b,c,d)
#define IDirectInput8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectInput8_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectInput8_Release(p) (p)->lpVtbl->Release(p)
/*** IDirectInput8 methods ***/
#define IDirectInput8_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c)
#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
#define IDirectInput8_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a)
#define IDirectInput8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
#define IDirectInput8_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
#define IDirectInput8_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c)
#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->lpVtbl->EnumDevicesBySemantics(p,a,b,c,d,e)
#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->lpVtbl->ConfigureDevices(p,a,b,c,d)
#endif
#endif /* DI8 */
......@@ -1541,7 +1657,7 @@ HRESULT WINAPI DirectInput8Create(HINSTANCE,DWORD,REFIID,LPVOID *,LPUNKNOWN);
#endif
HRESULT WINAPI DirectInputCreateA(HINSTANCE,DWORD,LPDIRECTINPUTA *,LPUNKNOWN);
HRESULT WINAPI DirectInputCreateW(HINSTANCE,DWORD,LPDIRECTINPUTA *,LPUNKNOWN);
HRESULT WINAPI DirectInputCreateW(HINSTANCE,DWORD,LPDIRECTINPUTW *,LPUNKNOWN);
#define DirectInputCreate WINELIB_NAME_AW(DirectInputCreate)
HRESULT WINAPI DirectInputCreateEx(HINSTANCE,DWORD,REFIID,LPVOID *,LPUNKNOWN);
......
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