ReactOS  0.4.15-dev-1197-g8081ba9
keyboard.c File Reference
#include <windows.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "wine/test.h"
#include "windef.h"
#include "wingdi.h"
#include "dinput.h"
Include dependency graph for keyboard.c:

Go to the source code of this file.

Macros

#define DIRECTINPUT_VERSION   0x0700
 
#define COBJMACROS
 

Functions

static HRESULT (WINAPI *pDirectInputCreateA)(HINSTANCE
 
static IDirectInputA IUnknown *static void pump_messages (void)
 
static HKL activate_keyboard_layout (LANGID langid, HKL *hkl_orig)
 
static void acquire_tests (IDirectInputA *pDI, HWND hwnd)
 
static void test_set_coop (IDirectInputA *pDI, HWND hwnd)
 
static void test_get_prop (IDirectInputA *pDI, HWND hwnd)
 
static void test_capabilities (IDirectInputA *pDI, HWND hwnd)
 
static void test_dik_codes (IDirectInputA *dI, HWND hwnd, LANGID langid)
 
static void test_GetDeviceInfo (IDirectInputA *pDI)
 
static void keyboard_tests (DWORD version)
 
 START_TEST (keyboard)
 

Variables

static DWORD
 
static const HRESULT SetCoop_null_window [16]
 
static const HRESULT SetCoop_invalid_window [16]
 
static const HRESULT SetCoop_real_window [16]
 
static const HRESULT SetCoop_child_window [16]
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file keyboard.c.

◆ DIRECTINPUT_VERSION

#define DIRECTINPUT_VERSION   0x0700

Definition at line 19 of file keyboard.c.

Function Documentation

◆ acquire_tests()

static void acquire_tests ( IDirectInputA *  pDI,
HWND  hwnd 
)
static

Definition at line 80 of file keyboard.c.

81 {
82  HRESULT hr;
83  IDirectInputDeviceA *pKeyboard;
84  BYTE kbd_state[256];
85  LONG custom_state[6];
86  int i;
87  DIOBJECTDATAFORMAT dodf[] =
88  {
89  { &GUID_Key, sizeof(LONG) * 0, DIDFT_MAKEINSTANCE(DIK_Q)|DIDFT_BUTTON, 0 },
90  { &GUID_Key, sizeof(LONG) * 1, DIDFT_MAKEINSTANCE(DIK_W)|DIDFT_BUTTON, 0 },
91  { &GUID_Key, sizeof(LONG) * 2, DIDFT_MAKEINSTANCE(DIK_E)|DIDFT_BUTTON, 0 },
92  { &GUID_Key, sizeof(LONG) * 4, DIDFT_MAKEINSTANCE(DIK_R)|DIDFT_BUTTON, 0 },
93  };
94  DIDATAFORMAT df;
95  HKL hkl, hkl_orig;
96  UINT prev_raw_devices_count, raw_devices_count;
97 
99  if (!hkl) return;
100 
101  df.dwSize = sizeof( df );
102  df.dwObjSize = sizeof( DIOBJECTDATAFORMAT );
103  df.dwFlags = DIDF_RELAXIS;
104  df.dwDataSize = sizeof( custom_state );
105  df.dwNumObjs = ARRAY_SIZE(dodf);
106  df.rgodf = dodf;
107 
108  hr = IDirectInput_CreateDevice(pDI, &GUID_SysKeyboard, &pKeyboard, NULL);
109  ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %08x\n", hr);
110  if (FAILED(hr)) return;
111 
113  ok(SUCCEEDED(hr), "IDirectInputDevice_SetDataFormat() failed: %08x\n", hr);
115  ok(SUCCEEDED(hr), "IDirectInputDevice_SetCooperativeLevel() failed: %08x\n", hr);
116  hr = IDirectInputDevice_GetDeviceState(pKeyboard, 10, kbd_state);
117  ok(hr == DIERR_NOTACQUIRED, "IDirectInputDevice_GetDeviceState(10,) should have failed: %08x\n", hr);
118  hr = IDirectInputDevice_GetDeviceState(pKeyboard, sizeof(kbd_state), kbd_state);
119  ok(hr == DIERR_NOTACQUIRED, "IDirectInputDevice_GetDeviceState() should have failed: %08x\n", hr);
120  hr = IDirectInputDevice_Unacquire(pKeyboard);
121  ok(hr == S_FALSE, "IDirectInputDevice_Unacquire() should have failed: %08x\n", hr);
122  hr = IDirectInputDevice_Acquire(pKeyboard);
123  ok(SUCCEEDED(hr), "IDirectInputDevice_Acquire() failed: %08x\n", hr);
124  hr = IDirectInputDevice_Acquire(pKeyboard);
125  ok(hr == S_FALSE, "IDirectInputDevice_Acquire() should have failed: %08x\n", hr);
126  hr = IDirectInputDevice_GetDeviceState(pKeyboard, 10, kbd_state);
127  ok(hr == DIERR_INVALIDPARAM, "IDirectInputDevice_GetDeviceState(10,) should have failed: %08x\n", hr);
128  hr = IDirectInputDevice_GetDeviceState(pKeyboard, sizeof(kbd_state), kbd_state);
129  ok(SUCCEEDED(hr), "IDirectInputDevice_GetDeviceState() failed: %08x\n", hr);
130  hr = IDirectInputDevice_Unacquire(pKeyboard);
131  ok(SUCCEEDED(hr), "IDirectInputDevice_Uncquire() failed: %08x\n", hr);
132  hr = IDirectInputDevice_SetDataFormat( pKeyboard , &df );
133  ok(SUCCEEDED(hr), "IDirectInputDevice_SetDataFormat() failed: %08x\n", hr);
134  hr = IDirectInputDevice_Acquire(pKeyboard);
135  ok(SUCCEEDED(hr), "IDirectInputDevice_Acquire() failed: %08x\n", hr);
136  hr = IDirectInputDevice_GetDeviceState(pKeyboard, sizeof(custom_state), custom_state);
137  ok(SUCCEEDED(hr), "IDirectInputDevice_GetDeviceState(4,) failed: %08x\n", hr);
138  hr = IDirectInputDevice_GetDeviceState(pKeyboard, sizeof(kbd_state), kbd_state);
139  ok(hr == DIERR_INVALIDPARAM, "IDirectInputDevice_GetDeviceState(256,) should have failed: %08x\n", hr);
140 
141  memset(custom_state, 0x56, sizeof(custom_state));
142  IDirectInputDevice_GetDeviceState(pKeyboard, sizeof(custom_state), custom_state);
143  for (i = 0; i < ARRAY_SIZE(custom_state); i++)
144  ok(custom_state[i] == 0, "Should be zeroed, got 0x%08x\n", custom_state[i]);
145 
146  /* simulate some keyboard input */
147  SetFocus(hwnd);
148  pump_messages();
149 
150  keybd_event('Q', 0, 0, 0);
151  hr = IDirectInputDevice_GetDeviceState(pKeyboard, sizeof(custom_state), custom_state);
152  ok(SUCCEEDED(hr), "IDirectInputDevice_GetDeviceState() failed: %08x\n", hr);
153  if (!custom_state[0])
154  win_skip("Keyboard event not processed, skipping test\n");
155  else
156  {
157  /* unacquiring should reset the device state */
158  hr = IDirectInputDevice_Unacquire(pKeyboard);
159  ok(SUCCEEDED(hr), "IDirectInputDevice_Unacquire() failed: %08x\n", hr);
160  hr = IDirectInputDevice_Acquire(pKeyboard);
161  ok(SUCCEEDED(hr), "IDirectInputDevice_Acquire() failed: %08x\n", hr);
162  hr = IDirectInputDevice_GetDeviceState(pKeyboard, sizeof(custom_state), custom_state);
163  ok(SUCCEEDED(hr), "IDirectInputDevice_GetDeviceState failed: %08x\n", hr);
164  for (i = 0; i < ARRAY_SIZE(custom_state); i++)
165  ok(custom_state[i] == 0, "Should be zeroed, got 0x%08x\n", custom_state[i]);
166  }
167  keybd_event('Q', 0, KEYEVENTF_KEYUP, 0);
168 
169  prev_raw_devices_count = 0;
170  GetRegisteredRawInputDevices(NULL, &prev_raw_devices_count, sizeof(RAWINPUTDEVICE));
171  ok(prev_raw_devices_count == 0 || broken(prev_raw_devices_count == 1) /* wxppro, w2003std */,
172  "Unexpected raw devices registered: %d\n", prev_raw_devices_count);
173 
174  hr = IDirectInputDevice_Acquire(pKeyboard);
175  ok(SUCCEEDED(hr), "IDirectInputDevice_Acquire() failed: %08x\n", hr);
176 
177  raw_devices_count = 0;
178  GetRegisteredRawInputDevices(NULL, &raw_devices_count, sizeof(RAWINPUTDEVICE));
179  ok(raw_devices_count == prev_raw_devices_count,
180  "Unexpected raw devices registered: %d\n", raw_devices_count);
181 
182  hr = IDirectInputDevice_Unacquire(pKeyboard);
183  ok(SUCCEEDED(hr), "IDirectInputDevice_Unacquire() failed: %08x\n", hr);
184 
185  if (pKeyboard) IUnknown_Release(pKeyboard);
186 
187  ActivateKeyboardLayout(hkl_orig, 0);
189 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HKL WINAPI ActivateKeyboardLayout(_In_ HKL, _In_ UINT)
DWORD dwSize
Definition: dinput.h:808
HRESULT hr
Definition: shlfolder.c:183
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
#define IDirectInputDevice_SetCooperativeLevel(p, a, b)
Definition: dinput.h:1614
#define DIERR_NOTACQUIRED
Definition: dinput.h:167
#define IDirectInput_CreateDevice(p, a, b, c)
Definition: dinput.h:2296
DWORD dwNumObjs
Definition: dinput.h:812
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define DIK_Q
Definition: dinput.h:485
#define DIDFT_MAKEINSTANCE(n)
Definition: dinput.h:762
#define IDirectInputDevice_GetDeviceState(p, a, b)
Definition: dinput.h:1610
DWORD dwObjSize
Definition: dinput.h:809
HWND WINAPI SetFocus(_In_opt_ HWND)
#define DISCL_NONEXCLUSIVE
Definition: dinput.h:964
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define DIK_R
Definition: dinput.h:488
#define DIK_E
Definition: dinput.h:487
long LONG
Definition: pedump.c:60
#define DIDFT_BUTTON
Definition: dinput.h:756
#define DIDF_RELAXIS
Definition: dinput.h:776
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
#define DIERR_INVALIDPARAM
Definition: dinput.h:152
#define DISCL_BACKGROUND
Definition: dinput.h:966
BOOL WINAPI UnloadKeyboardLayout(_In_ HKL)
LONG HRESULT
Definition: typedefs.h:79
VOID WINAPI keybd_event(_In_ BYTE, _In_ BYTE, _In_ DWORD, _In_ ULONG_PTR)
#define LANG_ENGLISH
Definition: nls.h:52
DWORD dwFlags
Definition: dinput.h:810
struct _DIOBJECTDATAFORMAT DIOBJECTDATAFORMAT
static HKL activate_keyboard_layout(LANGID langid, HKL *hkl_orig)
Definition: keyboard.c:47
UINT WINAPI DECLSPEC_HOTPATCH GetRegisteredRawInputDevices(PRAWINPUTDEVICE pRawInputDevices, PUINT puiNumDevices, UINT cbSize)
Definition: stubs.c:349
LPDIOBJECTDATAFORMAT rgodf
Definition: dinput.h:813
UINT_PTR HKL
Definition: msctf.idl:101
unsigned char BYTE
Definition: xxhash.c:193
#define broken(x)
Definition: _sntprintf.h:21
#define IDirectInputDevice_Acquire(p)
Definition: dinput.h:1608
static IDirectInputA IUnknown *static void pump_messages(void)
Definition: keyboard.c:36
HKL hkl
Definition: msctf.idl:611
DWORD dwDataSize
Definition: dinput.h:811
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
#define IDirectInputDevice_SetDataFormat(p, a)
Definition: dinput.h:1612
unsigned int UINT
Definition: ndis.h:50
const DIDATAFORMAT c_dfDIKeyboard
Definition: data_formats.c:561
#define IDirectInputDevice_Unacquire(p)
Definition: dinput.h:1609
#define MAKELANGID(p, s)
Definition: nls.h:15
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:149
#define DIK_W
Definition: dinput.h:486
#define SUCCEEDED(hr)
Definition: intsafe.h:49

Referenced by keyboard_tests().

◆ activate_keyboard_layout()

static HKL activate_keyboard_layout ( LANGID  langid,
HKL hkl_orig 
)
static

Definition at line 47 of file keyboard.c.

48 {
49  HKL hkl, hkl_current;
50  char hkl_name[64];
51 
52  sprintf(hkl_name, "%08x", langid);
53  trace("Loading keyboard layout %s\n", hkl_name);
54  hkl = LoadKeyboardLayoutA(hkl_name, 0);
55  if (!hkl)
56  {
57  win_skip("Unable to load keyboard layout %s\n", hkl_name);
58  return 0;
59  }
60  *hkl_orig = ActivateKeyboardLayout(hkl, 0);
61  ok(*hkl_orig != 0, "Unable to activate keyboard layout %s\n", hkl_name);
62  if (!*hkl_orig) return 0;
63 
64  hkl_current = GetKeyboardLayout(0);
65  if (LOWORD(hkl_current) != langid)
66  {
67  /* FIXME: Wine can't activate different keyboard layouts.
68  * for testing purposes use this workaround:
69  * setxkbmap us && LANG=en_US.UTF-8 make test
70  * setxkbmap fr && LANG=fr_FR.UTF-8 make test
71  * setxkbmap de && LANG=de_DE.UTF-8 make test
72  */
73  skip("current %08x != langid %08x\n", LOWORD(hkl_current), langid);
74  return 0;
75  }
76 
77  return hkl;
78 }
HKL WINAPI ActivateKeyboardLayout(_In_ HKL, _In_ UINT)
HKL WINAPI LoadKeyboardLayoutA(_In_ LPCSTR, _In_ UINT)
LANGID langid
Definition: msctf.idl:605
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define trace
Definition: atltest.h:70
UINT_PTR HKL
Definition: msctf.idl:101
HKL hkl
Definition: msctf.idl:611
#define ok(value,...)
Definition: atltest.h:57
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
#define skip(...)
Definition: atltest.h:64
#define win_skip
Definition: test.h:149
#define LOWORD(l)
Definition: pedump.c:82

Referenced by acquire_tests(), and test_dik_codes().

◆ HRESULT()

static HRESULT ( WINAPI pDirectInputCreateA)
static

◆ keyboard_tests()

static void keyboard_tests ( DWORD  version)
static

Definition at line 502 of file keyboard.c.

503 {
504  HRESULT hr;
505  IDirectInputA *pDI = NULL;
507  HWND hwnd;
508  ULONG ref = 0;
509 
510  hr = pDirectInputCreateA(hInstance, version, &pDI, NULL);
512  {
513  skip("Tests require a newer dinput version\n");
514  return;
515  }
516  ok(SUCCEEDED(hr), "DirectInputCreateA() failed: %08x\n", hr);
517  if (FAILED(hr)) return;
518 
519  hwnd = CreateWindowA("static", "Title", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 10, 10, 200, 200,
520  NULL, NULL, NULL, NULL);
521  ok(hwnd != NULL, "err: %d\n", GetLastError());
523 
524  if (hwnd)
525  {
526  pump_messages();
527 
528  acquire_tests(pDI, hwnd);
529  test_set_coop(pDI, hwnd);
530  test_get_prop(pDI, hwnd);
531  test_capabilities(pDI, hwnd);
532  test_GetDeviceInfo(pDI);
533 
538  }
539 
541  if (pDI) ref = IUnknown_Release(pDI);
542  ok(!ref, "IDirectInput_Release() reference count = %d\n", ref);
543 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define SUBLANG_GERMAN
Definition: nls.h:251
HRESULT hr
Definition: shlfolder.c:183
static void acquire_tests(IDirectInputA *pDI, HWND hwnd)
Definition: keyboard.c:80
#define SUBLANG_DEFAULT
Definition: nls.h:168
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
static void test_dik_codes(IDirectInputA *dI, HWND hwnd, LANGID langid)
Definition: keyboard.c:315
#define SUBLANG_JAPANESE_JAPAN
Definition: nls.h:271
#define SUBLANG_FRENCH
Definition: nls.h:242
BOOL WINAPI DestroyWindow(_In_ HWND)
Definition: send.c:48
static void test_set_coop(IDirectInputA *pDI, HWND hwnd)
Definition: keyboard.c:215
HINSTANCE hInstance
Definition: charmap.c:20
#define LANG_JAPANESE
Definition: nls.h:76
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4290
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR version[]
Definition: asmname.c:66
#define DIERR_OLDDIRECTINPUTVERSION
Definition: dinput.h:141
LONG HRESULT
Definition: typedefs.h:79
#define LANG_ENGLISH
Definition: nls.h:52
static void test_capabilities(IDirectInputA *pDI, HWND hwnd)
Definition: keyboard.c:278
static void test_GetDeviceInfo(IDirectInputA *pDI)
Definition: keyboard.c:473
#define LANG_FRENCH
Definition: nls.h:58
#define LANG_GERMAN
Definition: nls.h:62
static IDirectInputA IUnknown *static void pump_messages(void)
Definition: keyboard.c:36
#define ok(value,...)
Definition: atltest.h:57
static void test_get_prop(IDirectInputA *pDI, HWND hwnd)
Definition: keyboard.c:256
#define skip(...)
Definition: atltest.h:64
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
unsigned int ULONG
Definition: retypes.h:1
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define MAKELANGID(p, s)
Definition: nls.h:15
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define WS_VISIBLE
Definition: pedump.c:620
#define SUCCEEDED(hr)
Definition: intsafe.h:49

Referenced by START_TEST().

◆ pump_messages()

static IDirectInputA IUnknown* static void pump_messages ( void  )
static

Definition at line 36 of file keyboard.c.

37 {
38  MSG msg;
39 
40  while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
41  {
44  }
45 }
BOOL WINAPI TranslateMessage(_In_ const MSG *)
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define msg(x)
Definition: auth_time.c:54
#define PM_REMOVE
Definition: winuser.h:1182

Referenced by acquire_tests(), keyboard_tests(), and test_dik_codes().

◆ START_TEST()

START_TEST ( keyboard  )

Definition at line 545 of file keyboard.c.

546 {
547  pDirectInputCreateA = (void *)GetProcAddress(GetModuleHandleA("dinput.dll"), "DirectInputCreateA");
548 
550 
551  keyboard_tests(0x0700);
552 
553  CoUninitialize();
554 }
smooth NULL
Definition: ftsmooth.c:416
static void keyboard_tests(DWORD version)
Definition: keyboard.c:502
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
#define GetProcAddress(x, y)
Definition: compat.h:501

◆ test_capabilities()

static void test_capabilities ( IDirectInputA *  pDI,
HWND  hwnd 
)
static

Definition at line 278 of file keyboard.c.

279 {
280  HRESULT hr;
281  IDirectInputDeviceA *pKeyboard = NULL;
282  DIDEVCAPS caps;
283  int kbd_type, kbd_subtype, dev_subtype;
284 
285  hr = IDirectInput_CreateDevice(pDI, &GUID_SysKeyboard, &pKeyboard, NULL);
286  ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %08x\n", hr);
287  if (FAILED(hr)) return;
288 
289  caps.dwSize = sizeof(caps);
290  hr = IDirectInputDevice_GetCapabilities(pKeyboard, &caps);
291 
292  ok (SUCCEEDED(hr), "GetCapabilities failed: 0x%08x\n", hr);
293  ok (caps.dwFlags & DIDC_ATTACHED, "GetCapabilities dwFlags: 0x%08x\n", caps.dwFlags);
295  "GetCapabilities invalid device type for dwDevType: 0x%08x\n", caps.dwDevType);
296  kbd_type = GetKeyboardType(0);
297  kbd_subtype = GetKeyboardType(1);
298  dev_subtype = GET_DIDEVICE_SUBTYPE(caps.dwDevType);
299  if (kbd_type == 4 || (kbd_type == 7 && kbd_subtype == 0))
300  ok (dev_subtype == DIDEVTYPEKEYBOARD_PCENH,
301  "GetCapabilities invalid device subtype for dwDevType: 0x%08x (%04x:%04x)\n",
302  caps.dwDevType, kbd_type, kbd_subtype);
303  else if (kbd_type == 7 && kbd_subtype == 2)
304  ok (dev_subtype == DIDEVTYPEKEYBOARD_JAPAN106,
305  "GetCapabilities invalid device subtype for dwDevType: 0x%08x (%04x:%04x)\n",
306  caps.dwDevType, kbd_type, kbd_subtype);
307  else
308  ok (dev_subtype != DIDEVTYPEKEYBOARD_UNKNOWN,
309  "GetCapabilities invalid device subtype for dwDevType: 0x%08x (%04x:%04x)\n",
310  caps.dwDevType, kbd_type, kbd_subtype);
311 
312  IUnknown_Release(pKeyboard);
313 }
#define DIDEVTYPEKEYBOARD_UNKNOWN
Definition: dinput.h:228
HRESULT hr
Definition: shlfolder.c:183
#define IDirectInput_CreateDevice(p, a, b, c)
Definition: dinput.h:2296
#define DIDC_ATTACHED
Definition: dinput.h:945
#define GET_DIDEVICE_SUBTYPE(dwDevType)
Definition: dinput.h:321
DWORD dwDevType
Definition: dinput.h:934
DWORD dwFlags
Definition: dinput.h:933
smooth NULL
Definition: ftsmooth.c:416
#define IDirectInputDevice_GetCapabilities(p, a)
Definition: dinput.h:1604
#define DIDEVTYPEKEYBOARD_PCENH
Definition: dinput.h:232
DWORD dwSize
Definition: dinput.h:932
LONG HRESULT
Definition: typedefs.h:79
#define GET_DIDEVICE_TYPE(dwDevType)
Definition: dinput.h:320
#define DIDEVTYPE_KEYBOARD
Definition: dinput.h:199
#define ok(value,...)
Definition: atltest.h:57
#define DIDEVTYPEKEYBOARD_JAPAN106
Definition: dinput.h:238
#define SUCCEEDED(hr)
Definition: intsafe.h:49
int WINAPI GetKeyboardType(_In_ int)

Referenced by keyboard_tests().

◆ test_dik_codes()

static void test_dik_codes ( IDirectInputA *  dI,
HWND  hwnd,
LANGID  langid 
)
static

Definition at line 315 of file keyboard.c.

316 {
317  static const struct key2dik
318  {
319  BYTE key, dik, todo;
320  } key2dik_en[] =
321  {
322  {'Q',DIK_Q}, {'W',DIK_W}, {'E',DIK_E}, {'R',DIK_R}, {'T',DIK_T}, {'Y',DIK_Y},
323  {'[',DIK_LBRACKET}, {']',DIK_RBRACKET}, {'.',DIK_PERIOD}
324  },
325  key2dik_fr[] =
326  {
327  {'A',DIK_Q}, {'Z',DIK_W}, {'E',DIK_E}, {'R',DIK_R}, {'T',DIK_T}, {'Y',DIK_Y},
328  {'^',DIK_LBRACKET}, {'$',DIK_RBRACKET}, {':',DIK_PERIOD}
329  },
330  key2dik_de[] =
331  {
332  {'Q',DIK_Q}, {'W',DIK_W}, {'E',DIK_E}, {'R',DIK_R}, {'T',DIK_T}, {'Z',DIK_Y},
333  {'\xfc',DIK_LBRACKET,1}, {'+',DIK_RBRACKET}, {'.',DIK_PERIOD}
334  },
335  key2dik_ja[] =
336  {
337  {'Q',DIK_Q}, {'W',DIK_W}, {'E',DIK_E}, {'R',DIK_R}, {'T',DIK_T}, {'Y',DIK_Y},
338  {'@',DIK_AT}, {']',DIK_RBRACKET}, {'.',DIK_PERIOD}
339  };
340  static const struct
341  {
342  LANGID langid;
343  const struct key2dik *map;
344  DWORD type;
345  } expected[] =
346  {
348  key2dik_en, DIDEVTYPEKEYBOARD_PCENH },
350  key2dik_fr, DIDEVTYPEKEYBOARD_PCENH },
352  key2dik_de, DIDEVTYPEKEYBOARD_PCENH },
354  key2dik_ja, DIDEVTYPEKEYBOARD_JAPAN106 }
355  };
356  const struct key2dik *map = NULL;
357  UINT i;
358  HRESULT hr;
359  IDirectInputDeviceA *device;
360  DIDEVCAPS caps;
361  HKL hkl, hkl_orig;
362  MSG msg;
363 
364  for (i = 0; i < ARRAY_SIZE(expected); i++)
365  {
366  if (expected[i].langid == langid)
367  {
368  map = expected[i].map;
369  break;
370  }
371  }
372  ok(map != NULL, "can't find mapping for langid %04x\n", langid);
373  if (!map) return;
374 
375  hr = IDirectInput_CreateDevice(dI, &GUID_SysKeyboard, &device, NULL);
376  ok(hr == S_OK, "CreateDevice() failed: %08x\n", hr);
378  ok(hr == S_OK, "SetDataFormat() failed: %08x\n", hr);
380  ok(hr == S_OK, "Acquire() failed: %08x\n", hr);
381  caps.dwSize = sizeof( caps );
383  ok(hr == S_OK, "GetDeviceInstance() failed: %08x\n", hr);
384  if (expected[i].type != GET_DIDEVICE_SUBTYPE(caps.dwDevType)) {
385  skip("Keyboard type(%u) doesn't match for lang %04x\n",
387  goto fail;
388  }
389 
390  hkl = activate_keyboard_layout(langid, &hkl_orig);
391  if (!hkl) goto fail;
392 
393  SetFocus(hwnd);
394  pump_messages();
395 
396  for (i = 0; i < ARRAY_SIZE(key2dik_en); i++)
397  {
398  BYTE kbd_state[256];
399  UINT n;
400  WORD vkey, scan;
401  INPUT in;
402 
403  n = VkKeyScanExW(map[i].key, hkl);
404  todo_wine_if(map[i].todo & 1)
405  ok(n != 0xffff, "%u: failed to get virtual key value for %c(%02x)\n", i, map[i].key, map[i].key);
406  vkey = LOBYTE(n);
407  n = MapVirtualKeyExA(vkey, MAPVK_VK_TO_CHAR, hkl) & 0xff;
408  todo_wine_if(map[i].todo & 1)
409  ok(n == map[i].key, "%u: expected %c(%02x), got %c(%02x)\n", i, map[i].key, map[i].key, n, n);
410  scan = MapVirtualKeyExA(vkey, MAPVK_VK_TO_VSC, hkl);
411  /* scan codes match the DIK_ codes on US keyboard.
412  however, it isn't true for symbols and punctuations in other layouts. */
414  ok(scan == map[i].dik, "%u: expected %02x, got %02x\n", i, map[i].dik, n);
415  else
416  todo_wine_if(map[i].todo & 1)
417  ok(scan, "%u: fail to get scan code value, expected %02x (vkey=%02x)\n",
418  i, map[i].dik, vkey);
419 
420  in.type = INPUT_KEYBOARD;
421  U(in).ki.wVk = vkey;
422  U(in).ki.wScan = scan;
423  U(in).ki.dwFlags = 0;
424  U(in).ki.dwExtraInfo = 0;
425  U(in).ki.time = 0;
426  n = SendInput(1, &in, sizeof(in));
427  ok(n == 1, "got %u\n", n);
428 
429  if (!PeekMessageA(&msg, hwnd, 0, 0, PM_REMOVE))
430  {
431  U(in).ki.dwFlags = KEYEVENTF_KEYUP;
432  SendInput(1, &in, sizeof(in));
433  win_skip("failed to queue keyboard event\n");
434  break;
435  }
436  ok(msg.message == WM_KEYDOWN, "expected WM_KEYDOWN, got %04x\n", msg.message);
438 
440  trace("keydown wParam: %#08lx (%c) lParam: %#08lx, MapVirtualKey(MAPVK_VK_TO_CHAR) = %c\n",
441  msg.wParam, isprint(LOWORD(msg.wParam)) ? LOWORD(msg.wParam) : '?',
442  msg.lParam, isprint(n) ? n : '?');
443 
444  pump_messages();
445 
446  hr = IDirectInputDevice_GetDeviceState(device, sizeof(kbd_state), kbd_state);
447  ok(hr == S_OK, "GetDeviceState() failed: %08x\n", hr);
448 
449  /* this never happens on real hardware but tesbot VMs seem to have timing issues */
450  if (i == 0 && kbd_state[map[0].dik] != 0x80)
451  {
452  win_skip("dinput failed to handle keyboard event\n");
453  break;
454  }
455 
457  ok(kbd_state[map[i].dik] == 0x80, "DI key %#x has state %#x\n", map[i].dik, kbd_state[map[i].dik]);
458 
459  U(in).ki.dwFlags = KEYEVENTF_KEYUP;
460  n = SendInput(1, &in, sizeof(in));
461  ok(n == 1, "got %u\n", n);
462 
463  pump_messages();
464  }
465 
466  ActivateKeyboardLayout(hkl_orig, 0);
468 fail:
470  IUnknown_Release(device);
471 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HKL WINAPI ActivateKeyboardLayout(_In_ HKL, _In_ UINT)
SHORT WINAPI VkKeyScanExW(_In_ WCHAR, _In_ HKL)
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define DIK_AT
Definition: dinput.h:564
#define SUBLANG_GERMAN
Definition: nls.h:251
HRESULT hr
Definition: shlfolder.c:183
#define LOBYTE(W)
Definition: jmemdos.c:487
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
#define IDirectInput_CreateDevice(p, a, b, c)
Definition: dinput.h:2296
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define U(x)
Definition: wordpad.c:45
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define DIK_Q
Definition: dinput.h:485
BOOL todo
Definition: filedlg.c:313
GLdouble n
Definition: glext.h:7729
#define IDirectInputDevice_GetDeviceState(p, a, b)
Definition: dinput.h:1610
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define isalpha(c)
Definition: acclib.h:74
HWND WINAPI SetFocus(_In_opt_ HWND)
WORD LANGID
Definition: typedefs.h:81
#define SUBLANG_JAPANESE_JAPAN
Definition: nls.h:271
#define GET_DIDEVICE_SUBTYPE(dwDevType)
Definition: dinput.h:321
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define DIK_PERIOD
Definition: dinput.h:521
#define SUBLANG_FRENCH
Definition: nls.h:242
LANGID langid
Definition: msctf.idl:605
DWORD dwDevType
Definition: dinput.h:934
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define INPUT_KEYBOARD
Definition: winable.h:10
#define DIK_R
Definition: dinput.h:488
#define DIK_E
Definition: dinput.h:487
#define LANG_JAPANESE
Definition: nls.h:76
Definition: devices.h:37
#define DIK_T
Definition: dinput.h:489
smooth NULL
Definition: ftsmooth.c:416
#define IDirectInputDevice_GetCapabilities(p, a)
Definition: dinput.h:1604
#define WM_KEYDOWN
Definition: winuser.h:1697
#define DIDEVTYPEKEYBOARD_PCENH
Definition: dinput.h:232
#define DIK_LBRACKET
Definition: dinput.h:495
#define todo_wine_if(is_todo)
Definition: test.h:163
#define trace
Definition: atltest.h:70
DWORD dwSize
Definition: dinput.h:932
BOOL WINAPI UnloadKeyboardLayout(_In_ HKL)
#define MAPVK_VK_TO_VSC
Definition: winuser.h:2330
LONG HRESULT
Definition: typedefs.h:79
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: _map.h:44
#define LANG_ENGLISH
Definition: nls.h:52
static HKL activate_keyboard_layout(LANGID langid, HKL *hkl_orig)
Definition: keyboard.c:47
HKEY key
Definition: reg.c:42
UINT_PTR HKL
Definition: msctf.idl:101
#define LANG_FRENCH
Definition: nls.h:58
unsigned char BYTE
Definition: xxhash.c:193
#define LANG_GERMAN
Definition: nls.h:62
#define DIK_RBRACKET
Definition: dinput.h:496
#define MAPVK_VK_TO_CHAR
Definition: winuser.h:2332
#define DIK_Y
Definition: dinput.h:490
UINT WINAPI MapVirtualKeyExA(_In_ UINT, _In_ UINT, _In_opt_ HKL)
#define IDirectInputDevice_Acquire(p)
Definition: dinput.h:1608
static IDirectInputA IUnknown *static void pump_messages(void)
Definition: keyboard.c:36
#define S_OK
Definition: intsafe.h:51
HKL hkl
Definition: msctf.idl:611
GLuint in
Definition: glext.h:9616
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
#define IDirectInputDevice_SetDataFormat(p, a)
Definition: dinput.h:1612
unsigned int UINT
Definition: ndis.h:50
#define DIDEVTYPEKEYBOARD_JAPAN106
Definition: dinput.h:238
const DIDATAFORMAT c_dfDIKeyboard
Definition: data_formats.c:561
#define isprint(c)
Definition: acclib.h:73
#define skip(...)
Definition: atltest.h:64
#define msg(x)
Definition: auth_time.c:54
#define IDirectInputDevice_Unacquire(p)
Definition: dinput.h:1609
#define MAKELANGID(p, s)
Definition: nls.h:15
#define PM_REMOVE
Definition: winuser.h:1182
#define win_skip
Definition: test.h:149
#define LOWORD(l)
Definition: pedump.c:82
UINT WINAPI SendInput(UINT, LPINPUT, int)
Definition: ntwrapper.h:344
#define DIK_W
Definition: dinput.h:486
BOOL expected
Definition: store.c:2063
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum map
Definition: glfuncs.h:262
Definition: path.c:41

Referenced by keyboard_tests().

◆ test_get_prop()

static void test_get_prop ( IDirectInputA *  pDI,
HWND  hwnd 
)
static

Definition at line 256 of file keyboard.c.

257 {
258  HRESULT hr;
259  IDirectInputDeviceA *pKeyboard = NULL;
260  DIPROPRANGE diprg;
261 
262  hr = IDirectInput_CreateDevice(pDI, &GUID_SysKeyboard, &pKeyboard, NULL);
263  ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %08x\n", hr);
264  if (FAILED(hr)) return;
265 
266  memset(&diprg, 0, sizeof(diprg));
267  diprg.diph.dwSize = sizeof(DIPROPRANGE);
268  diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
269  diprg.diph.dwHow = DIPH_DEVICE;
270  diprg.diph.dwObj = 0;
271 
272  hr = IDirectInputDevice_GetProperty(pKeyboard, DIPROP_RANGE, &diprg.diph);
273  ok(hr == DIERR_UNSUPPORTED, "IDirectInputDevice_GetProperty() did not return DIPROP_RANGE but: %08x\n", hr);
274 
275  if (pKeyboard) IUnknown_Release(pKeyboard);
276 }
DWORD dwSize
Definition: dinput.h:828
HRESULT hr
Definition: shlfolder.c:183
#define IDirectInput_CreateDevice(p, a, b, c)
Definition: dinput.h:2296
#define DIPROP_RANGE
Definition: dinput.h:892
DWORD dwHow
Definition: dinput.h:831
#define IDirectInputDevice_GetProperty(p, a, b)
Definition: dinput.h:1606
#define DIPH_DEVICE
Definition: dinput.h:835
#define DIERR_UNSUPPORTED
Definition: dinput.h:156
struct DIPROPRANGE DIPROPRANGE
smooth NULL
Definition: ftsmooth.c:416
DIPROPHEADER diph
Definition: dinput.h:849
LONG HRESULT
Definition: typedefs.h:79
struct DIPROPHEADER DIPROPHEADER
#define ok(value,...)
Definition: atltest.h:57
DWORD dwObj
Definition: dinput.h:830
DWORD dwHeaderSize
Definition: dinput.h:829
#define memset(x, y, z)
Definition: compat.h:39
#define SUCCEEDED(hr)
Definition: intsafe.h:49

Referenced by keyboard_tests().

◆ test_GetDeviceInfo()

static void test_GetDeviceInfo ( IDirectInputA *  pDI)
static

Definition at line 473 of file keyboard.c.

474 {
475  HRESULT hr;
476  IDirectInputDeviceA *pKey = NULL;
477  DIDEVICEINSTANCEA instA;
478  DIDEVICEINSTANCE_DX3A inst3A;
479 
480  hr = IDirectInput_CreateDevice(pDI, &GUID_SysKeyboard, &pKey, NULL);
481  ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %08x\n", hr);
482  if (FAILED(hr)) return;
483 
484  instA.dwSize = sizeof(instA);
485  hr = IDirectInputDevice_GetDeviceInfo(pKey, &instA);
486  ok(SUCCEEDED(hr), "got %08x\n", hr);
487 
488  inst3A.dwSize = sizeof(inst3A);
490  ok(SUCCEEDED(hr), "got %08x\n", hr);
491 
492  ok(instA.dwSize != inst3A.dwSize, "got %d, %d \n", instA.dwSize, inst3A.dwSize);
493  ok(IsEqualGUID(&instA.guidInstance, &inst3A.guidInstance), "got %s, %s\n",
495  ok(IsEqualGUID(&instA.guidProduct, &inst3A.guidProduct), "got %s, %s\n",
497  ok(instA.dwDevType == inst3A.dwDevType, "got %d, %d\n", instA.dwDevType, inst3A.dwDevType);
498 
499  IUnknown_Release(pKey);
500 }
GUID guidInstance
Definition: dinput.h:413
HRESULT hr
Definition: shlfolder.c:183
#define IDirectInput_CreateDevice(p, a, b, c)
Definition: dinput.h:2296
const char * wine_dbgstr_guid(const GUID *guid)
DWORD dwDevType
Definition: dinput.h:415
GUID guidProduct
Definition: dinput.h:414
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:79
#define ok(value,...)
Definition: atltest.h:57
#define IDirectInputDevice_GetDeviceInfo(p, a)
Definition: dinput.h:1616
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define SUCCEEDED(hr)
Definition: intsafe.h:49

Referenced by keyboard_tests().

◆ test_set_coop()

static void test_set_coop ( IDirectInputA *  pDI,
HWND  hwnd 
)
static

Definition at line 215 of file keyboard.c.

216 {
217  HRESULT hr;
218  IDirectInputDeviceA *pKeyboard = NULL;
219  int i;
220  HWND child;
221 
222  hr = IDirectInput_CreateDevice(pDI, &GUID_SysKeyboard, &pKeyboard, NULL);
223  ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %08x\n", hr);
224  if (FAILED(hr)) return;
225 
226  for (i=0; i<16; i++)
227  {
229  ok(hr == SetCoop_null_window[i], "SetCooperativeLevel(NULL, %d): %08x\n", i, hr);
230  }
231  for (i=0; i<16; i++)
232  {
233  hr = IDirectInputDevice_SetCooperativeLevel(pKeyboard, (HWND)0x400000, i);
234  ok(hr == SetCoop_invalid_window[i], "SetCooperativeLevel(invalid, %d): %08x\n", i, hr);
235  }
236  for (i=0; i<16; i++)
237  {
239  ok(hr == SetCoop_real_window[i], "SetCooperativeLevel(hwnd, %d): %08x\n", i, hr);
240  }
241 
242  child = CreateWindowA("static", "Title", WS_CHILD | WS_VISIBLE, 10, 10, 50, 50, hwnd, NULL,
243  NULL, NULL);
244  ok(child != NULL, "err: %d\n", GetLastError());
245 
246  for (i=0; i<16; i++)
247  {
249  ok(hr == SetCoop_child_window[i], "SetCooperativeLevel(child, %d): %08x\n", i, hr);
250  }
251 
253  if (pKeyboard) IUnknown_Release(pKeyboard);
254 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HRESULT hr
Definition: shlfolder.c:183
#define IDirectInputDevice_SetCooperativeLevel(p, a, b)
Definition: dinput.h:1614
#define IDirectInput_CreateDevice(p, a, b, c)
Definition: dinput.h:2296
static const HRESULT SetCoop_real_window[16]
Definition: keyboard.c:203
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define WS_CHILD
Definition: pedump.c:617
BOOL WINAPI DestroyWindow(_In_ HWND)
static HWND child
Definition: cursoricon.c:298
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4290
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:79
static const HRESULT SetCoop_invalid_window[16]
Definition: keyboard.c:197
#define ok(value,...)
Definition: atltest.h:57
#define WS_VISIBLE
Definition: pedump.c:620
static const HRESULT SetCoop_null_window[16]
Definition: keyboard.c:191
static const HRESULT SetCoop_child_window[16]
Definition: keyboard.c:209
#define SUCCEEDED(hr)
Definition: intsafe.h:49

Referenced by keyboard_tests().

Variable Documentation

◆ DWORD

Definition at line 34 of file keyboard.c.

Referenced by KeyboardSpeedProc(), and NtUserVkKeyScanEx().

◆ SetCoop_child_window

const HRESULT SetCoop_child_window[16]
static

◆ SetCoop_invalid_window

const HRESULT SetCoop_invalid_window[16]
static

◆ SetCoop_null_window

const HRESULT SetCoop_null_window[16]
static
Initial value:

Definition at line 191 of file keyboard.c.

Referenced by test_set_coop().

◆ SetCoop_real_window

const HRESULT SetCoop_real_window[16]
static
Initial value:

Definition at line 203 of file keyboard.c.

Referenced by test_set_coop().