dinput: Factor all GetDeviceInfo implementations together.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e6009c5b55
commit
fc7f430afb
|
@ -1176,6 +1176,25 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8
|
|||
return hr;
|
||||
}
|
||||
|
||||
HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceInfo( IDirectInputDevice8W *iface, DIDEVICEINSTANCEW *instance )
|
||||
{
|
||||
IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8W( iface );
|
||||
DWORD size;
|
||||
|
||||
TRACE( "iface %p, instance %p.\n", iface, instance );
|
||||
|
||||
if (!instance) return E_POINTER;
|
||||
if (instance->dwSize != sizeof(DIDEVICEINSTANCE_DX3W) &&
|
||||
instance->dwSize != sizeof(DIDEVICEINSTANCEW))
|
||||
return DIERR_INVALIDPARAM;
|
||||
|
||||
size = instance->dwSize;
|
||||
memcpy( instance, &impl->instance, size );
|
||||
instance->dwSize = size;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* SetEventNotification : specifies event to be sent on state change
|
||||
*/
|
||||
|
@ -1740,6 +1759,7 @@ HRESULT direct_input_device_alloc( SIZE_T size, const IDirectInputDevice8WVtbl *
|
|||
This->IDirectInputDevice8W_iface.lpVtbl = vtbl;
|
||||
This->ref = 1;
|
||||
This->guid = *guid;
|
||||
This->instance.dwSize = sizeof(DIDEVICEINSTANCEW);
|
||||
This->data_format.wine_df = format;
|
||||
InitializeCriticalSection( &This->crit );
|
||||
This->dinput = dinput;
|
||||
|
|
|
@ -67,6 +67,7 @@ struct IDirectInputDeviceImpl
|
|||
IDirectInputImpl *dinput;
|
||||
struct list entry; /* entry into acquired device list */
|
||||
HANDLE hEvent;
|
||||
DIDEVICEINSTANCEW instance;
|
||||
DWORD dwCoopLevel;
|
||||
HWND win;
|
||||
int acquired;
|
||||
|
@ -120,6 +121,8 @@ extern HRESULT WINAPI IDirectInputDevice2WImpl_Acquire(LPDIRECTINPUTDEVICE8W ifa
|
|||
extern HRESULT WINAPI IDirectInputDevice2WImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN;
|
||||
extern HRESULT WINAPI IDirectInputDevice2WImpl_SetDataFormat(LPDIRECTINPUTDEVICE8W iface, LPCDIDATAFORMAT df) DECLSPEC_HIDDEN;
|
||||
extern HRESULT WINAPI IDirectInputDevice2WImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8W iface, HWND hwnd, DWORD dwflags) DECLSPEC_HIDDEN;
|
||||
extern HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceInfo( IDirectInputDevice8W *iface,
|
||||
DIDEVICEINSTANCEW *instance );
|
||||
extern HRESULT WINAPI IDirectInputDevice2WImpl_SetEventNotification(LPDIRECTINPUTDEVICE8W iface, HANDLE hnd) DECLSPEC_HIDDEN;
|
||||
extern ULONG WINAPI IDirectInputDevice2WImpl_Release(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN;
|
||||
extern HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(LPDIRECTINPUTDEVICE8W iface, REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -161,7 +161,6 @@ struct hid_joystick
|
|||
OVERLAPPED read_ovl;
|
||||
PHIDP_PREPARSED_DATA preparsed;
|
||||
|
||||
DIDEVICEINSTANCEW instance;
|
||||
WCHAR device_path[MAX_PATH];
|
||||
HIDD_ATTRIBUTES attrs;
|
||||
DIDEVCAPS dev_caps;
|
||||
|
@ -775,14 +774,14 @@ static HRESULT WINAPI hid_joystick_GetProperty( IDirectInputDevice8W *iface, con
|
|||
{
|
||||
DIPROPSTRING *value = (DIPROPSTRING *)header;
|
||||
if (header->dwSize != sizeof(DIPROPSTRING)) return DIERR_INVALIDPARAM;
|
||||
lstrcpynW( value->wsz, impl->instance.tszProductName, MAX_PATH );
|
||||
lstrcpynW( value->wsz, impl->base.instance.tszProductName, MAX_PATH );
|
||||
return DI_OK;
|
||||
}
|
||||
case (DWORD_PTR)DIPROP_INSTANCENAME:
|
||||
{
|
||||
DIPROPSTRING *value = (DIPROPSTRING *)header;
|
||||
if (header->dwSize != sizeof(DIPROPSTRING)) return DIERR_INVALIDPARAM;
|
||||
lstrcpynW( value->wsz, impl->instance.tszInstanceName, MAX_PATH );
|
||||
lstrcpynW( value->wsz, impl->base.instance.tszInstanceName, MAX_PATH );
|
||||
return DI_OK;
|
||||
}
|
||||
case (DWORD_PTR)DIPROP_VIDPID:
|
||||
|
@ -797,7 +796,7 @@ static HRESULT WINAPI hid_joystick_GetProperty( IDirectInputDevice8W *iface, con
|
|||
{
|
||||
DIPROPDWORD *value = (DIPROPDWORD *)header;
|
||||
if (header->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM;
|
||||
value->dwData = impl->instance.guidInstance.Data3;
|
||||
value->dwData = impl->base.instance.guidInstance.Data3;
|
||||
return DI_OK;
|
||||
}
|
||||
case (DWORD_PTR)DIPROP_GUIDANDPATH:
|
||||
|
@ -1060,22 +1059,6 @@ static HRESULT WINAPI hid_joystick_GetObjectInfo( IDirectInputDevice8W *iface, D
|
|||
return DIERR_NOTFOUND;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI hid_joystick_GetDeviceInfo( IDirectInputDevice8W *iface, DIDEVICEINSTANCEW *instance )
|
||||
{
|
||||
struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface );
|
||||
|
||||
TRACE( "iface %p, instance %p.\n", iface, instance );
|
||||
|
||||
if (!instance) return E_POINTER;
|
||||
if (instance->dwSize != sizeof(DIDEVICEINSTANCE_DX3W) &&
|
||||
instance->dwSize != sizeof(DIDEVICEINSTANCEW))
|
||||
return DIERR_INVALIDPARAM;
|
||||
|
||||
memcpy( instance, &impl->instance, instance->dwSize );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT hid_joystick_effect_create( struct hid_joystick *joystick, IDirectInputEffect **out );
|
||||
|
||||
static HRESULT WINAPI hid_joystick_CreateEffect( IDirectInputDevice8W *iface, const GUID *guid,
|
||||
|
@ -1457,7 +1440,7 @@ static const IDirectInputDevice8WVtbl hid_joystick_vtbl =
|
|||
IDirectInputDevice2WImpl_SetEventNotification,
|
||||
IDirectInputDevice2WImpl_SetCooperativeLevel,
|
||||
hid_joystick_GetObjectInfo,
|
||||
hid_joystick_GetDeviceInfo,
|
||||
IDirectInputDevice2WImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2WImpl_RunControlPanel,
|
||||
IDirectInputDevice2WImpl_Initialize,
|
||||
/*** IDirectInputDevice2 methods ***/
|
||||
|
@ -2277,7 +2260,7 @@ static HRESULT hid_joystick_create_device( IDirectInputImpl *dinput, const GUID
|
|||
if (hr != DI_OK) goto failed;
|
||||
|
||||
impl->ref = 1;
|
||||
impl->instance = instance;
|
||||
impl->base.instance = instance;
|
||||
impl->attrs = attrs;
|
||||
impl->dev_caps.dwSize = sizeof(impl->dev_caps);
|
||||
impl->dev_caps.dwFlags = DIDC_ATTACHED | DIDC_EMULATED;
|
||||
|
|
|
@ -43,7 +43,6 @@ struct SysKeyboardImpl
|
|||
{
|
||||
struct IDirectInputDeviceImpl base;
|
||||
BYTE DInputKeyState[WINE_DINPUT_KEYBOARD_MAX_KEYS];
|
||||
DWORD subtype;
|
||||
};
|
||||
|
||||
static inline SysKeyboardImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
|
||||
|
@ -89,9 +88,9 @@ static BYTE map_dik_code(DWORD scanCode, DWORD vkCode, DWORD subType, DWORD vers
|
|||
int dinput_keyboard_hook( IDirectInputDevice8W *iface, WPARAM wparam, LPARAM lparam )
|
||||
{
|
||||
SysKeyboardImpl *This = impl_from_IDirectInputDevice8W( iface );
|
||||
BYTE new_diks, subtype = GET_DIDEVICE_SUBTYPE( This->base.instance.dwDevType );
|
||||
int dik_code, ret = This->base.dwCoopLevel & DISCL_EXCLUSIVE;
|
||||
KBDLLHOOKSTRUCT *hook = (KBDLLHOOKSTRUCT *)lparam;
|
||||
BYTE new_diks;
|
||||
|
||||
if (wparam != WM_KEYDOWN && wparam != WM_KEYUP &&
|
||||
wparam != WM_SYSKEYDOWN && wparam != WM_SYSKEYUP)
|
||||
|
@ -108,7 +107,8 @@ int dinput_keyboard_hook( IDirectInputDevice8W *iface, WPARAM wparam, LPARAM lpa
|
|||
case VK_NUMLOCK : dik_code = DIK_NUMLOCK; break;
|
||||
case VK_SUBTRACT: dik_code = DIK_SUBTRACT; break;
|
||||
default:
|
||||
dik_code = map_dik_code(hook->scanCode & 0xff, hook->vkCode, This->subtype, This->base.dinput->dwVersion);
|
||||
dik_code = map_dik_code( hook->scanCode & 0xff, hook->vkCode, subtype,
|
||||
This->base.dinput->dwVersion );
|
||||
if (hook->flags & LLKHF_EXTENDED) dik_code |= 0x80;
|
||||
}
|
||||
new_diks = hook->flags & LLKHF_UP ? 0 : 0x80;
|
||||
|
@ -193,6 +193,7 @@ static HRESULT keyboarddev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVIC
|
|||
|
||||
static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, SysKeyboardImpl **out )
|
||||
{
|
||||
BYTE subtype = get_keyboard_subtype();
|
||||
SysKeyboardImpl* newDevice;
|
||||
LPDIDATAFORMAT df = NULL;
|
||||
int i, idx = 0;
|
||||
|
@ -203,7 +204,7 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, SysKeyboar
|
|||
df = newDevice->base.data_format.wine_df;
|
||||
newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysKeyboardImpl*->base.crit");
|
||||
|
||||
newDevice->subtype = get_keyboard_subtype();
|
||||
fill_keyboard_dideviceinstanceW( &newDevice->base.instance, newDevice->base.dinput->dwVersion, subtype );
|
||||
|
||||
/* Create copy of default data format */
|
||||
memcpy(df, &c_dfDIKeyboard, c_dfDIKeyboard.dwSize);
|
||||
|
@ -217,7 +218,7 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, SysKeyboar
|
|||
if (!GetKeyNameTextA(((i & 0x7f) << 16) | ((i & 0x80) << 17), buf, sizeof(buf)))
|
||||
continue;
|
||||
|
||||
dik_code = map_dik_code(i, 0, newDevice->subtype, dinput->dwVersion);
|
||||
dik_code = map_dik_code( i, 0, subtype, dinput->dwVersion );
|
||||
memcpy(&df->rgodf[idx], &c_dfDIKeyboard.rgodf[dik_code], df->dwObjSize);
|
||||
df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(dik_code) | DIDFT_PSHBUTTON;
|
||||
}
|
||||
|
@ -294,6 +295,7 @@ static HRESULT WINAPI SysKeyboardWImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W ifac
|
|||
static HRESULT WINAPI SysKeyboardWImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W iface, LPDIDEVCAPS lpDIDevCaps)
|
||||
{
|
||||
SysKeyboardImpl *This = impl_from_IDirectInputDevice8W(iface);
|
||||
BYTE subtype = GET_DIDEVICE_SUBTYPE( This->base.instance.dwDevType );
|
||||
DIDEVCAPS devcaps;
|
||||
|
||||
TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
|
||||
|
@ -306,9 +308,9 @@ static HRESULT WINAPI SysKeyboardWImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W ifa
|
|||
devcaps.dwSize = lpDIDevCaps->dwSize;
|
||||
devcaps.dwFlags = DIDC_ATTACHED | DIDC_EMULATED;
|
||||
if (This->base.dinput->dwVersion >= 0x0800)
|
||||
devcaps.dwDevType = DI8DEVTYPE_KEYBOARD | (This->subtype << 8);
|
||||
devcaps.dwDevType = DI8DEVTYPE_KEYBOARD | (subtype << 8);
|
||||
else
|
||||
devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (This->subtype << 8);
|
||||
devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (subtype << 8);
|
||||
devcaps.dwAxes = 0;
|
||||
devcaps.dwButtons = This->base.data_format.wine_df->dwNumObjs;
|
||||
devcaps.dwPOVs = 0;
|
||||
|
@ -367,13 +369,14 @@ static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface
|
|||
DWORD dwHow)
|
||||
{
|
||||
SysKeyboardImpl *This = impl_from_IDirectInputDevice8W(iface);
|
||||
BYTE subtype = GET_DIDEVICE_SUBTYPE( This->base.instance.dwDevType );
|
||||
HRESULT res;
|
||||
LONG scan;
|
||||
|
||||
res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
|
||||
if (res != DI_OK) return res;
|
||||
|
||||
scan = map_dik_to_scan(DIDFT_GETINSTANCE(pdidoi->dwType), This->subtype);
|
||||
scan = map_dik_to_scan( DIDFT_GETINSTANCE( pdidoi->dwType ), subtype );
|
||||
if (!GetKeyNameTextW((scan & 0x80) << 17 | (scan & 0x7f) << 16,
|
||||
pdidoi->tszName, ARRAY_SIZE(pdidoi->tszName)))
|
||||
return DIERR_OBJECTNOTFOUND;
|
||||
|
@ -382,24 +385,6 @@ static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface
|
|||
return res;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* GetDeviceInfo : get information about a device's identity
|
||||
*/
|
||||
static HRESULT WINAPI SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi)
|
||||
{
|
||||
SysKeyboardImpl *This = impl_from_IDirectInputDevice8W(iface);
|
||||
TRACE("(this=%p,%p)\n", This, pdidi);
|
||||
|
||||
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
|
||||
WARN(" dinput3 not supported yet...\n");
|
||||
return DI_OK;
|
||||
}
|
||||
|
||||
fill_keyboard_dideviceinstanceW(pdidi, This->base.dinput->dwVersion, This->subtype);
|
||||
|
||||
return DI_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* GetProperty : Retrieves information about the input device.
|
||||
*/
|
||||
|
@ -496,7 +481,7 @@ static const IDirectInputDevice8WVtbl SysKeyboardWvt =
|
|||
IDirectInputDevice2WImpl_SetEventNotification,
|
||||
IDirectInputDevice2WImpl_SetCooperativeLevel,
|
||||
SysKeyboardWImpl_GetObjectInfo,
|
||||
SysKeyboardWImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2WImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2WImpl_RunControlPanel,
|
||||
IDirectInputDevice2WImpl_Initialize,
|
||||
IDirectInputDevice2WImpl_CreateEffect,
|
||||
|
|
|
@ -148,6 +148,7 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, SysMouseIm
|
|||
df = newDevice->base.data_format.wine_df;
|
||||
newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysMouseImpl*->base.crit");
|
||||
|
||||
fill_mouse_dideviceinstanceW( &newDevice->base.instance, newDevice->base.dinput->dwVersion );
|
||||
newDevice->base.dwCoopLevel = DISCL_NONEXCLUSIVE | DISCL_BACKGROUND;
|
||||
|
||||
get_app_key(&hkey, &appkey);
|
||||
|
@ -705,24 +706,6 @@ static HRESULT WINAPI SysMouseWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
|
|||
return res;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* GetDeviceInfo : get information about a device's identity
|
||||
*/
|
||||
static HRESULT WINAPI SysMouseWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi)
|
||||
{
|
||||
SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface);
|
||||
TRACE("(this=%p,%p)\n", This, pdidi);
|
||||
|
||||
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
|
||||
WARN(" dinput3 not supported yet...\n");
|
||||
return DI_OK;
|
||||
}
|
||||
|
||||
fill_mouse_dideviceinstanceW(pdidi, This->base.dinput->dwVersion);
|
||||
|
||||
return DI_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI SysMouseWImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
|
||||
LPDIACTIONFORMATW lpdiaf,
|
||||
LPCWSTR lpszUserName,
|
||||
|
@ -761,7 +744,7 @@ static const IDirectInputDevice8WVtbl SysMouseWvt =
|
|||
IDirectInputDevice2WImpl_SetEventNotification,
|
||||
IDirectInputDevice2WImpl_SetCooperativeLevel,
|
||||
SysMouseWImpl_GetObjectInfo,
|
||||
SysMouseWImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2WImpl_GetDeviceInfo,
|
||||
IDirectInputDevice2WImpl_RunControlPanel,
|
||||
IDirectInputDevice2WImpl_Initialize,
|
||||
IDirectInputDevice2WImpl_CreateEffect,
|
||||
|
|
Loading…
Reference in New Issue