dinput: Zero the out buffer.
This commit is contained in:
parent
0fb6e30838
commit
aa0188cd6f
@ -265,11 +265,13 @@ DWORD get_config_key( HKEY defkey, HKEY appkey, const char *name,
|
||||
}
|
||||
|
||||
/* Conversion between internal data buffer and external data buffer */
|
||||
void fill_DataFormat(void *out, const void *in, const DataFormat *df) {
|
||||
void fill_DataFormat(void *out, DWORD size, const void *in, const DataFormat *df)
|
||||
{
|
||||
int i;
|
||||
const char *in_c = in;
|
||||
char *out_c = (char *) out;
|
||||
|
||||
memset(out, 0, size);
|
||||
if (df->dt == NULL) {
|
||||
/* This means that the app uses Wine's internal data format */
|
||||
memcpy(out, in, df->internal_format_size);
|
||||
|
@ -76,7 +76,7 @@ extern BOOL get_app_key(HKEY*, HKEY*);
|
||||
extern DWORD get_config_key(HKEY, HKEY, const char*, char*, DWORD);
|
||||
|
||||
/* Routines to do DataFormat / WineFormat conversions */
|
||||
extern void fill_DataFormat(void *out, const void *in, const DataFormat *df) ;
|
||||
extern void fill_DataFormat(void *out, DWORD size, const void *in, const DataFormat *df) ;
|
||||
extern HRESULT create_DataFormat(LPCDIDATAFORMAT asked_format, DataFormat *format);
|
||||
extern void release_DataFormat(DataFormat *df) ;
|
||||
extern void queue_event(LPDIRECTINPUTDEVICE8A iface, int ofs, DWORD data, DWORD time, DWORD seq);
|
||||
|
@ -767,7 +767,7 @@ static HRESULT WINAPI JoystickAImpl_GetDeviceState(
|
||||
joy_polldev(This);
|
||||
|
||||
/* convert and copy data to user supplied buffer */
|
||||
fill_DataFormat(ptr, &This->js, &This->base.data_format);
|
||||
fill_DataFormat(ptr, len, &This->js, &This->base.data_format);
|
||||
|
||||
return DI_OK;
|
||||
}
|
||||
|
@ -802,7 +802,7 @@ static HRESULT WINAPI JoystickAImpl_GetDeviceState(
|
||||
joy_polldev(This);
|
||||
|
||||
/* convert and copy data to user supplied buffer */
|
||||
fill_DataFormat(ptr, &This->js, &This->base.data_format);
|
||||
fill_DataFormat(ptr, len, &This->js, &This->base.data_format);
|
||||
|
||||
return DI_OK;
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState(
|
||||
}
|
||||
}
|
||||
|
||||
fill_DataFormat(ptr, This->DInputKeyState, &This->base.data_format);
|
||||
fill_DataFormat(ptr, len, This->DInputKeyState, &This->base.data_format);
|
||||
LeaveCriticalSection(&This->base.crit);
|
||||
|
||||
return DI_OK;
|
||||
|
@ -490,7 +490,7 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
|
||||
|
||||
EnterCriticalSection(&This->base.crit);
|
||||
/* Copy the current mouse state */
|
||||
fill_DataFormat(ptr, &(This->m_state), &This->base.data_format);
|
||||
fill_DataFormat(ptr, len, &This->m_state, &This->base.data_format);
|
||||
|
||||
/* Initialize the buffer when in relative mode */
|
||||
if (!(This->base.data_format.user_df->dwFlags & DIDF_ABSAXIS))
|
||||
|
@ -70,20 +70,21 @@ static void acquire_tests(LPDIRECTINPUT pDI, HWND hwnd)
|
||||
HRESULT hr;
|
||||
LPDIRECTINPUTDEVICE pKeyboard;
|
||||
BYTE kbd_state[256];
|
||||
BYTE custom_state[4];
|
||||
LONG custom_state[6];
|
||||
int i;
|
||||
DIOBJECTDATAFORMAT dodf[] =
|
||||
{
|
||||
{ &GUID_Key, 0, DIDFT_MAKEINSTANCE(DIK_Q)|DIDFT_BUTTON, 0 },
|
||||
{ &GUID_Key, 1, DIDFT_MAKEINSTANCE(DIK_W)|DIDFT_BUTTON, 0 },
|
||||
{ &GUID_Key, 2, DIDFT_MAKEINSTANCE(DIK_E)|DIDFT_BUTTON, 0 },
|
||||
{ &GUID_Key, 3, DIDFT_MAKEINSTANCE(DIK_R)|DIDFT_BUTTON, 0 },
|
||||
{ &GUID_Key, sizeof(LONG) * 0, DIDFT_MAKEINSTANCE(DIK_Q)|DIDFT_BUTTON, 0 },
|
||||
{ &GUID_Key, sizeof(LONG) * 1, DIDFT_MAKEINSTANCE(DIK_W)|DIDFT_BUTTON, 0 },
|
||||
{ &GUID_Key, sizeof(LONG) * 2, DIDFT_MAKEINSTANCE(DIK_E)|DIDFT_BUTTON, 0 },
|
||||
{ &GUID_Key, sizeof(LONG) * 4, DIDFT_MAKEINSTANCE(DIK_R)|DIDFT_BUTTON, 0 },
|
||||
};
|
||||
|
||||
DIDATAFORMAT df;
|
||||
df.dwSize = sizeof( df );
|
||||
df.dwObjSize = sizeof( DIOBJECTDATAFORMAT );
|
||||
df.dwFlags = DIDF_RELAXIS;
|
||||
df.dwDataSize = sizeof( dodf )/sizeof( dodf[0] );
|
||||
df.dwDataSize = sizeof( custom_state );
|
||||
df.dwNumObjs = sizeof( dodf )/sizeof( dodf[0] );
|
||||
df.rgodf = dodf;
|
||||
|
||||
@ -120,6 +121,11 @@ static void acquire_tests(LPDIRECTINPUT pDI, HWND hwnd)
|
||||
hr = IDirectInputDevice_GetDeviceState(pKeyboard, sizeof(kbd_state), kbd_state);
|
||||
ok(hr == DIERR_INVALIDPARAM, "IDirectInputDevice_GetDeviceState(256,) should have failed: %08x\n", hr);
|
||||
|
||||
memset(custom_state, 0x56, sizeof(custom_state));
|
||||
IDirectInputDevice_GetDeviceState(pKeyboard, sizeof(custom_state), custom_state);
|
||||
for (i = 0; i < sizeof(custom_state) / sizeof(custom_state[0]); i++)
|
||||
ok(custom_state[i] == 0, "Should be zeroed, got 0x%08x\n", custom_state[i]);
|
||||
|
||||
if (pKeyboard) IUnknown_Release(pKeyboard);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user