dinput: Move keyboard to using new EnumObjects from base class.
This commit is contained in:
parent
7d37e8e9c7
commit
263d5ce171
|
@ -835,6 +835,10 @@ HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(
|
||||||
if (IsEqualGUID(&ddoi.guidType, &GUID_XAxis)) strcpy(ddoi.tszName, "X-Axis");
|
if (IsEqualGUID(&ddoi.guidType, &GUID_XAxis)) strcpy(ddoi.tszName, "X-Axis");
|
||||||
else if (IsEqualGUID(&ddoi.guidType, &GUID_YAxis)) strcpy(ddoi.tszName, "Y-Axis");
|
else if (IsEqualGUID(&ddoi.guidType, &GUID_YAxis)) strcpy(ddoi.tszName, "Y-Axis");
|
||||||
else if (IsEqualGUID(&ddoi.guidType, &GUID_ZAxis)) strcpy(ddoi.tszName, "Z-Axis");
|
else if (IsEqualGUID(&ddoi.guidType, &GUID_ZAxis)) strcpy(ddoi.tszName, "Z-Axis");
|
||||||
|
else if (IsEqualGUID(&ddoi.guidType, &GUID_Key ))
|
||||||
|
GetKeyNameTextA((DIDFT_GETINSTANCE(odf->dwType) & 0x80) << 17 |
|
||||||
|
(DIDFT_GETINSTANCE(odf->dwType) & 0x7f) << 16,
|
||||||
|
ddoi.tszName, sizeof(ddoi.tszName));
|
||||||
else if (type & DIDFT_AXIS) wsprintfA(ddoi.tszName, "%d-Axis", axis - 1);
|
else if (type & DIDFT_AXIS) wsprintfA(ddoi.tszName, "%d-Axis", axis - 1);
|
||||||
else if (type & DIDFT_BUTTON) wsprintfA(ddoi.tszName, "Button %d", button - 1);
|
else if (type & DIDFT_BUTTON) wsprintfA(ddoi.tszName, "Button %d", button - 1);
|
||||||
else FIXME("no name\n");
|
else FIXME("no name\n");
|
||||||
|
|
|
@ -188,6 +188,8 @@ static BOOL keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEI
|
||||||
static SysKeyboardImpl *alloc_device(REFGUID rguid, const void *kvt, IDirectInputImpl *dinput)
|
static SysKeyboardImpl *alloc_device(REFGUID rguid, const void *kvt, IDirectInputImpl *dinput)
|
||||||
{
|
{
|
||||||
SysKeyboardImpl* newDevice;
|
SysKeyboardImpl* newDevice;
|
||||||
|
LPDIDATAFORMAT df = NULL;
|
||||||
|
int i, idx = 0;
|
||||||
|
|
||||||
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl));
|
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl));
|
||||||
newDevice->base.lpVtbl = kvt;
|
newDevice->base.lpVtbl = kvt;
|
||||||
|
@ -196,13 +198,30 @@ static SysKeyboardImpl *alloc_device(REFGUID rguid, const void *kvt, IDirectInpu
|
||||||
newDevice->dinput = dinput;
|
newDevice->dinput = dinput;
|
||||||
InitializeCriticalSection(&newDevice->base.crit);
|
InitializeCriticalSection(&newDevice->base.crit);
|
||||||
|
|
||||||
newDevice->base.data_format.wine_df = &c_dfDIKeyboard;
|
/* Create copy of default data format */
|
||||||
if (create_DataFormat(&c_dfDIKeyboard, &newDevice->base.data_format) == DI_OK)
|
if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIKeyboard.dwSize))) goto failed;
|
||||||
|
memcpy(df, &c_dfDIKeyboard, c_dfDIKeyboard.dwSize);
|
||||||
|
if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto failed;
|
||||||
|
|
||||||
|
for (i = 0; i < df->dwNumObjs; i++)
|
||||||
{
|
{
|
||||||
|
char buf[MAX_PATH];
|
||||||
|
|
||||||
|
if (!GetKeyNameTextA(((i & 0x7f) << 16) | ((i & 0x80) << 17), buf, sizeof(buf)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
memcpy(&df->rgodf[idx], &c_dfDIKeyboard.rgodf[i], df->dwObjSize);
|
||||||
|
df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_PSHBUTTON;
|
||||||
|
}
|
||||||
|
df->dwNumObjs = idx;
|
||||||
|
|
||||||
|
newDevice->base.data_format.wine_df = df;
|
||||||
IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->dinput);
|
IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->dinput);
|
||||||
return newDevice;
|
return newDevice;
|
||||||
}
|
|
||||||
|
|
||||||
|
failed:
|
||||||
|
if (df) HeapFree(GetProcessHeap(), 0, df->rgodf);
|
||||||
|
HeapFree(GetProcessHeap(), 0, df);
|
||||||
HeapFree(GetProcessHeap(), 0, newDevice);
|
HeapFree(GetProcessHeap(), 0, newDevice);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -265,6 +284,11 @@ static ULONG WINAPI SysKeyboardAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
|
||||||
set_dinput_hook(WH_KEYBOARD_LL, NULL);
|
set_dinput_hook(WH_KEYBOARD_LL, NULL);
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, This->base.data_queue);
|
HeapFree(GetProcessHeap(), 0, This->base.data_queue);
|
||||||
|
|
||||||
|
/* Free data format */
|
||||||
|
HeapFree(GetProcessHeap(), 0, (LPVOID)This->base.data_format.wine_df);
|
||||||
|
release_DataFormat(&This->base.data_format);
|
||||||
|
|
||||||
IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->dinput);
|
IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->dinput);
|
||||||
DeleteCriticalSection(&This->base.crit);
|
DeleteCriticalSection(&This->base.crit);
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
|
@ -301,56 +325,6 @@ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState(
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI SysKeyboardAImpl_EnumObjects(
|
|
||||||
LPDIRECTINPUTDEVICE8A iface,
|
|
||||||
LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
|
|
||||||
LPVOID lpvRef,
|
|
||||||
DWORD dwFlags)
|
|
||||||
{
|
|
||||||
SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
|
|
||||||
DIDEVICEOBJECTINSTANCEA ddoi;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
TRACE("(this=%p,%p,%p,%08x)\n", This, lpCallback, lpvRef, dwFlags);
|
|
||||||
if (TRACE_ON(dinput)) {
|
|
||||||
TRACE(" - flags = ");
|
|
||||||
_dump_EnumObjects_flags(dwFlags);
|
|
||||||
TRACE("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only the fields till dwFFMaxForce are relevant */
|
|
||||||
memset(&ddoi, 0, sizeof(ddoi));
|
|
||||||
ddoi.dwSize = FIELD_OFFSET(DIDEVICEOBJECTINSTANCEA, dwFFMaxForce);
|
|
||||||
|
|
||||||
for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
|
|
||||||
{
|
|
||||||
if (!GetKeyNameTextA(((i & 0x7f) << 16) | ((i & 0x80) << 17), ddoi.tszName, sizeof(ddoi.tszName)))
|
|
||||||
continue;
|
|
||||||
ddoi.guidType = GUID_Key;
|
|
||||||
ddoi.dwOfs = i;
|
|
||||||
ddoi.dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_BUTTON;
|
|
||||||
_dump_OBJECTINSTANCEA(&ddoi);
|
|
||||||
if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) return DI_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return DI_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI SysKeyboardWImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface,
|
|
||||||
LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
|
|
||||||
LPVOID lpvRef,
|
|
||||||
DWORD dwFlags)
|
|
||||||
{
|
|
||||||
SysKeyboardImpl *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_Unacquire(LPDIRECTINPUTDEVICE8A iface);
|
||||||
|
|
||||||
static HRESULT WINAPI SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
|
static HRESULT WINAPI SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
|
||||||
|
@ -417,7 +391,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities(
|
||||||
else
|
else
|
||||||
devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
|
devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
|
||||||
devcaps.dwAxes = 0;
|
devcaps.dwAxes = 0;
|
||||||
devcaps.dwButtons = WINE_DINPUT_KEYBOARD_MAX_KEYS;
|
devcaps.dwButtons = This->base.data_format.wine_df->dwNumObjs;
|
||||||
devcaps.dwPOVs = 0;
|
devcaps.dwPOVs = 0;
|
||||||
devcaps.dwFFSamplePeriod = 0;
|
devcaps.dwFFSamplePeriod = 0;
|
||||||
devcaps.dwFFMinTimeResolution = 0;
|
devcaps.dwFFMinTimeResolution = 0;
|
||||||
|
@ -555,7 +529,7 @@ static const IDirectInputDevice8AVtbl SysKeyboardAvt =
|
||||||
IDirectInputDevice2AImpl_AddRef,
|
IDirectInputDevice2AImpl_AddRef,
|
||||||
SysKeyboardAImpl_Release,
|
SysKeyboardAImpl_Release,
|
||||||
SysKeyboardAImpl_GetCapabilities,
|
SysKeyboardAImpl_GetCapabilities,
|
||||||
SysKeyboardAImpl_EnumObjects,
|
IDirectInputDevice2AImpl_EnumObjects,
|
||||||
IDirectInputDevice2AImpl_GetProperty,
|
IDirectInputDevice2AImpl_GetProperty,
|
||||||
IDirectInputDevice2AImpl_SetProperty,
|
IDirectInputDevice2AImpl_SetProperty,
|
||||||
SysKeyboardAImpl_Acquire,
|
SysKeyboardAImpl_Acquire,
|
||||||
|
@ -597,7 +571,7 @@ static const IDirectInputDevice8WVtbl SysKeyboardWvt =
|
||||||
XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
|
XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
|
||||||
XCAST(Release)SysKeyboardAImpl_Release,
|
XCAST(Release)SysKeyboardAImpl_Release,
|
||||||
XCAST(GetCapabilities)SysKeyboardAImpl_GetCapabilities,
|
XCAST(GetCapabilities)SysKeyboardAImpl_GetCapabilities,
|
||||||
SysKeyboardWImpl_EnumObjects,
|
IDirectInputDevice2WImpl_EnumObjects,
|
||||||
XCAST(GetProperty)IDirectInputDevice2AImpl_GetProperty,
|
XCAST(GetProperty)IDirectInputDevice2AImpl_GetProperty,
|
||||||
XCAST(SetProperty)IDirectInputDevice2AImpl_SetProperty,
|
XCAST(SetProperty)IDirectInputDevice2AImpl_SetProperty,
|
||||||
XCAST(Acquire)SysKeyboardAImpl_Acquire,
|
XCAST(Acquire)SysKeyboardAImpl_Acquire,
|
||||||
|
|
Loading…
Reference in New Issue