dinput: Explicitly define ASCII and Unicode methods in mouse.

This commit is contained in:
Vitaliy Margolen 2011-01-09 15:44:02 -07:00 committed by Alexandre Julliard
parent 9f9e376239
commit 30ab6c1749
1 changed files with 75 additions and 41 deletions

View File

@ -86,6 +86,14 @@ static inline SysMouseImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W
{ {
return (SysMouseImpl *) iface; return (SysMouseImpl *) iface;
} }
static inline IDirectInputDevice8A *IDirectInputDevice8A_from_impl(SysMouseImpl *This)
{
return (IDirectInputDevice8A *)This;
}
static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(SysMouseImpl *This)
{
return (IDirectInputDevice8W *)This;
}
static int dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam ); static int dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam );
@ -419,16 +427,16 @@ static BOOL dinput_window_check(SysMouseImpl* This) {
/****************************************************************************** /******************************************************************************
* Acquire : gets exclusive control of the mouse * Acquire : gets exclusive control of the mouse
*/ */
static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) static HRESULT WINAPI SysMouseWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface)
{ {
SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface); SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface);
RECT rect; RECT rect;
POINT point; POINT point;
HRESULT res; HRESULT res;
TRACE("(this=%p)\n",This); TRACE("(this=%p)\n",This);
if ((res = IDirectInputDevice2AImpl_Acquire(iface)) != DI_OK) return res; if ((res = IDirectInputDevice2WImpl_Acquire(iface)) != DI_OK) return res;
/* Init the mouse state */ /* Init the mouse state */
GetCursorPos( &point ); GetCursorPos( &point );
@ -486,17 +494,23 @@ static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
return DI_OK; return DI_OK;
} }
static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
{
SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
return SysMouseWImpl_Acquire(IDirectInputDevice8W_from_impl(This));
}
/****************************************************************************** /******************************************************************************
* Unacquire : frees the mouse * Unacquire : frees the mouse
*/ */
static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface) static HRESULT WINAPI SysMouseWImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface)
{ {
SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface); SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface);
HRESULT res; HRESULT res;
TRACE("(this=%p)\n",This); TRACE("(this=%p)\n",This);
if ((res = IDirectInputDevice2AImpl_Unacquire(iface)) != DI_OK) return res; if ((res = IDirectInputDevice2WImpl_Unacquire(iface)) != DI_OK) return res;
if (This->base.dwCoopLevel & DISCL_EXCLUSIVE) if (This->base.dwCoopLevel & DISCL_EXCLUSIVE)
{ {
@ -510,20 +524,25 @@ static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
TRACE(" warping mouse back to (%d , %d)\n", This->org_coords.x, This->org_coords.y); TRACE(" warping mouse back to (%d , %d)\n", This->org_coords.x, This->org_coords.y);
SetCursorPos(This->org_coords.x, This->org_coords.y); SetCursorPos(This->org_coords.x, This->org_coords.y);
} }
return DI_OK; return DI_OK;
} }
static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
{
SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
return SysMouseWImpl_Unacquire(IDirectInputDevice8W_from_impl(This));
}
/****************************************************************************** /******************************************************************************
* GetDeviceState : returns the "state" of the mouse. * GetDeviceState : returns the "state" of the mouse.
* *
* For the moment, only the "standard" return structure (DIMOUSESTATE) is * For the moment, only the "standard" return structure (DIMOUSESTATE) is
* supported. * supported.
*/ */
static HRESULT WINAPI SysMouseAImpl_GetDeviceState( static HRESULT WINAPI SysMouseWImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W iface, DWORD len, LPVOID ptr)
LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr {
) { SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface);
SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
if(This->base.acquired == 0) return DIERR_NOTACQUIRED; if(This->base.acquired == 0) return DIERR_NOTACQUIRED;
@ -554,20 +573,26 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
This->need_warp = FALSE; This->need_warp = FALSE;
} }
return DI_OK; return DI_OK;
} }
static HRESULT WINAPI SysMouseAImpl_GetDeviceState(LPDIRECTINPUTDEVICE8A iface, DWORD len, LPVOID ptr)
{
SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
return SysMouseWImpl_GetDeviceState(IDirectInputDevice8W_from_impl(This), len, ptr);
}
/****************************************************************************** /******************************************************************************
* GetDeviceData : gets buffered input data. * GetDeviceData : gets buffered input data.
*/ */
static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface, static HRESULT WINAPI SysMouseWImpl_GetDeviceData(LPDIRECTINPUTDEVICE8W iface,
DWORD dodsize, LPDIDEVICEOBJECTDATA dod, LPDWORD entries, DWORD flags) DWORD dodsize, LPDIDEVICEOBJECTDATA dod, LPDWORD entries, DWORD flags)
{ {
SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface); SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface);
HRESULT res; HRESULT res;
res = IDirectInputDevice2AImpl_GetDeviceData(iface, dodsize, dod, entries, flags); res = IDirectInputDevice2WImpl_GetDeviceData(iface, dodsize, dod, entries, flags);
if (FAILED(res)) return res; if (FAILED(res)) return res;
/* Check if we need to do a mouse warping */ /* Check if we need to do a mouse warping */
@ -584,14 +609,19 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
return res; return res;
} }
static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
DWORD dodsize, LPDIDEVICEOBJECTDATA dod, LPDWORD entries, DWORD flags)
{
SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
return SysMouseWImpl_GetDeviceData(IDirectInputDevice8W_from_impl(This), dodsize, dod, entries, flags);
}
/****************************************************************************** /******************************************************************************
* GetProperty : get input device properties * GetProperty : get input device properties
*/ */
static HRESULT WINAPI SysMouseAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, static HRESULT WINAPI SysMouseWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph)
REFGUID rguid,
LPDIPROPHEADER pdiph)
{ {
SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface); SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface);
TRACE("(%p) %s,%p\n", This, debugstr_guid(rguid), pdiph); TRACE("(%p) %s,%p\n", This, debugstr_guid(rguid), pdiph);
_dump_DIPROPHEADER(pdiph); _dump_DIPROPHEADER(pdiph);
@ -624,21 +654,25 @@ static HRESULT WINAPI SysMouseAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
} }
default: default:
return IDirectInputDevice2AImpl_GetProperty(iface, rguid, pdiph); return IDirectInputDevice2WImpl_GetProperty(iface, rguid, pdiph);
} }
} }
return DI_OK; return DI_OK;
} }
static HRESULT WINAPI SysMouseAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph)
{
SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
return SysMouseWImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph);
}
/****************************************************************************** /******************************************************************************
* GetCapabilities : get the device capabilities * GetCapabilities : get the device capabilities
*/ */
static HRESULT WINAPI SysMouseAImpl_GetCapabilities( static HRESULT WINAPI SysMouseWImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W iface, LPDIDEVCAPS lpDIDevCaps)
LPDIRECTINPUTDEVICE8A iface,
LPDIDEVCAPS lpDIDevCaps)
{ {
SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface); SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface);
DIDEVCAPS devcaps; DIDEVCAPS devcaps;
TRACE("(this=%p,%p)\n",This,lpDIDevCaps); TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
@ -664,10 +698,16 @@ static HRESULT WINAPI SysMouseAImpl_GetCapabilities(
devcaps.dwFFDriverVersion = 0; devcaps.dwFFDriverVersion = 0;
memcpy(lpDIDevCaps, &devcaps, lpDIDevCaps->dwSize); memcpy(lpDIDevCaps, &devcaps, lpDIDevCaps->dwSize);
return DI_OK; return DI_OK;
} }
static HRESULT WINAPI SysMouseAImpl_GetCapabilities(LPDIRECTINPUTDEVICE8A iface, LPDIDEVCAPS lpDIDevCaps)
{
SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
return SysMouseWImpl_GetCapabilities(IDirectInputDevice8W_from_impl(This), lpDIDevCaps);
}
/****************************************************************************** /******************************************************************************
* GetObjectInfo : get information about a device object such as a button * GetObjectInfo : get information about a device object such as a button
* or axis * or axis
@ -697,12 +737,13 @@ static HRESULT WINAPI SysMouseWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
static HRESULT WINAPI SysMouseAImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface, static HRESULT WINAPI SysMouseAImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface,
LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow)
{ {
SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
HRESULT res; HRESULT res;
DIDEVICEOBJECTINSTANCEW didoiW; DIDEVICEOBJECTINSTANCEW didoiW;
DWORD dwSize = pdidoi->dwSize; DWORD dwSize = pdidoi->dwSize;
didoiW.dwSize = sizeof(didoiW); didoiW.dwSize = sizeof(didoiW);
res = SysMouseWImpl_GetObjectInfo((LPDIRECTINPUTDEVICE8W)iface, &didoiW, dwObj, dwHow); res = SysMouseWImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This), &didoiW, dwObj, dwHow);
if (res != DI_OK) return res; if (res != DI_OK) return res;
memset(pdidoi, 0, pdidoi->dwSize); memset(pdidoi, 0, pdidoi->dwSize);
@ -786,25 +827,19 @@ static const IDirectInputDevice8AVtbl SysMouseAvt =
IDirectInputDevice8AImpl_GetImageInfo IDirectInputDevice8AImpl_GetImageInfo
}; };
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(SysMouseWvt.fun))
#else
# define XCAST(fun) (void*)
#endif
static const IDirectInputDevice8WVtbl SysMouseWvt = static const IDirectInputDevice8WVtbl SysMouseWvt =
{ {
IDirectInputDevice2WImpl_QueryInterface, IDirectInputDevice2WImpl_QueryInterface,
IDirectInputDevice2WImpl_AddRef, IDirectInputDevice2WImpl_AddRef,
IDirectInputDevice2WImpl_Release, IDirectInputDevice2WImpl_Release,
XCAST(GetCapabilities)SysMouseAImpl_GetCapabilities, SysMouseWImpl_GetCapabilities,
IDirectInputDevice2WImpl_EnumObjects, IDirectInputDevice2WImpl_EnumObjects,
XCAST(GetProperty)SysMouseAImpl_GetProperty, SysMouseWImpl_GetProperty,
IDirectInputDevice2WImpl_SetProperty, IDirectInputDevice2WImpl_SetProperty,
XCAST(Acquire)SysMouseAImpl_Acquire, SysMouseWImpl_Acquire,
XCAST(Unacquire)SysMouseAImpl_Unacquire, SysMouseWImpl_Unacquire,
XCAST(GetDeviceState)SysMouseAImpl_GetDeviceState, SysMouseWImpl_GetDeviceState,
XCAST(GetDeviceData)SysMouseAImpl_GetDeviceData, SysMouseWImpl_GetDeviceData,
IDirectInputDevice2WImpl_SetDataFormat, IDirectInputDevice2WImpl_SetDataFormat,
IDirectInputDevice2WImpl_SetEventNotification, IDirectInputDevice2WImpl_SetEventNotification,
IDirectInputDevice2WImpl_SetCooperativeLevel, IDirectInputDevice2WImpl_SetCooperativeLevel,
@ -827,4 +862,3 @@ static const IDirectInputDevice8WVtbl SysMouseWvt =
IDirectInputDevice8WImpl_SetActionMap, IDirectInputDevice8WImpl_SetActionMap,
IDirectInputDevice8WImpl_GetImageInfo IDirectInputDevice8WImpl_GetImageInfo
}; };
#undef XCAST