Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
June 2022
- 68 participants
- 3274 messages
Re: [PATCH] comctl32: Add partial support for LVM_SETBKIMAGE.
by Zhiyi Zhang
On 6/10/22 17:08, Dmitry Timoshkov wrote:
> Zhiyi Zhang <zzhang(a)codeweavers.com> wrote:
>
>>>> Also, I found LVM_SETBKIMAGE is acting a bit weird on Windows. For example,
>>>> if a LVM_SETBKIMAGE message trying to set a bitmap
>>>> is sent the second time. The second message returns FALSE and the background
>>>> image gets reset to none(from LVM_GETBKIMAGE). I don't know if we should
>>>> implement such a behavior but I would be more comfortable with some tests.
>>> According to my testing LVM_SETBKIMAGE always returns 0.
>> If LVM_SETBKIMAGE for a bitmap succeeds, it does return TRUE.
> Where do you see this? In my tests LVM_SETBKIMAGE always returns 0:
> https://testbot.winehq.org/JobDetails.pl?Key=116659
You're only testing with comctl32 v5. Please see https://testbot.winehq.org/JobDetails.pl?Key=116666&f204=exe32.report#k204
>>> Regarding calling
>>> LVM_SETBKIMAGE again with the same hbitmap I'd guess that the control first
>>> destroys previosuly assigned bitmap, and that leads to a being assigned bitmap
>>> gets destroyed. The conrol then probably verifies bitmap validity before saving
>>> it internally, and that would explain why LVM_GETBKIMAGE returns 0.
>>>
>> Right, this make sense. It would be nice to add a test for this. MSDN doesn't mention that the bitmap
>> will be managed by the control after the message.
> I just added a test that calls LVM_SETBKIMAGE twice with the same bitmap,
> and calls GetObject() to verify the bitmap validity after each call. Adding
> the tests with LVM_GETBKIMAGE would required implementing it, and this deserves
> a separate patch, probably with another set of tests.
>
June 10, 2022
[PATCH v2] comctl32/listview: Add partial support for LVM_SETBKIMAGE.
by Dmitry Timoshkov
v2: Formatting fixes, add some tests.
Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru>
---
dlls/comctl32/listview.c | 78 +++++++++++++++++++++++++++++++---
dlls/comctl32/tests/listview.c | 71 +++++++++++++++++++++++++++++++
2 files changed, 142 insertions(+), 7 deletions(-)
diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index 730bf4aaddd..6a98fcc6274 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -91,7 +91,7 @@
*
* Messages:
* -- LVM_ENABLEGROUPVIEW
- * -- LVM_GETBKIMAGE, LVM_SETBKIMAGE
+ * -- LVM_GETBKIMAGE
* -- LVM_GETGROUPINFO, LVM_SETGROUPINFO
* -- LVM_GETGROUPMETRICS, LVM_SETGROUPMETRICS
* -- LVM_GETINSERTMARK, LVM_SETINSERTMARK
@@ -297,6 +297,7 @@ typedef struct tagLISTVIEW_INFO
COLORREF clrBk;
COLORREF clrText;
COLORREF clrTextBk;
+ HBITMAP hBkBitmap;
/* font */
HFONT hDefaultFont;
@@ -4565,13 +4566,32 @@ static INT LISTVIEW_GetTopIndex(const LISTVIEW_INFO *infoPtr)
* Success: TRUE
* Failure: FALSE
*/
-static inline BOOL LISTVIEW_FillBkgnd(const LISTVIEW_INFO *infoPtr, HDC hdc, const RECT *lprcBox)
+static BOOL LISTVIEW_FillBkgnd(const LISTVIEW_INFO *infoPtr, HDC hdc, const RECT *lprcBox)
{
- if (!infoPtr->hBkBrush) return FALSE;
+ BOOL ret = FALSE;
- TRACE("(hdc=%p, lprcBox=%s, hBkBrush=%p)\n", hdc, wine_dbgstr_rect(lprcBox), infoPtr->hBkBrush);
+ if (infoPtr->hBkBrush)
+ {
+ TRACE("(hdc=%p, lprcBox=%s, hBkBrush=%p)\n", hdc, wine_dbgstr_rect(lprcBox), infoPtr->hBkBrush);
+
+ ret = FillRect(hdc, lprcBox, infoPtr->hBkBrush);
+ }
+
+ if (infoPtr->hBkBitmap)
+ {
+ HDC hdc_src = CreateCompatibleDC(hdc);
+
+ TRACE("(hdc=%p, lprcBox=%s, hBkBitmap=%p)\n", hdc, wine_dbgstr_rect(lprcBox), infoPtr->hBkBitmap);
+
+ SelectObject(hdc_src, infoPtr->hBkBitmap);
+ BitBlt(hdc, lprcBox->left, lprcBox->top, lprcBox->right - lprcBox->left,
+ lprcBox->bottom - lprcBox->top, hdc_src, lprcBox->left, lprcBox->top, SRCCOPY);
+
+ DeleteDC(hdc_src);
+ ret = TRUE;
+ }
- return FillRect(hdc, lprcBox, infoPtr->hBkBrush);
+ return ret;
}
/* Draw main item or subitem */
@@ -8028,7 +8048,48 @@ static BOOL LISTVIEW_SetBkColor(LISTVIEW_INFO *infoPtr, COLORREF color)
return TRUE;
}
-/* LISTVIEW_SetBkImage */
+static LRESULT LISTVIEW_SetBkImage(LISTVIEW_INFO *infoPtr, const LVBKIMAGEW *image, BOOL isW)
+{
+ TRACE("%08lx, %p, %p, %u, %d, %d\n", image->ulFlags, image->hbm, image->pszImage,
+ image->cchImageMax, image->xOffsetPercent, image->yOffsetPercent);
+
+ if (image->ulFlags & ~LVBKIF_SOURCE_MASK)
+ FIXME("not supported flags %08lx\n", image->ulFlags & ~LVBKIF_SOURCE_MASK);
+
+ if (image->xOffsetPercent || image->yOffsetPercent)
+ FIXME("not supported offset %d,%d\n", image->xOffsetPercent, image->yOffsetPercent);
+
+ switch (image->ulFlags & LVBKIF_SOURCE_MASK)
+ {
+ case LVBKIF_SOURCE_NONE:
+ if (infoPtr->hBkBitmap)
+ {
+ DeleteObject(infoPtr->hBkBitmap);
+ infoPtr->hBkBitmap = 0;
+ }
+ break;
+
+ case LVBKIF_SOURCE_HBITMAP:
+ {
+ BITMAP bm;
+
+ if (infoPtr->hBkBitmap)
+ {
+ DeleteObject(infoPtr->hBkBitmap);
+ infoPtr->hBkBitmap = 0;
+ }
+ if (GetObjectW(image->hbm, sizeof(bm), &bm) == sizeof(bm))
+ infoPtr->hBkBitmap = image->hbm;
+ break;
+ }
+
+ case LVBKIF_SOURCE_URL:
+ FIXME("LVBKIF_SOURCE_URL: %s\n", isW ? debugstr_w(image->pszImage) : debugstr_a((LPCSTR)image->pszImage));
+ break;
+ }
+
+ return 0;
+}
/*** Helper for {Insert,Set}ColumnT *only* */
static void column_fill_hditem(const LISTVIEW_INFO *infoPtr, HDITEMW *lphdi, INT nColumn,
@@ -10406,6 +10467,7 @@ static LRESULT LISTVIEW_NCDestroy(LISTVIEW_INFO *infoPtr)
infoPtr->hFont = 0;
if (infoPtr->hDefaultFont) DeleteObject(infoPtr->hDefaultFont);
if (infoPtr->clrBk != CLR_NONE) DeleteObject(infoPtr->hBkBrush);
+ if (infoPtr->hBkBitmap) DeleteObject(infoPtr->hBkBitmap);
SetWindowLongPtrW(infoPtr->hwndSelf, 0, 0);
@@ -11554,7 +11616,9 @@ LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case LVM_SETBKCOLOR:
return LISTVIEW_SetBkColor(infoPtr, (COLORREF)lParam);
- /* case LVM_SETBKIMAGE: */
+ case LVM_SETBKIMAGEA:
+ case LVM_SETBKIMAGEW:
+ return LISTVIEW_SetBkImage(infoPtr, (LVBKIMAGEW *)lParam, uMsg == LVM_SETBKIMAGEW);
case LVM_SETCALLBACKMASK:
infoPtr->uCallbackMask = (UINT)wParam;
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index 6ac7f53137d..420e557f2db 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <windows.h>
#include <commctrl.h>
+#include <objbase.h>
#include "wine/test.h"
#include "v6util.h"
@@ -6924,6 +6925,75 @@ static void test_LVM_GETNEXTITEMINDEX(void)
DestroyWindow(hwnd);
}
+static void test_LVM_SETBKIMAGE(void)
+{
+ HWND hwnd;
+ int ret;
+ HBITMAP hbmp;
+ BITMAP bm;
+ LVBKIMAGEA image;
+
+ CoInitialize(NULL);
+
+ hbmp = CreateBitmap(32, 32, 1, 1, NULL);
+ hwnd = create_listview_control(LVS_REPORT);
+
+ image.ulFlags = LVBKIF_SOURCE_NONE;
+ image.hbm = 0;
+ image.pszImage = NULL;
+ image.cchImageMax = 0;
+ image.xOffsetPercent = 0;
+ image.yOffsetPercent = 0;
+ ret = SendMessageA(hwnd, LVM_SETBKIMAGEA, 0, (LPARAM)&image);
+ ok(!ret, "got %d\n", ret);
+
+ ret = GetObjectA(hbmp, sizeof(bm), &bm);
+ ok(ret == sizeof(bm), "got %d\n", ret);
+
+ image.ulFlags = LVBKIF_SOURCE_HBITMAP;
+ image.hbm = hbmp;
+ ret = SendMessageA(hwnd, LVM_SETBKIMAGEA, 0, (LPARAM)&image);
+ ok(!ret, "got %d\n", ret);
+
+ ret = GetObjectA(hbmp, sizeof(bm), &bm);
+ ok(ret == sizeof(bm), "got %d\n", ret);
+
+ image.ulFlags = LVBKIF_SOURCE_NONE;
+ image.hbm = 0;
+ ret = SendMessageA(hwnd, LVM_SETBKIMAGEA, 0, (LPARAM)&image);
+ ok(!ret, "got %d\n", ret);
+
+ ret = GetObjectA(hbmp, sizeof(bm), &bm);
+ ok(!ret, "got %d\n", ret);
+
+ hbmp = CreateBitmap(32, 32, 1, 1, NULL);
+
+ image.ulFlags = LVBKIF_SOURCE_HBITMAP;
+ image.hbm = hbmp;
+ ret = SendMessageA(hwnd, LVM_SETBKIMAGEA, 0, (LPARAM)&image);
+ ok(!ret, "got %d\n", ret);
+
+ ret = GetObjectA(hbmp, sizeof(bm), &bm);
+ ok(ret == sizeof(bm), "got %d\n", ret);
+
+ image.ulFlags = LVBKIF_SOURCE_HBITMAP;
+ image.hbm = hbmp;
+ ret = SendMessageA(hwnd, LVM_SETBKIMAGEA, 0, (LPARAM)&image);
+ ok(!ret, "got %d\n", ret);
+
+ ret = GetObjectA(hbmp, sizeof(bm), &bm);
+ ok(!ret, "got %d\n", ret);
+
+ image.ulFlags = LVBKIF_SOURCE_NONE;
+ image.hbm = 0;
+ ret = SendMessageA(hwnd, LVM_SETBKIMAGEA, 0, (LPARAM)&image);
+ ok(!ret, "got %d\n", ret);
+
+ DestroyWindow(hwnd);
+
+ CoUninitialize();
+}
+
START_TEST(listview)
{
ULONG_PTR ctx_cookie;
@@ -6987,6 +7057,7 @@ START_TEST(listview)
test_LVN_ENDLABELEDIT();
test_LVM_GETCOUNTPERPAGE();
test_item_state_change();
+ test_LVM_SETBKIMAGE();
if (!load_v6_module(&ctx_cookie, &hCtx))
{
--
2.36.1
June 10, 2022
Re: [PATCH] comctl32: Add partial support for LVM_SETBKIMAGE.
by Dmitry Timoshkov
Zhiyi Zhang <zzhang(a)codeweavers.com> wrote:
> >> Also, I found LVM_SETBKIMAGE is acting a bit weird on Windows. For example,
> >> if a LVM_SETBKIMAGE message trying to set a bitmap
> >> is sent the second time. The second message returns FALSE and the background
> >> image gets reset to none(from LVM_GETBKIMAGE). I don't know if we should
> >> implement such a behavior but I would be more comfortable with some tests.
> > According to my testing LVM_SETBKIMAGE always returns 0.
>
> If LVM_SETBKIMAGE for a bitmap succeeds, it does return TRUE.
Where do you see this? In my tests LVM_SETBKIMAGE always returns 0:
https://testbot.winehq.org/JobDetails.pl?Key=116659
> > Regarding calling
> > LVM_SETBKIMAGE again with the same hbitmap I'd guess that the control first
> > destroys previosuly assigned bitmap, and that leads to a being assigned bitmap
> > gets destroyed. The conrol then probably verifies bitmap validity before saving
> > it internally, and that would explain why LVM_GETBKIMAGE returns 0.
> >
> Right, this make sense. It would be nice to add a test for this. MSDN doesn't mention that the bitmap
> will be managed by the control after the message.
I just added a test that calls LVM_SETBKIMAGE twice with the same bitmap,
and calls GetObject() to verify the bitmap validity after each call. Adding
the tests with LVM_GETBKIMAGE would required implementing it, and this deserves
a separate patch, probably with another set of tests.
--
Dmitry.
June 10, 2022
Re: [PATCH] comctl32: Add partial support for LVM_SETBKIMAGE.
by Zhiyi Zhang
On 6/10/22 16:42, Dmitry Timoshkov wrote:
> Zhiyi Zhang <zzhang(a)codeweavers.com> wrote:
>
> Thanks for the review.
>
>> Also, I found LVM_SETBKIMAGE is acting a bit weird on Windows. For example,
>> if a LVM_SETBKIMAGE message trying to set a bitmap
>> is sent the second time. The second message returns FALSE and the background
>> image gets reset to none(from LVM_GETBKIMAGE). I don't know if we should
>> implement such a behavior but I would be more comfortable with some tests.
> According to my testing LVM_SETBKIMAGE always returns 0.
If LVM_SETBKIMAGE for a bitmap succeeds, it does return TRUE.
> Regarding calling
> LVM_SETBKIMAGE again with the same hbitmap I'd guess that the control first
> destroys previosuly assigned bitmap, and that leads to a being assigned bitmap
> gets destroyed. The conrol then probably verifies bitmap validity before saving
> it internally, and that would explain why LVM_GETBKIMAGE returns 0.
>
Right, this make sense. It would be nice to add a test for this. MSDN doesn't mention that the bitmap
will be managed by the control after the message.
Thanks,
Zhiyi
June 10, 2022
[PATCH 6/6] dinput/tests: Merge keyboard.c tests into device8.c.
by Rémi Bernon
From: Rémi Bernon <rbernon(a)codeweavers.com>
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
dlls/dinput/tests/Makefile.in | 3 +-
dlls/dinput/tests/device8.c | 298 ++++++++++++++++++++++
dlls/dinput/tests/keyboard.c | 458 ----------------------------------
3 files changed, 299 insertions(+), 460 deletions(-)
delete mode 100644 dlls/dinput/tests/keyboard.c
diff --git a/dlls/dinput/tests/Makefile.in b/dlls/dinput/tests/Makefile.in
index 6ef155e5160..87522c12abf 100644
--- a/dlls/dinput/tests/Makefile.in
+++ b/dlls/dinput/tests/Makefile.in
@@ -21,5 +21,4 @@ SOURCES = \
hid.c \
hotplug.c \
joystick.c \
- joystick8.c \
- keyboard.c
+ joystick8.c
diff --git a/dlls/dinput/tests/device8.c b/dlls/dinput/tests/device8.c
index 7ad3f98af24..927bf18949a 100644
--- a/dlls/dinput/tests/device8.c
+++ b/dlls/dinput/tests/device8.c
@@ -122,6 +122,29 @@ static HRESULT create_dinput_device( DWORD version, const GUID *guid, IDirectInp
return DI_OK;
}
+static HKL activate_keyboard_layout( LANGID langid, HKL *old_hkl )
+{
+ WCHAR hkl_name[64];
+ HKL hkl;
+
+ swprintf( hkl_name, ARRAY_SIZE(hkl_name), L"%08x", langid );
+ hkl = LoadKeyboardLayoutW( hkl_name, 0 );
+ if (!hkl)
+ {
+ win_skip( "Unable to load keyboard layout %#x\n", langid );
+ *old_hkl = GetKeyboardLayout( 0 );
+ return 0;
+ }
+
+ *old_hkl = ActivateKeyboardLayout( hkl, 0 );
+ ok( !!*old_hkl, "ActivateKeyboardLayout failed, error %lu\n", GetLastError() );
+
+ hkl = GetKeyboardLayout( 0 );
+ todo_wine_if( LOWORD(*old_hkl) != langid )
+ ok( LOWORD(hkl) == langid, "GetKeyboardLayout returned %p\n", hkl );
+ return hkl;
+}
+
static HRESULT direct_input_create( DWORD version, IDirectInputA **out )
{
HRESULT hr;
@@ -2047,6 +2070,126 @@ static void test_sys_mouse( DWORD version )
localized = old_localized;
}
+static void test_dik_codes( IDirectInputDevice8W *device, HANDLE event, HWND hwnd )
+{
+ static const struct key2dik
+ {
+ BYTE key, dik, todo;
+ }
+ key2dik_en[] =
+ {
+ {'Q',DIK_Q}, {'W',DIK_W}, {'E',DIK_E}, {'R',DIK_R}, {'T',DIK_T}, {'Y',DIK_Y},
+ {'[',DIK_LBRACKET}, {']',DIK_RBRACKET}, {'.',DIK_PERIOD}
+ },
+ key2dik_fr[] =
+ {
+ {'A',DIK_Q}, {'Z',DIK_W}, {'E',DIK_E}, {'R',DIK_R}, {'T',DIK_T}, {'Y',DIK_Y},
+ {'^',DIK_LBRACKET}, {'$',DIK_RBRACKET}, {':',DIK_PERIOD}
+ },
+ key2dik_de[] =
+ {
+ {'Q',DIK_Q}, {'W',DIK_W}, {'E',DIK_E}, {'R',DIK_R}, {'T',DIK_T}, {'Z',DIK_Y},
+ {'\xfc',DIK_LBRACKET,1}, {'+',DIK_RBRACKET}, {'.',DIK_PERIOD}
+ },
+ key2dik_ja[] =
+ {
+ {'Q',DIK_Q}, {'W',DIK_W}, {'E',DIK_E}, {'R',DIK_R}, {'T',DIK_T}, {'Y',DIK_Y},
+ {'@',DIK_AT}, {']',DIK_RBRACKET}, {'.',DIK_PERIOD}
+ };
+ static const struct
+ {
+ LANGID langid;
+ const struct key2dik *map;
+ DWORD type;
+ } tests[] =
+ {
+ { MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), key2dik_en, DIDEVTYPEKEYBOARD_PCENH },
+ { MAKELANGID(LANG_FRENCH, SUBLANG_FRENCH), key2dik_fr, DIDEVTYPEKEYBOARD_PCENH },
+ { MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), key2dik_de, DIDEVTYPEKEYBOARD_PCENH },
+ { MAKELANGID(LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN), key2dik_ja, DIDEVTYPEKEYBOARD_JAPAN106 }
+ };
+ DIDEVCAPS caps = {.dwSize = sizeof(DIDEVCAPS)};
+ const struct key2dik *map;
+ BYTE key_state[256];
+ HKL hkl, old_hkl;
+ WORD vkey, scan;
+ HRESULT hr;
+ ULONG res;
+ UINT i, j;
+
+ hr = IDirectInputDevice_SetDataFormat( device, &c_dfDIKeyboard );
+ ok( hr == DI_OK, "SetDataFormat returned %#lx\n", hr );
+ hr = IDirectInputDevice_Acquire( device );
+ ok( hr == DI_OK, "Acquire returned %#lx\n", hr );
+ hr = IDirectInputDevice_GetCapabilities( device, &caps );
+ ok( hr == DI_OK, "GetDeviceInstance returned %#lx\n", hr );
+
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
+ {
+ if (tests[i].type != GET_DIDEVICE_SUBTYPE( caps.dwDevType ))
+ {
+ skip( "keyboard type %#x doesn't match for lang %#x\n",
+ GET_DIDEVICE_SUBTYPE( caps.dwDevType ), tests[i].langid );
+ continue;
+ }
+
+ winetest_push_context( "lang %#x", tests[i].langid );
+
+ hkl = activate_keyboard_layout( tests[i].langid, &old_hkl );
+ if (LOWORD(old_hkl) != MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT) ||
+ LOWORD(hkl) != tests[i].langid) goto skip_key_tests;
+
+ map = tests[i].map;
+ for (j = 0; j < ARRAY_SIZE(key2dik_en); j++)
+ {
+ winetest_push_context( "key %#x, dik %#x", map[j].key, map[j].dik );
+
+ vkey = VkKeyScanExW( map[j].key, hkl );
+ todo_wine_if( map[j].todo )
+ ok( vkey != 0xffff, "VkKeyScanExW failed\n" );
+
+ vkey = LOBYTE(vkey);
+ res = MapVirtualKeyExA( vkey, MAPVK_VK_TO_CHAR, hkl ) & 0xff;
+ todo_wine_if( map[j].todo )
+ ok( res == map[j].key, "MapVirtualKeyExA failed\n" );
+
+ scan = MapVirtualKeyExA( vkey, MAPVK_VK_TO_VSC, hkl );
+ todo_wine_if( map[j].todo )
+ ok( scan, "MapVirtualKeyExA failed\n" );
+
+ keybd_event( vkey, scan, 0, 0 );
+ res = WaitForSingleObject( event, 100 );
+ if (i == 0 && j == 0 && res == WAIT_TIMEOUT) /* Acquire is asynchronous */
+ {
+ keybd_event( vkey, scan, 0, 0 );
+ res = WaitForSingleObject( event, 100 );
+ }
+ ok( !res, "WaitForSingleObject returned %#lx\n", res );
+
+ hr = IDirectInputDevice_GetDeviceState( device, sizeof(key_state), key_state );
+ ok( hr == DI_OK, "GetDeviceState returned %#lx\n", hr );
+
+ todo_wine_if( map[j].todo )
+ ok( key_state[map[j].dik] == 0x80, "got state %#x\n", key_state[map[j].dik] );
+
+ keybd_event( vkey, scan, KEYEVENTF_KEYUP, 0 );
+ res = WaitForSingleObject( event, 100 );
+ ok( !res, "WaitForSingleObject returned %#lx\n", res );
+
+ winetest_pop_context();
+ }
+
+ skip_key_tests:
+ ActivateKeyboardLayout( old_hkl, 0 );
+ UnloadKeyboardLayout( hkl );
+
+ winetest_pop_context();
+ }
+
+ hr = IDirectInputDevice8_Unacquire( device );
+ ok( hr == DI_OK, "Unacquire returned %#lx\n", hr );
+}
+
static void test_sys_keyboard( DWORD version )
{
const DIDEVCAPS expect_caps =
@@ -2151,12 +2294,31 @@ static void test_sys_keyboard( DWORD version )
.dwHow = DIPH_DEVICE,
},
};
+
+ LONG key_state[6], zero_state[6] = {0};
+ DIOBJECTDATAFORMAT obj_data_format[] =
+ {
+ {&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 data_format =
+ {
+ sizeof(DIDATAFORMAT), sizeof(DIOBJECTDATAFORMAT), DIDF_RELAXIS,
+ sizeof(key_state), ARRAY_SIZE(obj_data_format), obj_data_format,
+ };
+
DIDEVICEOBJECTINSTANCEW objinst = {0};
DIDEVICEINSTANCEW devinst = {0};
BOOL old_localized = localized;
IDirectInputDevice8W *device;
DIDEVCAPS caps = {0};
+ BYTE full_state[256];
+ HKL hkl, old_hkl;
+ HWND hwnd, child;
ULONG res, ref;
+ HANDLE event;
HRESULT hr;
GUID guid;
@@ -2388,6 +2550,142 @@ static void test_sys_keyboard( DWORD version )
check_member( objinst, expect_objects[2], "%#04x", wExponent );
check_member( objinst, expect_objects[2], "%u", wReportId );
+
+ hwnd = CreateWindowW( L"static", L"static", WS_POPUP | WS_VISIBLE,
+ 50, 50, 200, 200, NULL, NULL, NULL, NULL );
+ ok( !!hwnd, "CreateWindowW failed, error %lu\n", GetLastError() );
+ flush_events();
+
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_FOREGROUND );
+ ok( hr == DIERR_INVALIDPARAM, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_FOREGROUND|DISCL_EXCLUSIVE );
+ ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_FOREGROUND|DISCL_NONEXCLUSIVE );
+ ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr );
+
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_BACKGROUND );
+ ok( hr == DIERR_INVALIDPARAM, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_BACKGROUND|DISCL_EXCLUSIVE );
+ ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_BACKGROUND|DISCL_NONEXCLUSIVE );
+ ok( hr == DI_OK, "SetCooperativeLevel returned %#lx\n", hr );
+
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_FOREGROUND );
+ ok( hr == DIERR_INVALIDPARAM, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_FOREGROUND|DISCL_EXCLUSIVE );
+ todo_wine_if( version == 0x500 )
+ ok( hr == (version == 0x500 ? DIERR_INVALIDPARAM : DI_OK), "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_FOREGROUND|DISCL_NONEXCLUSIVE );
+ ok( hr == DI_OK, "SetCooperativeLevel returned %#lx\n", hr );
+
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_BACKGROUND );
+ ok( hr == DIERR_INVALIDPARAM, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_BACKGROUND|DISCL_EXCLUSIVE );
+ todo_wine_if( version == 0x500 )
+ ok( hr == (version == 0x500 ? DIERR_INVALIDPARAM : DIERR_UNSUPPORTED), "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_BACKGROUND|DISCL_NONEXCLUSIVE );
+ ok( hr == DI_OK, "SetCooperativeLevel returned %#lx\n", hr );
+
+ child = CreateWindowW( L"static", L"static", WS_CHILD | WS_VISIBLE,
+ 10, 10, 50, 50, hwnd, NULL, NULL, NULL );
+ ok( !!child, "CreateWindowW failed, error %lu\n", GetLastError() );
+ flush_events();
+
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, child, DISCL_FOREGROUND );
+ ok( hr == DIERR_INVALIDPARAM, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, child, DISCL_FOREGROUND|DISCL_EXCLUSIVE );
+ ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, child, DISCL_FOREGROUND|DISCL_NONEXCLUSIVE );
+ ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr );
+
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, child, DISCL_BACKGROUND );
+ ok( hr == DIERR_INVALIDPARAM, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, child, DISCL_BACKGROUND|DISCL_EXCLUSIVE );
+ ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, child, DISCL_BACKGROUND|DISCL_NONEXCLUSIVE );
+ ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr );
+
+ DestroyWindow( child );
+
+ event = CreateEventW( NULL, FALSE, FALSE, NULL );
+ ok( !!event, "CreateEventW failed, error %lu\n", GetLastError() );
+
+ hkl = activate_keyboard_layout( MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), &old_hkl );
+ if (LOWORD(hkl) != MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT)) goto skip_key_tests;
+
+ hr = IDirectInputDevice8_SetEventNotification( device, event );
+ ok( hr == DI_OK, "SetEventNotification returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetDataFormat( device, &c_dfDIKeyboard );
+ ok( hr == DI_OK, "SetDataFormat returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND );
+ ok( hr == DI_OK, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_GetDeviceState( device, 10, full_state );
+ ok( hr == DIERR_NOTACQUIRED, "GetDeviceState returned %#lx\n", hr );
+ hr = IDirectInputDevice8_GetDeviceState( device, sizeof(full_state), full_state );
+ ok( hr == DIERR_NOTACQUIRED, "GetDeviceState returned %#lx\n", hr );
+ hr = IDirectInputDevice8_Unacquire( device );
+ ok( hr == DI_NOEFFECT, "Unacquire returned %#lx\n", hr );
+ hr = IDirectInputDevice8_Acquire( device );
+ ok( hr == DI_OK, "Acquire returned %#lx\n", hr );
+ hr = IDirectInputDevice8_Acquire( device );
+ ok( hr == DI_NOEFFECT, "Acquire returned %#lx\n", hr );
+ hr = IDirectInputDevice8_GetDeviceState( device, 10, full_state );
+ ok( hr == DIERR_INVALIDPARAM, "GetDeviceState returned %#lx\n", hr );
+ hr = IDirectInputDevice8_GetDeviceState( device, sizeof(full_state), full_state );
+ ok( hr == DI_OK, "GetDeviceState returned %#lx\n", hr );
+ hr = IDirectInputDevice8_Unacquire( device );
+ ok( hr == DI_OK, "Uncquire returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetDataFormat( device, &data_format );
+ ok( hr == DI_OK, "SetDataFormat returned %#lx\n", hr );
+ hr = IDirectInputDevice8_Acquire( device );
+ ok( hr == DI_OK, "Acquire returned %#lx\n", hr );
+ hr = IDirectInputDevice8_GetDeviceState( device, sizeof(key_state), key_state );
+ ok( hr == DI_OK, "GetDeviceState returned %#lx\n", hr );
+ hr = IDirectInputDevice8_GetDeviceState( device, sizeof(full_state), full_state );
+ ok( hr == DIERR_INVALIDPARAM, "GetDeviceState returned %#lx\n", hr );
+
+ memset( key_state, 0x56, sizeof(key_state) );
+ hr = IDirectInputDevice8_GetDeviceState( device, sizeof(key_state), key_state );
+ ok( hr == DI_OK, "GetDeviceState returned %#lx\n", hr );
+ ok( !memcmp( key_state, zero_state, sizeof(key_state) ), "got non zero state\n" );
+
+ keybd_event( 'Q', 0, 0, 0 );
+ res = WaitForSingleObject( event, 100 );
+ if (res == WAIT_TIMEOUT) /* Acquire is asynchronous */
+ {
+ keybd_event( 'Q', 0, 0, 0 );
+ res = WaitForSingleObject( event, 100 );
+ }
+ ok( !res, "WaitForSingleObject returned %#lx\n", res );
+
+ memset( key_state, 0xcd, sizeof(key_state) );
+ hr = IDirectInputDevice8_GetDeviceState( device, sizeof(key_state), key_state );
+ ok( hr == DI_OK, "GetDeviceState returned %#lx\n", hr );
+ ok( key_state[0] == (version < 0x800 ? 0x80 : 0), "got key_state[0] %lu\n", key_state[0] );
+
+ /* unacquiring should reset the device state */
+ hr = IDirectInputDevice8_Unacquire( device );
+ ok( hr == DI_OK, "Unacquire returned %#lx\n", hr );
+ hr = IDirectInputDevice8_Acquire( device );
+ ok( hr == DI_OK, "Acquire returned %#lx\n", hr );
+ hr = IDirectInputDevice8_GetDeviceState( device, sizeof(key_state), key_state );
+ ok( hr == DI_OK, "GetDeviceState returned %#lx\n", hr );
+ ok( !memcmp( key_state, zero_state, sizeof(key_state) ), "got non zero state\n" );
+
+ keybd_event( 'Q', 0, KEYEVENTF_KEYUP, 0 );
+
+ hr = IDirectInputDevice8_Unacquire( device );
+ ok( hr == DI_OK, "Unacquire returned %#lx\n", hr );
+
+skip_key_tests:
+ ActivateKeyboardLayout( old_hkl, 0 );
+ UnloadKeyboardLayout( hkl );
+
+ test_dik_codes( device, event, hwnd );
+
+ CloseHandle( event );
+ DestroyWindow( hwnd );
+
ref = IDirectInputDevice8_Release( device );
ok( ref == 0, "Release returned %ld\n", ref );
diff --git a/dlls/dinput/tests/keyboard.c b/dlls/dinput/tests/keyboard.c
deleted file mode 100644
index 2aa4fa86f98..00000000000
--- a/dlls/dinput/tests/keyboard.c
+++ /dev/null
@@ -1,458 +0,0 @@
-/*
- * Copyright (c) 2005 Robert Reif
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#define DIRECTINPUT_VERSION 0x0700
-
-#include <stdarg.h>
-#include <stddef.h>
-
-#include "ntstatus.h"
-#define WIN32_NO_STATUS
-#include "windef.h"
-#include "winbase.h"
-
-#define COBJMACROS
-#include "dinput.h"
-
-#include "dinput_test.h"
-
-static void pump_messages(void)
-{
- MSG msg;
-
- while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
- {
- TranslateMessage(&msg);
- DispatchMessageA(&msg);
- }
-}
-
-static HKL activate_keyboard_layout(LANGID langid, HKL *hkl_orig)
-{
- HKL hkl, hkl_current;
- char hkl_name[64];
-
- sprintf(hkl_name, "%#x", langid);
- trace("Loading keyboard layout %s\n", hkl_name);
- hkl = LoadKeyboardLayoutA(hkl_name, 0);
- if (!hkl)
- {
- win_skip("Unable to load keyboard layout %s\n", hkl_name);
- return 0;
- }
- *hkl_orig = ActivateKeyboardLayout(hkl, 0);
- ok(*hkl_orig != 0, "Unable to activate keyboard layout %s\n", hkl_name);
- if (!*hkl_orig) return 0;
-
- hkl_current = GetKeyboardLayout(0);
- if (LOWORD(hkl_current) != langid)
- {
- /* FIXME: Wine can't activate different keyboard layouts.
- * for testing purposes use this workaround:
- * setxkbmap us && LANG=en_US.UTF-8 make test
- * setxkbmap fr && LANG=fr_FR.UTF-8 make test
- * setxkbmap de && LANG=de_DE.UTF-8 make test
- */
- skip("current %#x != langid %#x\n", LOWORD(hkl_current), langid);
- return 0;
- }
-
- return hkl;
-}
-
-static void acquire_tests(IDirectInputA *pDI, HWND hwnd)
-{
- HRESULT hr;
- IDirectInputDeviceA *pKeyboard;
- BYTE kbd_state[256];
- LONG custom_state[6];
- int i;
- DIOBJECTDATAFORMAT dodf[] =
- {
- { &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;
- HKL hkl, hkl_orig;
- UINT prev_raw_devices_count, raw_devices_count;
-
- hkl = activate_keyboard_layout(MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), &hkl_orig);
- if (!hkl) return;
-
- df.dwSize = sizeof( df );
- df.dwObjSize = sizeof( DIOBJECTDATAFORMAT );
- df.dwFlags = DIDF_RELAXIS;
- df.dwDataSize = sizeof( custom_state );
- df.dwNumObjs = ARRAY_SIZE(dodf);
- df.rgodf = dodf;
-
- hr = IDirectInput_CreateDevice(pDI, &GUID_SysKeyboard, &pKeyboard, NULL);
- ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr);
- if (FAILED(hr)) return;
-
- hr = IDirectInputDevice_SetDataFormat(pKeyboard, &c_dfDIKeyboard);
- ok(SUCCEEDED(hr), "IDirectInputDevice_SetDataFormat() failed: %#lx\n", hr);
- hr = IDirectInputDevice_SetCooperativeLevel(pKeyboard, NULL, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND);
- ok(SUCCEEDED(hr), "IDirectInputDevice_SetCooperativeLevel() failed: %#lx\n", hr);
- hr = IDirectInputDevice_GetDeviceState(pKeyboard, 10, kbd_state);
- ok(hr == DIERR_NOTACQUIRED, "IDirectInputDevice_GetDeviceState(10,) should have failed: %#lx\n", hr);
- hr = IDirectInputDevice_GetDeviceState(pKeyboard, sizeof(kbd_state), kbd_state);
- ok(hr == DIERR_NOTACQUIRED, "IDirectInputDevice_GetDeviceState() should have failed: %#lx\n", hr);
- hr = IDirectInputDevice_Unacquire(pKeyboard);
- ok(hr == S_FALSE, "IDirectInputDevice_Unacquire() should have failed: %#lx\n", hr);
- hr = IDirectInputDevice_Acquire(pKeyboard);
- ok(SUCCEEDED(hr), "IDirectInputDevice_Acquire() failed: %#lx\n", hr);
- hr = IDirectInputDevice_Acquire(pKeyboard);
- ok(hr == S_FALSE, "IDirectInputDevice_Acquire() should have failed: %#lx\n", hr);
- hr = IDirectInputDevice_GetDeviceState(pKeyboard, 10, kbd_state);
- ok(hr == DIERR_INVALIDPARAM, "IDirectInputDevice_GetDeviceState(10,) should have failed: %#lx\n", hr);
- hr = IDirectInputDevice_GetDeviceState(pKeyboard, sizeof(kbd_state), kbd_state);
- ok(SUCCEEDED(hr), "IDirectInputDevice_GetDeviceState() failed: %#lx\n", hr);
- hr = IDirectInputDevice_Unacquire(pKeyboard);
- ok(SUCCEEDED(hr), "IDirectInputDevice_Uncquire() failed: %#lx\n", hr);
- hr = IDirectInputDevice_SetDataFormat( pKeyboard , &df );
- ok(SUCCEEDED(hr), "IDirectInputDevice_SetDataFormat() failed: %#lx\n", hr);
- hr = IDirectInputDevice_Acquire(pKeyboard);
- ok(SUCCEEDED(hr), "IDirectInputDevice_Acquire() failed: %#lx\n", hr);
- hr = IDirectInputDevice_GetDeviceState(pKeyboard, sizeof(custom_state), custom_state);
- ok(SUCCEEDED(hr), "IDirectInputDevice_GetDeviceState(4,) failed: %#lx\n", hr);
- hr = IDirectInputDevice_GetDeviceState(pKeyboard, sizeof(kbd_state), kbd_state);
- ok(hr == DIERR_INVALIDPARAM, "IDirectInputDevice_GetDeviceState(256,) should have failed: %#lx\n", hr);
-
- memset(custom_state, 0x56, sizeof(custom_state));
- IDirectInputDevice_GetDeviceState(pKeyboard, sizeof(custom_state), custom_state);
- for (i = 0; i < ARRAY_SIZE(custom_state); i++)
- ok(custom_state[i] == 0, "Should be zeroed, got 0x%#lx\n", custom_state[i]);
-
- /* simulate some keyboard input */
- SetFocus(hwnd);
- pump_messages();
-
- keybd_event('Q', 0, 0, 0);
- hr = IDirectInputDevice_GetDeviceState(pKeyboard, sizeof(custom_state), custom_state);
- ok(SUCCEEDED(hr), "IDirectInputDevice_GetDeviceState() failed: %#lx\n", hr);
- if (!custom_state[0])
- win_skip("Keyboard event not processed, skipping test\n");
- else
- {
- /* unacquiring should reset the device state */
- hr = IDirectInputDevice_Unacquire(pKeyboard);
- ok(SUCCEEDED(hr), "IDirectInputDevice_Unacquire() failed: %#lx\n", hr);
- hr = IDirectInputDevice_Acquire(pKeyboard);
- ok(SUCCEEDED(hr), "IDirectInputDevice_Acquire() failed: %#lx\n", hr);
- hr = IDirectInputDevice_GetDeviceState(pKeyboard, sizeof(custom_state), custom_state);
- ok(SUCCEEDED(hr), "IDirectInputDevice_GetDeviceState failed: %#lx\n", hr);
- for (i = 0; i < ARRAY_SIZE(custom_state); i++)
- ok(custom_state[i] == 0, "Should be zeroed, got 0x%#lx\n", custom_state[i]);
- }
- keybd_event('Q', 0, KEYEVENTF_KEYUP, 0);
-
- prev_raw_devices_count = 0;
- GetRegisteredRawInputDevices(NULL, &prev_raw_devices_count, sizeof(RAWINPUTDEVICE));
- ok(prev_raw_devices_count == 0 || broken(prev_raw_devices_count == 1) /* wxppro, w2003std */,
- "Unexpected raw devices registered: %d\n", prev_raw_devices_count);
-
- hr = IDirectInputDevice_Acquire(pKeyboard);
- ok(SUCCEEDED(hr), "IDirectInputDevice_Acquire() failed: %#lx\n", hr);
-
- raw_devices_count = 0;
- GetRegisteredRawInputDevices(NULL, &raw_devices_count, sizeof(RAWINPUTDEVICE));
- ok(raw_devices_count == prev_raw_devices_count,
- "Unexpected raw devices registered: %d\n", raw_devices_count);
-
- hr = IDirectInputDevice_Unacquire(pKeyboard);
- ok(SUCCEEDED(hr), "IDirectInputDevice_Unacquire() failed: %#lx\n", hr);
-
- IUnknown_Release(pKeyboard);
-
- ActivateKeyboardLayout(hkl_orig, 0);
- UnloadKeyboardLayout(hkl);
-}
-
-static const HRESULT SetCoop_null_window[16] = {
- E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG,
- E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG,
- E_INVALIDARG, E_HANDLE, S_OK, E_INVALIDARG,
- E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG};
-
-static const HRESULT SetCoop_invalid_window[16] = {
- E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG,
- E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG,
- E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG,
- E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG};
-
-static const HRESULT SetCoop_real_window[16] = {
- E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG,
- E_INVALIDARG, S_OK, S_OK, E_INVALIDARG,
- E_INVALIDARG, E_NOTIMPL, S_OK, E_INVALIDARG,
- E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG};
-
-static const HRESULT SetCoop_child_window[16] = {
- E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG,
- E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG,
- E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG,
- E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG};
-
-static void test_set_coop(IDirectInputA *pDI, HWND hwnd)
-{
- HRESULT hr;
- IDirectInputDeviceA *pKeyboard = NULL;
- int i;
- HWND child;
-
- hr = IDirectInput_CreateDevice(pDI, &GUID_SysKeyboard, &pKeyboard, NULL);
- ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr);
- if (FAILED(hr)) return;
-
- for (i=0; i<16; i++)
- {
- hr = IDirectInputDevice_SetCooperativeLevel(pKeyboard, NULL, i);
- ok(hr == SetCoop_null_window[i], "SetCooperativeLevel(NULL, %d): %#lx\n", i, hr);
- }
- for (i=0; i<16; i++)
- {
- hr = IDirectInputDevice_SetCooperativeLevel(pKeyboard, (HWND)0x400000, i);
- ok(hr == SetCoop_invalid_window[i], "SetCooperativeLevel(invalid, %d): %#lx\n", i, hr);
- }
- for (i=0; i<16; i++)
- {
- hr = IDirectInputDevice_SetCooperativeLevel(pKeyboard, hwnd, i);
- ok(hr == SetCoop_real_window[i], "SetCooperativeLevel(hwnd, %d): %#lx\n", i, hr);
- }
-
- child = CreateWindowA("static", "Title", WS_CHILD | WS_VISIBLE, 10, 10, 50, 50, hwnd, NULL,
- NULL, NULL);
- ok(child != NULL, "err: %lu\n", GetLastError());
-
- for (i=0; i<16; i++)
- {
- hr = IDirectInputDevice_SetCooperativeLevel(pKeyboard, child, i);
- ok(hr == SetCoop_child_window[i], "SetCooperativeLevel(child, %d): %#lx\n", i, hr);
- }
-
- DestroyWindow(child);
- if (pKeyboard) IUnknown_Release(pKeyboard);
-}
-
-static void test_dik_codes(IDirectInputA *dI, HWND hwnd, LANGID langid)
-{
- static const struct key2dik
- {
- BYTE key, dik, todo;
- } key2dik_en[] =
- {
- {'Q',DIK_Q}, {'W',DIK_W}, {'E',DIK_E}, {'R',DIK_R}, {'T',DIK_T}, {'Y',DIK_Y},
- {'[',DIK_LBRACKET}, {']',DIK_RBRACKET}, {'.',DIK_PERIOD}
- },
- key2dik_fr[] =
- {
- {'A',DIK_Q}, {'Z',DIK_W}, {'E',DIK_E}, {'R',DIK_R}, {'T',DIK_T}, {'Y',DIK_Y},
- {'^',DIK_LBRACKET}, {'$',DIK_RBRACKET}, {':',DIK_PERIOD}
- },
- key2dik_de[] =
- {
- {'Q',DIK_Q}, {'W',DIK_W}, {'E',DIK_E}, {'R',DIK_R}, {'T',DIK_T}, {'Z',DIK_Y},
- {'\xfc',DIK_LBRACKET,1}, {'+',DIK_RBRACKET}, {'.',DIK_PERIOD}
- },
- key2dik_ja[] =
- {
- {'Q',DIK_Q}, {'W',DIK_W}, {'E',DIK_E}, {'R',DIK_R}, {'T',DIK_T}, {'Y',DIK_Y},
- {'@',DIK_AT}, {']',DIK_RBRACKET}, {'.',DIK_PERIOD}
- };
- static const struct
- {
- LANGID langid;
- const struct key2dik *map;
- DWORD type;
- } expected[] =
- {
- { MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
- key2dik_en, DIDEVTYPEKEYBOARD_PCENH },
- { MAKELANGID(LANG_FRENCH, SUBLANG_FRENCH),
- key2dik_fr, DIDEVTYPEKEYBOARD_PCENH },
- { MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN),
- key2dik_de, DIDEVTYPEKEYBOARD_PCENH },
- { MAKELANGID(LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN),
- key2dik_ja, DIDEVTYPEKEYBOARD_JAPAN106 }
- };
- const struct key2dik *map = NULL;
- UINT i;
- HRESULT hr;
- IDirectInputDeviceA *device;
- DIDEVCAPS caps;
- HKL hkl, hkl_orig;
- MSG msg;
-
- for (i = 0; i < ARRAY_SIZE(expected); i++)
- {
- if (expected[i].langid == langid)
- {
- map = expected[i].map;
- break;
- }
- }
- ok(map != NULL, "can't find mapping for langid %04x\n", langid);
- if (!map) return;
-
- hr = IDirectInput_CreateDevice(dI, &GUID_SysKeyboard, &device, NULL);
- ok(hr == S_OK, "CreateDevice() failed: %#lx\n", hr);
- hr = IDirectInputDevice_SetDataFormat(device, &c_dfDIKeyboard);
- ok(hr == S_OK, "SetDataFormat() failed: %#lx\n", hr);
- hr = IDirectInputDevice_Acquire(device);
- ok(hr == S_OK, "Acquire() failed: %#lx\n", hr);
- caps.dwSize = sizeof( caps );
- hr = IDirectInputDevice_GetCapabilities(device, &caps);
- ok(hr == S_OK, "GetDeviceInstance() failed: %#lx\n", hr);
- if (expected[i].type != GET_DIDEVICE_SUBTYPE(caps.dwDevType)) {
- skip("Keyboard type(%u) doesn't match for lang %04x\n",
- GET_DIDEVICE_SUBTYPE(caps.dwDevType), langid);
- goto fail;
- }
-
- hkl = activate_keyboard_layout(langid, &hkl_orig);
- if (!hkl) goto fail;
-
- SetFocus(hwnd);
- pump_messages();
-
- for (i = 0; i < ARRAY_SIZE(key2dik_en); i++)
- {
- BYTE kbd_state[256];
- UINT n;
- WORD vkey, scan;
- INPUT in;
-
- n = VkKeyScanExW(map[i].key, hkl);
- todo_wine_if(map[i].todo & 1)
- ok(n != 0xffff, "%u: failed to get virtual key value for %c(%02x)\n", i, map[i].key, map[i].key);
- vkey = LOBYTE(n);
- n = MapVirtualKeyExA(vkey, MAPVK_VK_TO_CHAR, hkl) & 0xff;
- todo_wine_if(map[i].todo & 1)
- ok(n == map[i].key, "%u: expected %c(%02x), got %c(%02x)\n", i, map[i].key, map[i].key, n, n);
- scan = MapVirtualKeyExA(vkey, MAPVK_VK_TO_VSC, hkl);
- /* scan codes match the DIK_ codes on US keyboard.
- however, it isn't true for symbols and punctuations in other layouts. */
- if (isalpha(map[i].key) || langid == MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT))
- ok(scan == map[i].dik, "%u: expected %02x, got %02x\n", i, map[i].dik, n);
- else
- todo_wine_if(map[i].todo & 1)
- ok(scan, "%u: fail to get scan code value, expected %02x (vkey=%02x)\n",
- i, map[i].dik, vkey);
-
- in.type = INPUT_KEYBOARD;
- U(in).ki.wVk = vkey;
- U(in).ki.wScan = scan;
- U(in).ki.dwFlags = 0;
- U(in).ki.dwExtraInfo = 0;
- U(in).ki.time = 0;
- n = SendInput(1, &in, sizeof(in));
- ok(n == 1, "got %u\n", n);
-
- if (!PeekMessageA(&msg, hwnd, 0, 0, PM_REMOVE))
- {
- U(in).ki.dwFlags = KEYEVENTF_KEYUP;
- SendInput(1, &in, sizeof(in));
- win_skip("failed to queue keyboard event\n");
- break;
- }
- ok(msg.message == WM_KEYDOWN, "expected WM_KEYDOWN, got %04x\n", msg.message);
- DispatchMessageA(&msg);
-
- n = MapVirtualKeyExA(msg.wParam, MAPVK_VK_TO_CHAR, hkl);
- trace("keydown wParam: %#Ix (%c) lParam: %#Ix, MapVirtualKey(MAPVK_VK_TO_CHAR) = %c\n",
- msg.wParam, isprint(LOWORD(msg.wParam)) ? LOWORD(msg.wParam) : '?',
- msg.lParam, isprint(n) ? n : '?');
-
- pump_messages();
-
- hr = IDirectInputDevice_GetDeviceState(device, sizeof(kbd_state), kbd_state);
- ok(hr == S_OK, "GetDeviceState() failed: %#lx\n", hr);
-
- /* this never happens on real hardware but tesbot VMs seem to have timing issues */
- if (i == 0 && kbd_state[map[0].dik] != 0x80)
- {
- win_skip("dinput failed to handle keyboard event\n");
- break;
- }
-
- todo_wine_if(map[i].todo)
- ok(kbd_state[map[i].dik] == 0x80, "DI key %#x has state %#x\n", map[i].dik, kbd_state[map[i].dik]);
-
- U(in).ki.dwFlags = KEYEVENTF_KEYUP;
- n = SendInput(1, &in, sizeof(in));
- ok(n == 1, "got %u\n", n);
-
- pump_messages();
- }
-
- ActivateKeyboardLayout(hkl_orig, 0);
- UnloadKeyboardLayout(hkl);
-fail:
- IDirectInputDevice_Unacquire(device);
- IUnknown_Release(device);
-}
-
-static void keyboard_tests(DWORD version)
-{
- HRESULT hr;
- IDirectInputA *pDI = NULL;
- HWND hwnd;
- ULONG ref = 0;
-
- hr = DirectInputCreateA(instance, version, &pDI, NULL);
- if (hr == DIERR_OLDDIRECTINPUTVERSION)
- {
- skip("Tests require a newer dinput version\n");
- return;
- }
- ok(SUCCEEDED(hr), "DirectInputCreateA() failed: %#lx\n", hr);
- if (FAILED(hr)) return;
-
- hwnd = CreateWindowA("static", "Title", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 10, 10, 200, 200,
- NULL, NULL, NULL, NULL);
- ok(hwnd != NULL, "err: %lu\n", GetLastError());
- SetForegroundWindow( hwnd );
-
- if (hwnd)
- {
- pump_messages();
-
- acquire_tests(pDI, hwnd);
- test_set_coop(pDI, hwnd);
-
- test_dik_codes(pDI, hwnd, MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT));
- test_dik_codes(pDI, hwnd, MAKELANGID(LANG_FRENCH, SUBLANG_FRENCH));
- test_dik_codes(pDI, hwnd, MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN));
- test_dik_codes(pDI, hwnd, MAKELANGID(LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN));
- }
-
- DestroyWindow(hwnd);
- if (pDI) ref = IUnknown_Release(pDI);
- ok(!ref, "IDirectInput_Release() reference count = %ld\n", ref);
-}
-
-START_TEST(keyboard)
-{
- dinput_test_init();
-
- keyboard_tests(0x0700);
-
- dinput_test_exit();
-}
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/223
June 10, 2022
[PATCH 5/6] dinput/tests: Run keyboard info tests for every dinput version.
by Rémi Bernon
From: Rémi Bernon <rbernon(a)codeweavers.com>
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
dlls/dinput/tests/device8.c | 51 ++++++++++++------
dlls/dinput/tests/keyboard.c | 101 -----------------------------------
2 files changed, 34 insertions(+), 118 deletions(-)
diff --git a/dlls/dinput/tests/device8.c b/dlls/dinput/tests/device8.c
index 08fccd00551..7ad3f98af24 100644
--- a/dlls/dinput/tests/device8.c
+++ b/dlls/dinput/tests/device8.c
@@ -2047,13 +2047,14 @@ static void test_sys_mouse( DWORD version )
localized = old_localized;
}
-static void test_keyboard_info(void)
+static void test_sys_keyboard( DWORD version )
{
- static const DIDEVCAPS expect_caps =
+ const DIDEVCAPS expect_caps =
{
.dwSize = sizeof(DIDEVCAPS),
.dwFlags = DIDC_ATTACHED | DIDC_EMULATED,
- .dwDevType = (DI8DEVTYPEKEYBOARD_PCENH << 8) | DI8DEVTYPE_KEYBOARD,
+ .dwDevType = version < 0x800 ? (DIDEVTYPEKEYBOARD_PCENH << 8) | DIDEVTYPE_KEYBOARD
+ : (DI8DEVTYPEKEYBOARD_PCENH << 8) | DI8DEVTYPE_KEYBOARD,
.dwButtons = 128,
};
const DIDEVICEINSTANCEW expect_devinst =
@@ -2061,7 +2062,8 @@ static void test_keyboard_info(void)
.dwSize = sizeof(DIDEVICEINSTANCEW),
.guidInstance = GUID_SysKeyboard,
.guidProduct = GUID_SysKeyboard,
- .dwDevType = (DI8DEVTYPEKEYBOARD_PCENH << 8) | DI8DEVTYPE_KEYBOARD,
+ .dwDevType = version < 0x800 ? (DIDEVTYPEKEYBOARD_PCENH << 8) | DIDEVTYPE_KEYBOARD
+ : (DI8DEVTYPEKEYBOARD_PCENH << 8) | DI8DEVTYPE_KEYBOARD,
.tszInstanceName = L"Keyboard",
.tszProductName = L"Keyboard",
.guidFFDriver = GUID_NULL,
@@ -2151,21 +2153,19 @@ static void test_keyboard_info(void)
};
DIDEVICEOBJECTINSTANCEW objinst = {0};
DIDEVICEINSTANCEW devinst = {0};
+ BOOL old_localized = localized;
IDirectInputDevice8W *device;
DIDEVCAPS caps = {0};
- IDirectInput8W *di;
ULONG res, ref;
HRESULT hr;
GUID guid;
- localized = TRUE; /* Skip name tests, Wine sometimes succeeds depending on the host key names */
+ if (FAILED(create_dinput_device( version, &GUID_SysKeyboard, &device ))) return;
- hr = DirectInput8Create( instance, DIRECTINPUT_VERSION, &IID_IDirectInput8W, (void **)&di, NULL );
- ok( hr == DI_OK, "DirectInput8Create returned %#lx\n", hr );
- hr = IDirectInput8_CreateDevice( di, &GUID_SysKeyboard, &device, NULL );
- ok( hr == DI_OK, "CreateDevice returned %#lx\n", hr );
+ localized = TRUE; /* Skip name tests, Wine sometimes succeeds depending on the host key names */
+ winetest_push_context( "%#lx", version );
- hr = IDirectInputDevice8_Initialize( device, instance, DIRECTINPUT_VERSION, &GUID_SysKeyboardEm );
+ hr = IDirectInputDevice8_Initialize( device, instance, version, &GUID_SysKeyboardEm );
ok( hr == DI_OK, "Initialize returned %#lx\n", hr );
guid = GUID_SysKeyboardEm;
memset( &devinst, 0, sizeof(devinst) );
@@ -2175,7 +2175,7 @@ static void test_keyboard_info(void)
ok( IsEqualGUID( &guid, &GUID_SysKeyboardEm ), "got %s expected %s\n", debugstr_guid( &guid ),
debugstr_guid( &GUID_SysKeyboardEm ) );
- hr = IDirectInputDevice8_Initialize( device, instance, DIRECTINPUT_VERSION, &GUID_SysKeyboard );
+ hr = IDirectInputDevice8_Initialize( device, instance, version, &GUID_SysKeyboard );
ok( hr == DI_OK, "Initialize returned %#lx\n", hr );
memset( &devinst, 0, sizeof(devinst) );
@@ -2192,6 +2192,15 @@ static void test_keyboard_info(void)
check_member( devinst, expect_devinst, "%04x", wUsagePage );
check_member( devinst, expect_devinst, "%04x", wUsage );
+ devinst.dwSize = sizeof(DIDEVICEINSTANCE_DX3W);
+ hr = IDirectInputDevice8_GetDeviceInfo( device, &devinst );
+ ok( hr == DI_OK, "GetDeviceInfo returned %#lx\n", hr );
+ check_member_guid( devinst, expect_devinst, guidInstance );
+ check_member_guid( devinst, expect_devinst, guidProduct );
+ check_member( devinst, expect_devinst, "%#lx", dwDevType );
+ if (!localized) check_member_wstr( devinst, expect_devinst, tszInstanceName );
+ if (!localized) todo_wine check_member_wstr( devinst, expect_devinst, tszProductName );
+
caps.dwSize = sizeof(DIDEVCAPS);
hr = IDirectInputDevice8_GetCapabilities( device, &caps );
ok( hr == DI_OK, "GetCapabilities returned %#lx\n", hr );
@@ -2270,8 +2279,13 @@ static void test_keyboard_info(void)
hr = IDirectInputDevice8_GetProperty( device, DIPROP_TYPENAME, &prop_string.diph );
ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_TYPENAME returned %#lx\n", hr );
hr = IDirectInputDevice8_GetProperty( device, DIPROP_USERNAME, &prop_string.diph );
- ok( hr == S_FALSE, "GetProperty DIPROP_USERNAME returned %#lx\n", hr );
- ok( !wcscmp( prop_string.wsz, L"" ), "got user %s\n", debugstr_w(prop_string.wsz) );
+ if (version < 0x0800)
+ ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_USERNAME returned %#lx\n", hr );
+ else
+ {
+ ok( hr == DI_NOEFFECT, "GetProperty DIPROP_USERNAME returned %#lx\n", hr );
+ ok( !wcscmp( prop_string.wsz, L"" ), "got user %s\n", debugstr_w(prop_string.wsz) );
+ }
hr = IDirectInputDevice8_GetProperty( device, DIPROP_JOYSTICKID, &prop_dword.diph );
ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_VIDPID returned %#lx\n", hr );
@@ -2377,8 +2391,8 @@ static void test_keyboard_info(void)
ref = IDirectInputDevice8_Release( device );
ok( ref == 0, "Release returned %ld\n", ref );
- ref = IDirectInput8_Release( di );
- ok( ref == 0, "Release returned %ld\n", ref );
+ winetest_pop_context();
+ localized = old_localized;
}
START_TEST(device8)
@@ -2397,7 +2411,10 @@ START_TEST(device8)
test_sys_mouse( 0x700 );
test_sys_mouse( 0x800 );
- test_keyboard_info();
+ test_sys_keyboard( 0x500 );
+ test_sys_keyboard( 0x700 );
+ test_sys_keyboard( 0x800 );
+
test_action_mapping();
test_save_settings();
test_mouse_keyboard();
diff --git a/dlls/dinput/tests/keyboard.c b/dlls/dinput/tests/keyboard.c
index 0d3cf7b10c2..2aa4fa86f98 100644
--- a/dlls/dinput/tests/keyboard.c
+++ b/dlls/dinput/tests/keyboard.c
@@ -251,75 +251,6 @@ static void test_set_coop(IDirectInputA *pDI, HWND hwnd)
if (pKeyboard) IUnknown_Release(pKeyboard);
}
-static void test_get_prop(IDirectInputA *pDI, HWND hwnd)
-{
- HRESULT hr;
- IDirectInputDeviceA *pKeyboard = NULL;
- DIPROPRANGE diprg;
- DIPROPDWORD vidpid;
-
- hr = IDirectInput_CreateDevice(pDI, &GUID_SysKeyboard, &pKeyboard, NULL);
- ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr);
- if (FAILED(hr)) return;
-
- memset(&diprg, 0, sizeof(diprg));
- diprg.diph.dwSize = sizeof(DIPROPRANGE);
- diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
- diprg.diph.dwHow = DIPH_DEVICE;
- diprg.diph.dwObj = 0;
-
- hr = IDirectInputDevice_GetProperty(pKeyboard, DIPROP_RANGE, &diprg.diph);
- ok(hr == DIERR_UNSUPPORTED, "IDirectInputDevice_GetProperty() did not return DIPROP_RANGE but: %#lx\n", hr);
-
- memset(&vidpid, 0, sizeof(vidpid));
- vidpid.diph.dwSize = sizeof(DIPROPDWORD);
- vidpid.diph.dwHeaderSize = sizeof(DIPROPHEADER);
- vidpid.diph.dwHow = DIPH_DEVICE;
- vidpid.diph.dwObj = 0;
-
- hr = IDirectInputDevice_GetProperty(pKeyboard, DIPROP_VIDPID, &vidpid.diph);
- ok(hr == DIERR_UNSUPPORTED, "got %#lx\n", hr);
-
- IUnknown_Release(pKeyboard);
-}
-
-static void test_capabilities(IDirectInputA *pDI, HWND hwnd)
-{
- HRESULT hr;
- IDirectInputDeviceA *pKeyboard = NULL;
- DIDEVCAPS caps;
- int kbd_type, kbd_subtype, dev_subtype;
-
- hr = IDirectInput_CreateDevice(pDI, &GUID_SysKeyboard, &pKeyboard, NULL);
- ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr);
- if (FAILED(hr)) return;
-
- caps.dwSize = sizeof(caps);
- hr = IDirectInputDevice_GetCapabilities(pKeyboard, &caps);
-
- ok (SUCCEEDED(hr), "GetCapabilities failed: 0x%#lx\n", hr);
- ok (caps.dwFlags & DIDC_ATTACHED, "GetCapabilities dwFlags: 0x%#lx\n", caps.dwFlags);
- ok (GET_DIDEVICE_TYPE(caps.dwDevType) == DIDEVTYPE_KEYBOARD,
- "GetCapabilities invalid device type for dwDevType: 0x%#lx\n", caps.dwDevType);
- kbd_type = GetKeyboardType(0);
- kbd_subtype = GetKeyboardType(1);
- dev_subtype = GET_DIDEVICE_SUBTYPE(caps.dwDevType);
- if (kbd_type == 4 || (kbd_type == 7 && kbd_subtype == 0))
- ok (dev_subtype == DIDEVTYPEKEYBOARD_PCENH,
- "GetCapabilities invalid device subtype for dwDevType: 0x%#lx (%04x:%04x)\n",
- caps.dwDevType, kbd_type, kbd_subtype);
- else if (kbd_type == 7 && kbd_subtype == 2)
- ok (dev_subtype == DIDEVTYPEKEYBOARD_JAPAN106,
- "GetCapabilities invalid device subtype for dwDevType: 0x%#lx (%04x:%04x)\n",
- caps.dwDevType, kbd_type, kbd_subtype);
- else
- ok (dev_subtype != DIDEVTYPEKEYBOARD_UNKNOWN,
- "GetCapabilities invalid device subtype for dwDevType: 0x%#lx (%04x:%04x)\n",
- caps.dwDevType, kbd_type, kbd_subtype);
-
- IUnknown_Release(pKeyboard);
-}
-
static void test_dik_codes(IDirectInputA *dI, HWND hwnd, LANGID langid)
{
static const struct key2dik
@@ -478,35 +409,6 @@ fail:
IUnknown_Release(device);
}
-static void test_GetDeviceInfo(IDirectInputA *pDI)
-{
- HRESULT hr;
- IDirectInputDeviceA *pKey = NULL;
- DIDEVICEINSTANCEA instA;
- DIDEVICEINSTANCE_DX3A inst3A;
-
- hr = IDirectInput_CreateDevice(pDI, &GUID_SysKeyboard, &pKey, NULL);
- ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr);
- if (FAILED(hr)) return;
-
- instA.dwSize = sizeof(instA);
- hr = IDirectInputDevice_GetDeviceInfo(pKey, &instA);
- ok(SUCCEEDED(hr), "got %#lx\n", hr);
-
- inst3A.dwSize = sizeof(inst3A);
- hr = IDirectInputDevice_GetDeviceInfo(pKey, (DIDEVICEINSTANCEA *)&inst3A);
- ok(SUCCEEDED(hr), "got %#lx\n", hr);
-
- ok(instA.dwSize != inst3A.dwSize, "got %ld, %ld\n", instA.dwSize, inst3A.dwSize);
- ok(IsEqualGUID(&instA.guidInstance, &inst3A.guidInstance), "got %s, %s\n",
- wine_dbgstr_guid(&instA.guidInstance), wine_dbgstr_guid(&inst3A.guidInstance) );
- ok(IsEqualGUID(&instA.guidProduct, &inst3A.guidProduct), "got %s, %s\n",
- wine_dbgstr_guid(&instA.guidProduct), wine_dbgstr_guid(&inst3A.guidProduct) );
- ok(instA.dwDevType == inst3A.dwDevType, "got %ld, %ld\n", instA.dwDevType, inst3A.dwDevType);
-
- IUnknown_Release(pKey);
-}
-
static void keyboard_tests(DWORD version)
{
HRESULT hr;
@@ -534,9 +436,6 @@ static void keyboard_tests(DWORD version)
acquire_tests(pDI, hwnd);
test_set_coop(pDI, hwnd);
- test_get_prop(pDI, hwnd);
- test_capabilities(pDI, hwnd);
- test_GetDeviceInfo(pDI);
test_dik_codes(pDI, hwnd, MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT));
test_dik_codes(pDI, hwnd, MAKELANGID(LANG_FRENCH, SUBLANG_FRENCH));
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/223
June 10, 2022
[PATCH 4/6] dinput/tests: Merge mouse.c tests into device8.c.
by Rémi Bernon
From: Rémi Bernon <rbernon(a)codeweavers.com>
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
dlls/dinput/tests/Makefile.in | 3 +-
dlls/dinput/tests/device8.c | 182 +++++++++++++++++++++++++
dlls/dinput/tests/mouse.c | 242 ----------------------------------
3 files changed, 183 insertions(+), 244 deletions(-)
delete mode 100644 dlls/dinput/tests/mouse.c
diff --git a/dlls/dinput/tests/Makefile.in b/dlls/dinput/tests/Makefile.in
index 1556f3cda37..6ef155e5160 100644
--- a/dlls/dinput/tests/Makefile.in
+++ b/dlls/dinput/tests/Makefile.in
@@ -22,5 +22,4 @@ SOURCES = \
hotplug.c \
joystick.c \
joystick8.c \
- keyboard.c \
- mouse.c
+ keyboard.c
diff --git a/dlls/dinput/tests/device8.c b/dlls/dinput/tests/device8.c
index bf9d16cbc05..08fccd00551 100644
--- a/dlls/dinput/tests/device8.c
+++ b/dlls/dinput/tests/device8.c
@@ -1604,13 +1604,19 @@ static void test_sys_mouse( DWORD version )
},
};
DIDEVICEOBJECTINSTANCEW objinst = {0};
+ DIDEVICEOBJECTDATA objdata = {0};
DIDEVICEINSTANCEW devinst = {0};
BOOL old_localized = localized;
IDirectInputDevice8W *device;
+ HWND hwnd, tmp_hwnd, child;
DIDEVCAPS caps = {0};
+ DIMOUSESTATE state;
ULONG res, ref;
+ HANDLE event;
+ DWORD count;
HRESULT hr;
GUID guid;
+ int i;
if (FAILED(create_dinput_device( version, &GUID_SysMouse, &device ))) return;
@@ -1858,6 +1864,182 @@ static void test_sys_mouse( DWORD version )
check_member( objinst, expect_objects[3], "%#04x", wExponent );
check_member( objinst, expect_objects[3], "%u", wReportId );
+
+ SetCursorPos( 60, 60 );
+
+ hwnd = CreateWindowW( L"static", L"static", WS_POPUP | WS_VISIBLE,
+ 50, 50, 200, 200, NULL, NULL, NULL, NULL );
+ ok( !!hwnd, "CreateWindowW failed, error %lu\n", GetLastError() );
+ flush_events();
+
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_FOREGROUND );
+ ok( hr == DIERR_INVALIDPARAM, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_FOREGROUND|DISCL_EXCLUSIVE );
+ ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_FOREGROUND|DISCL_NONEXCLUSIVE );
+ ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr );
+
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_BACKGROUND );
+ ok( hr == DIERR_INVALIDPARAM, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_BACKGROUND|DISCL_EXCLUSIVE );
+ ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_BACKGROUND|DISCL_NONEXCLUSIVE );
+ ok( hr == DI_OK, "SetCooperativeLevel returned %#lx\n", hr );
+
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_FOREGROUND );
+ ok( hr == DIERR_INVALIDPARAM, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_FOREGROUND|DISCL_EXCLUSIVE );
+ ok( hr == DI_OK, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_FOREGROUND|DISCL_NONEXCLUSIVE );
+ ok( hr == DI_OK, "SetCooperativeLevel returned %#lx\n", hr );
+
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_BACKGROUND );
+ ok( hr == DIERR_INVALIDPARAM, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_BACKGROUND|DISCL_EXCLUSIVE );
+ ok( hr == DIERR_UNSUPPORTED, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_BACKGROUND|DISCL_NONEXCLUSIVE );
+ ok( hr == DI_OK, "SetCooperativeLevel returned %#lx\n", hr );
+
+ child = CreateWindowW( L"static", L"static", WS_CHILD | WS_VISIBLE,
+ 10, 10, 50, 50, hwnd, NULL, NULL, NULL );
+ ok( !!child, "CreateWindowW failed, error %lu\n", GetLastError() );
+ flush_events();
+
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, child, DISCL_FOREGROUND );
+ ok( hr == DIERR_INVALIDPARAM, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, child, DISCL_FOREGROUND|DISCL_EXCLUSIVE );
+ ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, child, DISCL_FOREGROUND|DISCL_NONEXCLUSIVE );
+ ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr );
+
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, child, DISCL_BACKGROUND );
+ ok( hr == DIERR_INVALIDPARAM, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, child, DISCL_BACKGROUND|DISCL_EXCLUSIVE );
+ ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, child, DISCL_BACKGROUND|DISCL_NONEXCLUSIVE );
+ ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr );
+
+ DestroyWindow( child );
+
+
+ event = CreateEventW( NULL, FALSE, FALSE, NULL );
+ ok( !!event, "CreateEventW failed, error %lu\n", GetLastError() );
+ hr = IDirectInputDevice8_SetEventNotification( device, event );
+ ok( hr == DI_OK, "SetEventNotification returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND );
+ ok( hr == DI_OK, "SetCooperativeLevel returned %#lx\n", hr );
+
+ prop_dword.dwData = 5;
+ prop_dword.diph.dwHow = DIPH_DEVICE;
+ prop_dword.diph.dwObj = 0;
+ hr = IDirectInputDevice8_SetProperty( device, DIPROP_BUFFERSIZE, (LPCDIPROPHEADER)&prop_dword );
+ ok( hr == DI_OK, "SetProperty returned %#lx\n", hr );
+ hr = IDirectInputDevice8_SetDataFormat( device, &c_dfDIMouse );
+ ok( hr == DI_OK, "SetDataFormat returned %#lx\n", hr );
+ hr = IDirectInputDevice8_Unacquire( device );
+ ok( hr == DI_NOEFFECT, "Unacquire returned %#lx\n", hr );
+ hr = IDirectInputDevice8_Acquire( device );
+ ok( hr == DI_OK, "Acquire returned %#lx\n", hr );
+ hr = IDirectInputDevice8_Acquire( device );
+ ok( hr == DI_NOEFFECT, "Acquire returned %#lx\n", hr );
+
+
+ tmp_hwnd = CreateWindowW( L"static", L"static", WS_POPUP | WS_VISIBLE,
+ 50, 250, 200, 200, NULL, NULL, NULL, NULL );
+ ok( !!tmp_hwnd, "CreateWindowW failed, error %lu\n", GetLastError() );
+ flush_events();
+
+ hr = IDirectInputDevice8_GetDeviceState( device, sizeof(state), &state );
+ ok( hr == DIERR_NOTACQUIRED, "GetDeviceState returned %#lx\n", hr );
+
+ hr = IDirectInputDevice8_Acquire( device );
+ ok( hr == DIERR_OTHERAPPHASPRIO, "Acquire returned %#lx\n", hr );
+
+ SetActiveWindow( hwnd );
+ flush_events();
+
+ hr = IDirectInputDevice8_SetProperty( device, DIPROP_BUFFERSIZE, (LPCDIPROPHEADER)&prop_dword );
+ ok( hr == DI_OK, "SetProperty returned %#lx\n", hr );
+
+ hr = IDirectInputDevice8_Acquire( device );
+ ok( hr == DI_OK, "Acquire returned %#lx\n", hr );
+
+ mouse_event( MOUSEEVENTF_MOVE, 10, 10, 0, 0 );
+ res = WaitForSingleObject( event, 100 );
+ if (res == WAIT_TIMEOUT) /* Acquire is asynchronous */
+ {
+ mouse_event( MOUSEEVENTF_MOVE, 10, 10, 0, 0 );
+ res = WaitForSingleObject( event, 100 );
+ }
+ ok( !res, "WaitForSingleObject returned %#lx\n", res );
+
+ count = 1;
+ hr = IDirectInputDevice8_GetDeviceData( device, sizeof(objdata), &objdata, &count, 0 );
+ ok( hr == DI_OK, "GetDeviceData returned %#lx\n", hr );
+ ok( count == 1, "got count %lu\n", count );
+
+ mouse_event( MOUSEEVENTF_MOVE, 10, 10, 0, 0 );
+ res = WaitForSingleObject( event, 100 );
+ ok( !res, "WaitForSingleObject returned %#lx\n", res );
+
+ hr = IDirectInputDevice8_Unacquire( device );
+ ok( hr == DI_OK, "Unacquire returned %#lx\n", hr );
+ count = 1;
+ hr = IDirectInputDevice8_GetDeviceData( device, sizeof(objdata), &objdata, &count, 0 );
+ ok( hr == (version < 0x800 ? DI_OK : DIERR_NOTACQUIRED), "GetDeviceData returned %#lx\n", hr );
+ ok( count == 1, "got count %lu\n", count );
+
+ hr = IDirectInputDevice8_Acquire( device );
+ ok( hr == DI_OK, "Acquire returned %#lx\n", hr );
+
+ mouse_event( MOUSEEVENTF_MOVE, 10, 10, 0, 0 );
+ res = WaitForSingleObject( event, 100 );
+ if (res == WAIT_TIMEOUT) /* Acquire is asynchronous */
+ {
+ mouse_event( MOUSEEVENTF_MOVE, 10, 10, 0, 0 );
+ res = WaitForSingleObject( event, 100 );
+ }
+ ok( !res, "WaitForSingleObject returned %#lx\n", res );
+
+ hr = IDirectInputDevice8_Unacquire( device );
+ ok( hr == DI_OK, "Unacquire returned %#lx\n", hr );
+
+ hr = IDirectInputDevice8_Acquire( device );
+ ok( hr == DI_OK, "Acquire returned %#lx\n", hr );
+ count = 1;
+ hr = IDirectInputDevice8_GetDeviceData( device, sizeof(objdata), &objdata, &count, 0 );
+ ok( hr == (version < 0x800 ? DI_OK : DI_BUFFEROVERFLOW), "GetDeviceData returned %#lx\n", hr );
+ ok( count == 1, "got count %lu\n", count );
+
+ mouse_event( MOUSEEVENTF_MOVE, 10, 10, 0, 0 );
+ res = WaitForSingleObject( event, 100 );
+ if (res == WAIT_TIMEOUT) /* Acquire is asynchronous */
+ {
+ mouse_event( MOUSEEVENTF_MOVE, 10, 10, 0, 0 );
+ res = WaitForSingleObject( event, 100 );
+ }
+ ok( !res, "WaitForSingleObject returned %#lx\n", res );
+
+ for (i = 0; i < 2; i++)
+ {
+ mouse_event( MOUSEEVENTF_MOVE, 10 + i, 10 + i, 0, 0 );
+ res = WaitForSingleObject( event, 100 );
+ ok( !res, "WaitForSingleObject returned %#lx\n", res );
+ }
+
+ count = 1;
+ hr = IDirectInputDevice8_GetDeviceData( device, sizeof(objdata), &objdata, &count, 0 );
+ ok( hr == (version < 0x800 ? DI_OK : DI_BUFFEROVERFLOW), "GetDeviceData returned %#lx\n", hr );
+ count = 1;
+ hr = IDirectInputDevice8_GetDeviceData( device, sizeof(objdata), &objdata, &count, 0 );
+ ok( hr == DI_OK, "GetDeviceData returned %#lx\n", hr );
+ ok( count == 1, "got count %lu\n", count );
+
+ DestroyWindow( tmp_hwnd );
+
+ CloseHandle( event );
+ DestroyWindow( hwnd );
+
ref = IDirectInputDevice8_Release( device );
ok( ref == 0, "Release returned %ld\n", ref );
diff --git a/dlls/dinput/tests/mouse.c b/dlls/dinput/tests/mouse.c
deleted file mode 100644
index 2079c5e1408..00000000000
--- a/dlls/dinput/tests/mouse.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (c) 2005 Robert Reif
- * Copyright (c) 2006 Vitaliy Margolen
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#define DIRECTINPUT_VERSION 0x0700
-
-#include <stdarg.h>
-#include <stddef.h>
-
-#include "ntstatus.h"
-#define WIN32_NO_STATUS
-#include "windef.h"
-#include "winbase.h"
-
-#define COBJMACROS
-#include "dinput.h"
-
-#include "dinput_test.h"
-
-static const HRESULT SetCoop_null_window[16] = {
- E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG,
- E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG,
- E_INVALIDARG, E_HANDLE, S_OK, E_INVALIDARG,
- E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG};
-
-static const HRESULT SetCoop_real_window[16] = {
- E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG,
- E_INVALIDARG, S_OK, S_OK, E_INVALIDARG,
- E_INVALIDARG, E_NOTIMPL, S_OK, E_INVALIDARG,
- E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG};
-
-static const HRESULT SetCoop_child_window[16] = {
- E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG,
- E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG,
- E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG,
- E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG};
-
-static void flush_events(void)
-{
- MSG msg;
- int diff = 200;
- int min_timeout = 100;
- DWORD time = GetTickCount() + diff;
-
- while (diff > 0)
- {
- if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
- while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
- diff = time - GetTickCount();
- }
-}
-
-static void test_set_coop(IDirectInputA *pDI, HWND hwnd)
-{
- HRESULT hr;
- IDirectInputDeviceA *pMouse = NULL;
- int i;
- HWND child;
-
- hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, &pMouse, NULL);
- ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr);
- if (FAILED(hr)) return;
-
- for (i=0; i<16; i++)
- {
- hr = IDirectInputDevice_SetCooperativeLevel(pMouse, NULL, i);
- ok(hr == SetCoop_null_window[i], "SetCooperativeLevel(NULL, %d): %#lx\n", i, hr);
- }
- for (i=0; i<16; i++)
- {
- hr = IDirectInputDevice_SetCooperativeLevel(pMouse, hwnd, i);
- ok(hr == SetCoop_real_window[i], "SetCooperativeLevel(hwnd, %d): %#lx\n", i, hr);
- }
-
- child = CreateWindowA("static", "Title", WS_CHILD | WS_VISIBLE, 10, 10, 50, 50, hwnd, NULL,
- NULL, NULL);
- ok(child != NULL, "err: %lu\n", GetLastError());
-
- for (i=0; i<16; i++)
- {
- hr = IDirectInputDevice_SetCooperativeLevel(pMouse, child, i);
- ok(hr == SetCoop_child_window[i], "SetCooperativeLevel(child, %d): %#lx\n", i, hr);
- }
-
- DestroyWindow(child);
- if (pMouse) IUnknown_Release(pMouse);
-}
-
-static void test_acquire(IDirectInputA *pDI, HWND hwnd)
-{
- HRESULT hr;
- IDirectInputDeviceA *pMouse = NULL;
- DIMOUSESTATE m_state;
- HWND hwnd2;
- DIPROPDWORD di_op;
- DIDEVICEOBJECTDATA mouse_state;
- DWORD cnt;
- int i;
-
- if (! SetForegroundWindow(hwnd))
- {
- skip("Not running as foreground app, skipping acquire tests\n");
- return;
- }
-
- hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, &pMouse, NULL);
- ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr);
- if (FAILED(hr)) return;
-
- hr = IDirectInputDevice_SetCooperativeLevel(pMouse, hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND);
- ok(hr == S_OK, "SetCooperativeLevel: %#lx\n", hr);
-
- memset(&di_op, 0, sizeof(di_op));
- di_op.dwData = 5;
- di_op.diph.dwHow = DIPH_DEVICE;
- di_op.diph.dwSize = sizeof(DIPROPDWORD);
- di_op.diph.dwHeaderSize = sizeof(DIPROPHEADER);
- hr = IDirectInputDevice_SetProperty(pMouse, DIPROP_BUFFERSIZE, (LPCDIPROPHEADER)&di_op);
- ok(hr == S_OK, "SetProperty() failed: %#lx\n", hr);
-
- hr = IDirectInputDevice_SetDataFormat(pMouse, &c_dfDIMouse);
- ok(SUCCEEDED(hr), "IDirectInputDevice_SetDataFormat() failed: %#lx\n", hr);
- hr = IDirectInputDevice_Unacquire(pMouse);
- ok(hr == S_FALSE, "IDirectInputDevice_Unacquire() should have failed: %#lx\n", hr);
- hr = IDirectInputDevice_Acquire(pMouse);
- ok(SUCCEEDED(hr), "IDirectInputDevice_Acquire() failed: %#lx\n", hr);
- hr = IDirectInputDevice_Acquire(pMouse);
- ok(hr == S_FALSE, "IDirectInputDevice_Acquire() should have failed: %#lx\n", hr);
-
- /* Foreground coop level requires window to have focus */
- /* Create a temporary window, this should make dinput
- * lose mouse input */
- hwnd2 = CreateWindowA("static", "Temporary", WS_VISIBLE, 10, 210, 200, 200, NULL, NULL, NULL,
- NULL);
- ok(hwnd2 != NULL, "CreateWindowA failed with %lu\n", GetLastError());
- flush_events();
-
- hr = IDirectInputDevice_GetDeviceState(pMouse, sizeof(m_state), &m_state);
- ok(hr == DIERR_NOTACQUIRED, "GetDeviceState() should have failed: %#lx\n", hr);
-
- hr = IDirectInputDevice_Acquire(pMouse);
- ok(hr == DIERR_OTHERAPPHASPRIO, "Acquire() should have failed: %#lx\n", hr);
-
- SetActiveWindow( hwnd );
- hr = IDirectInputDevice_Acquire(pMouse);
- ok(hr == S_OK, "Acquire() failed: %#lx\n", hr);
-
- mouse_event(MOUSEEVENTF_MOVE, 10, 10, 0, 0);
- cnt = 1;
- hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0);
- ok(hr == S_OK && cnt > 0, "GetDeviceData() failed: %#lx cnt:%lu\n", hr, cnt);
-
- mouse_event(MOUSEEVENTF_MOVE, 10, 10, 0, 0);
- hr = IDirectInputDevice_Unacquire(pMouse);
- ok(hr == S_OK, "Failed: %#lx\n", hr);
- cnt = 1;
- hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0);
- ok(hr == S_OK && cnt > 0, "GetDeviceData() failed: %#lx cnt:%lu\n", hr, cnt);
-
- hr = IDirectInputDevice_Acquire(pMouse);
- ok(hr == S_OK, "Failed: %#lx\n", hr);
- mouse_event(MOUSEEVENTF_MOVE, 10, 10, 0, 0);
- hr = IDirectInputDevice_Unacquire(pMouse);
- ok(hr == S_OK, "Failed: %#lx\n", hr);
-
- hr = IDirectInputDevice_Acquire(pMouse);
- ok(hr == S_OK, "Failed: %#lx\n", hr);
- cnt = 1;
- hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0);
- ok(hr == S_OK && cnt > 0, "GetDeviceData() failed: %#lx cnt:%lu\n", hr, cnt);
-
- /* Check for buffer overflow */
- for (i = 0; i < 6; i++)
- mouse_event(MOUSEEVENTF_MOVE, 10 + i, 10 + i, 0, 0);
-
- cnt = 1;
- hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0);
- ok(hr == DI_OK, "GetDeviceData() failed: %#lx cnt:%lu\n", hr, cnt);
- cnt = 1;
- hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0);
- ok(hr == DI_OK && cnt == 1, "GetDeviceData() failed: %#lx cnt:%lu\n", hr, cnt);
-
- IUnknown_Release(pMouse);
-
- DestroyWindow( hwnd2 );
-}
-
-static void mouse_tests(void)
-{
- HRESULT hr;
- IDirectInputA *pDI = NULL;
- HWND hwnd;
- ULONG ref = 0;
-
- hr = DirectInputCreateA(instance, DIRECTINPUT_VERSION, &pDI, NULL);
- if (hr == DIERR_OLDDIRECTINPUTVERSION)
- {
- skip("Tests require a newer dinput version\n");
- return;
- }
- ok(SUCCEEDED(hr), "DirectInputCreateA() failed: %#lx\n", hr);
- if (FAILED(hr)) return;
-
- hwnd = CreateWindowA("static", "Title", WS_OVERLAPPEDWINDOW, 10, 10, 200, 200, NULL, NULL,
- NULL, NULL);
- ok(hwnd != NULL, "err: %lu\n", GetLastError());
- if (hwnd)
- {
- ShowWindow(hwnd, SW_SHOW);
-
- test_set_coop(pDI, hwnd);
- test_acquire(pDI, hwnd);
-
- DestroyWindow(hwnd);
- }
- if (pDI) ref = IUnknown_Release(pDI);
- ok(!ref, "IDirectInput_Release() reference count = %lu\n", ref);
-}
-
-START_TEST(mouse)
-{
- dinput_test_init();
-
- mouse_tests();
-
- dinput_test_exit();
-}
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/223
June 10, 2022
[PATCH 3/6] dinput/tests: Run mouse info tests for every dinput version.
by Rémi Bernon
From: Rémi Bernon <rbernon(a)codeweavers.com>
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
dlls/dinput/tests/device8.c | 82 ++++++++++++++++++++++++++-------
dlls/dinput/tests/mouse.c | 90 -------------------------------------
2 files changed, 65 insertions(+), 107 deletions(-)
diff --git a/dlls/dinput/tests/device8.c b/dlls/dinput/tests/device8.c
index a5c647713f2..bf9d16cbc05 100644
--- a/dlls/dinput/tests/device8.c
+++ b/dlls/dinput/tests/device8.c
@@ -98,6 +98,30 @@ static void flush_events(void)
}
}
+static HRESULT create_dinput_device( DWORD version, const GUID *guid, IDirectInputDevice8W **device )
+{
+ IDirectInputW *dinput;
+ HRESULT hr;
+ ULONG ref;
+
+ if (version < 0x800) hr = DirectInputCreateW( instance, version, &dinput, NULL );
+ else hr = DirectInput8Create( instance, version, &IID_IDirectInput8W, (void **)&dinput, NULL );
+ if (FAILED(hr))
+ {
+ win_skip( "Failed to instantiate a IDirectInput instance, hr %#lx\n", hr );
+ return hr;
+ }
+
+ hr = IDirectInput_CreateDevice( dinput, guid, (IDirectInputDeviceW **)device, NULL );
+ ok( hr == DI_OK, "CreateDevice returned %#lx\n", hr );
+
+ ref = IDirectInput_Release( dinput );
+ todo_wine
+ ok( ref == 0, "Release returned %ld\n", ref );
+
+ return DI_OK;
+}
+
static HRESULT direct_input_create( DWORD version, IDirectInputA **out )
{
HRESULT hr;
@@ -1451,13 +1475,14 @@ static BOOL CALLBACK check_object_count( const DIDEVICEOBJECTINSTANCEW *obj, voi
return DIENUM_CONTINUE;
}
-static void test_mouse_info(void)
+static void test_sys_mouse( DWORD version )
{
- static const DIDEVCAPS expect_caps =
+ const DIDEVCAPS expect_caps =
{
.dwSize = sizeof(DIDEVCAPS),
.dwFlags = DIDC_ATTACHED | DIDC_EMULATED,
- .dwDevType = (DI8DEVTYPEMOUSE_UNKNOWN << 8) | DI8DEVTYPE_MOUSE,
+ .dwDevType = version < 0x800 ? (DIDEVTYPEMOUSE_UNKNOWN << 8) | DIDEVTYPE_MOUSE
+ : (DI8DEVTYPEMOUSE_UNKNOWN << 8) | DI8DEVTYPE_MOUSE,
.dwAxes = 3,
.dwButtons = 5,
};
@@ -1466,7 +1491,8 @@ static void test_mouse_info(void)
.dwSize = sizeof(DIDEVICEINSTANCEW),
.guidInstance = GUID_SysMouse,
.guidProduct = GUID_SysMouse,
- .dwDevType = (DI8DEVTYPEMOUSE_UNKNOWN << 8) | DI8DEVTYPE_MOUSE,
+ .dwDevType = version < 0x800 ? (DIDEVTYPEMOUSE_UNKNOWN << 8) | DIDEVTYPE_MOUSE
+ : (DI8DEVTYPEMOUSE_UNKNOWN << 8) | DI8DEVTYPE_MOUSE,
.tszInstanceName = L"Mouse",
.tszProductName = L"Mouse",
.guidFFDriver = GUID_NULL,
@@ -1579,21 +1605,19 @@ static void test_mouse_info(void)
};
DIDEVICEOBJECTINSTANCEW objinst = {0};
DIDEVICEINSTANCEW devinst = {0};
+ BOOL old_localized = localized;
IDirectInputDevice8W *device;
DIDEVCAPS caps = {0};
- IDirectInput8W *di;
ULONG res, ref;
HRESULT hr;
GUID guid;
- localized = LOWORD( GetKeyboardLayout( 0 ) ) != 0x0409;
+ if (FAILED(create_dinput_device( version, &GUID_SysMouse, &device ))) return;
- hr = DirectInput8Create( instance, DIRECTINPUT_VERSION, &IID_IDirectInput8W, (void **)&di, NULL );
- ok( hr == DI_OK, "DirectInput8Create returned %#lx\n", hr );
- hr = IDirectInput8_CreateDevice( di, &GUID_SysMouse, &device, NULL );
- ok( hr == DI_OK, "CreateDevice returned %#lx\n", hr );
+ localized = LOWORD( GetKeyboardLayout( 0 ) ) != 0x0409;
+ winetest_push_context( "%#lx", version );
- hr = IDirectInputDevice8_Initialize( device, instance, DIRECTINPUT_VERSION, &GUID_SysMouseEm );
+ hr = IDirectInputDevice8_Initialize( device, instance, version, &GUID_SysMouseEm );
ok( hr == DI_OK, "Initialize returned %#lx\n", hr );
guid = GUID_SysMouseEm;
memset( &devinst, 0, sizeof(devinst) );
@@ -1603,7 +1627,7 @@ static void test_mouse_info(void)
ok( IsEqualGUID( &guid, &GUID_SysMouseEm ), "got %s expected %s\n", debugstr_guid( &guid ),
debugstr_guid( &GUID_SysMouseEm ) );
- hr = IDirectInputDevice8_Initialize( device, instance, DIRECTINPUT_VERSION, &GUID_SysMouse );
+ hr = IDirectInputDevice8_Initialize( device, instance, version, &GUID_SysMouse );
ok( hr == DI_OK, "Initialize returned %#lx\n", hr );
memset( &devinst, 0, sizeof(devinst) );
@@ -1621,6 +1645,16 @@ static void test_mouse_info(void)
check_member( devinst, expect_devinst, "%04x", wUsagePage );
check_member( devinst, expect_devinst, "%04x", wUsage );
+ devinst.dwSize = sizeof(DIDEVICEINSTANCE_DX3W);
+ hr = IDirectInputDevice8_GetDeviceInfo( device, &devinst );
+ ok( hr == DI_OK, "GetDeviceInfo returned %#lx\n", hr );
+ check_member_guid( devinst, expect_devinst, guidInstance );
+ check_member_guid( devinst, expect_devinst, guidProduct );
+ todo_wine
+ check_member( devinst, expect_devinst, "%#lx", dwDevType );
+ if (!localized) check_member_wstr( devinst, expect_devinst, tszInstanceName );
+ if (!localized) todo_wine check_member_wstr( devinst, expect_devinst, tszProductName );
+
caps.dwSize = sizeof(DIDEVCAPS);
hr = IDirectInputDevice8_GetCapabilities( device, &caps );
ok( hr == DI_OK, "GetCapabilities returned %#lx\n", hr );
@@ -1695,8 +1729,13 @@ static void test_mouse_info(void)
hr = IDirectInputDevice8_GetProperty( device, DIPROP_TYPENAME, &prop_string.diph );
ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_TYPENAME returned %#lx\n", hr );
hr = IDirectInputDevice8_GetProperty( device, DIPROP_USERNAME, &prop_string.diph );
- ok( hr == S_FALSE, "GetProperty DIPROP_USERNAME returned %#lx\n", hr );
- ok( !wcscmp( prop_string.wsz, L"" ), "got user %s\n", debugstr_w(prop_string.wsz) );
+ if (version < 0x0800)
+ ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_USERNAME returned %#lx\n", hr );
+ else
+ {
+ ok( hr == DI_NOEFFECT, "GetProperty DIPROP_USERNAME returned %#lx\n", hr );
+ ok( !wcscmp( prop_string.wsz, L"" ), "got user %s\n", debugstr_w(prop_string.wsz) );
+ }
hr = IDirectInputDevice8_GetProperty( device, DIPROP_JOYSTICKID, &prop_dword.diph );
ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_VIDPID returned %#lx\n", hr );
@@ -1717,6 +1756,12 @@ static void test_mouse_info(void)
hr = IDirectInputDevice8_GetProperty( device, DIPROP_GRANULARITY, &prop_dword.diph );
ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_GRANULARITY returned %#lx\n", hr );
+ prop_dword.diph.dwHow = DIPH_BYID;
+ prop_dword.diph.dwObj = DIDFT_MAKEINSTANCE(1) | DIDFT_RELAXIS;
+ prop_dword.dwData = 0xdeadbeef;
+ hr = IDirectInputDevice8_GetProperty( device, DIPROP_GRANULARITY, &prop_dword.diph );
+ ok( hr == DI_OK, "GetProperty DIPROP_GRANULARITY returned %#lx\n", hr );
+ ok( prop_dword.dwData == 1, "got %ld expected 1\n", prop_dword.dwData );
prop_dword.diph.dwHow = DIPH_BYOFFSET;
prop_dword.diph.dwObj = DIMOFS_X;
prop_dword.dwData = 0xdeadbeef;
@@ -1816,8 +1861,8 @@ static void test_mouse_info(void)
ref = IDirectInputDevice8_Release( device );
ok( ref == 0, "Release returned %ld\n", ref );
- ref = IDirectInput8_Release( di );
- ok( ref == 0, "Release returned %ld\n", ref );
+ winetest_pop_context();
+ localized = old_localized;
}
static void test_keyboard_info(void)
@@ -2166,7 +2211,10 @@ START_TEST(device8)
test_overlapped_format( 0x700 );
test_overlapped_format( 0x800 );
- test_mouse_info();
+ test_sys_mouse( 0x500 );
+ test_sys_mouse( 0x700 );
+ test_sys_mouse( 0x800 );
+
test_keyboard_info();
test_action_mapping();
test_save_settings();
diff --git a/dlls/dinput/tests/mouse.c b/dlls/dinput/tests/mouse.c
index 2d92fe2b14c..2079c5e1408 100644
--- a/dlls/dinput/tests/mouse.c
+++ b/dlls/dinput/tests/mouse.c
@@ -195,99 +195,11 @@ static void test_acquire(IDirectInputA *pDI, HWND hwnd)
hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0);
ok(hr == DI_OK && cnt == 1, "GetDeviceData() failed: %#lx cnt:%lu\n", hr, cnt);
- /* Check for granularity property using BYOFFSET */
- memset(&di_op, 0, sizeof(di_op));
- di_op.diph.dwHow = DIPH_BYOFFSET;
- di_op.diph.dwObj = DIMOFS_Y;
- di_op.diph.dwSize = sizeof(DIPROPDWORD);
- di_op.diph.dwHeaderSize = sizeof(DIPROPHEADER);
- hr = IDirectInputDevice_GetProperty(pMouse, DIPROP_GRANULARITY, &di_op.diph);
- /* Granularity of Y axis should be 1! */
- ok(hr == S_OK && di_op.dwData == 1, "GetProperty(): %#lx, dwData: %lu but should be 1.\n", hr, di_op.dwData);
-
- /* Check for granularity property using BYID */
- memset(&di_op, 0, sizeof(di_op));
- di_op.diph.dwHow = DIPH_BYID;
- /* WINE_MOUSE_Y_AXIS_INSTANCE := 1 */
- di_op.diph.dwObj = (DIDFT_MAKEINSTANCE(1) | DIDFT_RELAXIS);
- di_op.diph.dwSize = sizeof(DIPROPDWORD);
- di_op.diph.dwHeaderSize = sizeof(DIPROPHEADER);
- hr = IDirectInputDevice_GetProperty(pMouse, DIPROP_GRANULARITY, &di_op.diph);
- /* Granularity of Y axis should be 1! */
- ok(hr == S_OK && di_op.dwData == 1, "GetProperty(): %#lx, dwData: %lu but should be 1.\n", hr, di_op.dwData);
-
- memset(&di_op, 0, sizeof(di_op));
- di_op.diph.dwSize = sizeof(DIPROPDWORD);
- di_op.diph.dwHeaderSize = sizeof(DIPROPHEADER);
- di_op.diph.dwHow = DIPH_DEVICE;
- di_op.diph.dwObj = 0;
- hr = IDirectInputDevice_GetProperty(pMouse, DIPROP_VIDPID, &di_op.diph);
- ok(hr == DIERR_UNSUPPORTED, "got %#lx\n", hr);
-
IUnknown_Release(pMouse);
DestroyWindow( hwnd2 );
}
-static void test_GetDeviceInfo(IDirectInputA *pDI)
-{
- HRESULT hr;
- IDirectInputDeviceA *pMouse = NULL;
- DIDEVICEINSTANCEA instA;
- DIDEVICEINSTANCE_DX3A inst3A;
-
- hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, &pMouse, NULL);
- ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr);
- if (FAILED(hr)) return;
-
- instA.dwSize = sizeof(instA);
- hr = IDirectInputDevice_GetDeviceInfo(pMouse, &instA);
- ok(SUCCEEDED(hr), "got %#lx\n", hr);
-
- inst3A.dwSize = sizeof(inst3A);
- hr = IDirectInputDevice_GetDeviceInfo(pMouse, (DIDEVICEINSTANCEA *)&inst3A);
- ok(SUCCEEDED(hr), "got %#lx\n", hr);
-
- ok(instA.dwSize != inst3A.dwSize, "got %lu, %lu\n", instA.dwSize, inst3A.dwSize);
- ok(IsEqualGUID(&instA.guidInstance, &inst3A.guidInstance), "got %s, %s\n",
- wine_dbgstr_guid(&instA.guidInstance), wine_dbgstr_guid(&inst3A.guidInstance) );
- ok(IsEqualGUID(&instA.guidProduct, &inst3A.guidProduct), "got %s, %s\n",
- wine_dbgstr_guid(&instA.guidProduct), wine_dbgstr_guid(&inst3A.guidProduct) );
- ok(instA.dwDevType == inst3A.dwDevType, "got %lu, %lu\n", instA.dwDevType, inst3A.dwDevType);
-
- IUnknown_Release(pMouse);
-}
-
-static BOOL CALLBACK EnumAxes(const DIDEVICEOBJECTINSTANCEA *pdidoi, void *pContext)
-{
- if (IsEqualIID(&pdidoi->guidType, &GUID_XAxis) ||
- IsEqualIID(&pdidoi->guidType, &GUID_YAxis) ||
- IsEqualIID(&pdidoi->guidType, &GUID_ZAxis))
- {
- ok(pdidoi->dwFlags & DIDOI_ASPECTPOSITION, "Missing DIDOI_ASPECTPOSITION, flags are %#lx\n",
- pdidoi->dwFlags);
- }
- else
- ok(pdidoi->dwFlags == 0, "Flags are %#lx\n", pdidoi->dwFlags);
-
- return DIENUM_CONTINUE;
-}
-
-static void test_mouse_EnumObjects(IDirectInputA *pDI)
-{
- HRESULT hr;
- IDirectInputDeviceA *pMouse = NULL;
-
- hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, &pMouse, NULL);
- ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr);
- if (FAILED(hr)) return;
-
- hr = IDirectInputDevice_EnumObjects(pMouse, EnumAxes, NULL, DIDFT_ALL);
- ok(hr==DI_OK,"IDirectInputDevice_EnumObjects() failed: %#lx\n", hr);
-
- IUnknown_Release(pMouse);
-}
-
static void mouse_tests(void)
{
HRESULT hr;
@@ -313,8 +225,6 @@ static void mouse_tests(void)
test_set_coop(pDI, hwnd);
test_acquire(pDI, hwnd);
- test_GetDeviceInfo(pDI);
- test_mouse_EnumObjects(pDI);
DestroyWindow(hwnd);
}
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/223
June 10, 2022
[PATCH 2/6] dinput: Fix DIPROP_FFGAIN mouse and keyboard tests.
by Rémi Bernon
From: Rémi Bernon <rbernon(a)codeweavers.com>
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
dlls/dinput/device.c | 2 +-
dlls/dinput/tests/device8.c | 16 ++++++++--------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index 9e7cb20453c..f4bdce51633 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -1394,9 +1394,9 @@ static HRESULT WINAPI dinput_device_set_property( IDirectInputDevice8W *iface, c
case (DWORD_PTR)DIPROP_FFGAIN:
{
const DIPROPDWORD *value = (const DIPROPDWORD *)header;
- if (!impl->vtbl->send_device_gain) return DIERR_UNSUPPORTED;
impl->device_gain = value->dwData;
if (!is_exclusively_acquired( impl )) return DI_OK;
+ if (!impl->vtbl->send_device_gain) return DI_OK;
return impl->vtbl->send_device_gain( iface, impl->device_gain );
}
case (DWORD_PTR)DIPROP_AXISMODE:
diff --git a/dlls/dinput/tests/device8.c b/dlls/dinput/tests/device8.c
index 7bd3600df61..a5c647713f2 100644
--- a/dlls/dinput/tests/device8.c
+++ b/dlls/dinput/tests/device8.c
@@ -1745,14 +1745,14 @@ static void test_mouse_info(void)
hr = IDirectInputDevice8_GetProperty( device, DIPROP_KEYNAME, &prop_string.diph );
ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_KEYNAME returned %#lx\n", hr );
- prop_range.diph.dwHow = DIPH_DEVICE;
- prop_range.diph.dwObj = 0;
+ prop_dword.diph.dwHow = DIPH_DEVICE;
+ prop_dword.diph.dwObj = 0;
prop_dword.dwData = 0xdeadbeef;
hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph );
- ok( hr == DIERR_UNSUPPORTED, "SetProperty DIPROP_FFGAIN returned %#lx\n", hr );
+ ok( hr == DIERR_INVALIDPARAM, "SetProperty DIPROP_FFGAIN returned %#lx\n", hr );
prop_dword.dwData = 1000;
hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph );
- ok( hr == DIERR_UNSUPPORTED, "SetProperty DIPROP_FFGAIN returned %#lx\n", hr );
+ ok( hr == DI_OK, "SetProperty DIPROP_FFGAIN returned %#lx\n", hr );
res = 0;
hr = IDirectInputDevice8_EnumObjects( device, check_object_count, &res, DIDFT_AXIS | DIDFT_PSHBUTTON );
@@ -2080,14 +2080,14 @@ static void test_keyboard_info(void)
hr = IDirectInputDevice8_GetProperty( device, DIPROP_RANGE, &prop_range.diph );
ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_RANGE returned %#lx\n", hr );
- prop_range.diph.dwHow = DIPH_DEVICE;
- prop_range.diph.dwObj = 0;
+ prop_dword.diph.dwHow = DIPH_DEVICE;
+ prop_dword.diph.dwObj = 0;
prop_dword.dwData = 0xdeadbeef;
hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph );
- ok( hr == DIERR_UNSUPPORTED, "SetProperty DIPROP_FFGAIN returned %#lx\n", hr );
+ ok( hr == DIERR_INVALIDPARAM, "SetProperty DIPROP_FFGAIN returned %#lx\n", hr );
prop_dword.dwData = 1000;
hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph );
- ok( hr == DIERR_UNSUPPORTED, "SetProperty DIPROP_FFGAIN returned %#lx\n", hr );
+ ok( hr == DI_OK, "SetProperty DIPROP_FFGAIN returned %#lx\n", hr );
res = 0;
hr = IDirectInputDevice8_EnumObjects( device, check_object_count, &res, DIDFT_AXIS | DIDFT_PSHBUTTON );
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/223
June 10, 2022
[PATCH 1/6] dinput/tests: Add some broken joystick axis results.
by Rémi Bernon
From: Rémi Bernon <rbernon(a)codeweavers.com>
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
dlls/dinput/tests/joystick8.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/dinput/tests/joystick8.c b/dlls/dinput/tests/joystick8.c
index c706276f146..e73330815a0 100644
--- a/dlls/dinput/tests/joystick8.c
+++ b/dlls/dinput/tests/joystick8.c
@@ -1682,8 +1682,8 @@ static void test_simple_joystick( DWORD version )
hr = IDirectInputDevice8_GetDeviceState( device, sizeof(DIJOYSTATE2), &state );
ok( hr == DI_OK, "GetDeviceState returned: %#lx\n", hr );
- check_member( state, expect_state_abs[1], "%ld", lX );
- check_member( state, expect_state_abs[1], "%ld", lY );
+ ok( state.lX == expect_state_abs[1].lX || broken( state.lX == 16853 ) /* w8 */, "got lX %ld", state.lX );
+ ok( state.lY == expect_state_abs[1].lY || broken( state.lY == 16853 ) /* w8 */, "got lY %ld", state.lY );
check_member( state, expect_state_abs[1], "%ld", lZ );
check_member( state, expect_state_abs[1], "%ld", lRx );
check_member( state, expect_state_abs[1], "%ld", rgdwPOV[0] );
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/223
June 10, 2022