ReactOS  0.4.15-dev-1197-g8081ba9
dinput.c File Reference
#include <initguid.h>
#include <windows.h>
#include <dinput.h>
#include <dinputd.h>
#include "wine/test.h"
Include dependency graph for dinput.c:

Go to the source code of this file.

Classes

struct  enum_devices_test
 
struct  enum_semantics_test
 

Macros

#define DIRECTINPUT_VERSION   0x0800
 
#define COBJMACROS
 

Functions

static BOOL CALLBACK dummy_callback (const DIDEVICEINSTANCEA *instance, void *context)
 
static void test_preinitialization (void)
 
static void test_DirectInput8Create (void)
 
static void test_QueryInterface (void)
 
static void test_CreateDevice (void)
 
static BOOL CALLBACK enum_devices_callback (const DIDEVICEINSTANCEA *instance, void *context)
 
static void test_EnumDevices (void)
 
static BOOL CALLBACK enum_semantics_callback (const DIDEVICEINSTANCEA *lpddi, IDirectInputDevice8A *lpdid, DWORD dwFlags, DWORD dwRemaining, void *context)
 
static BOOL CALLBACK set_action_map_callback (const DIDEVICEINSTANCEA *lpddi, IDirectInputDevice8A *lpdid, DWORD dwFlags, DWORD dwRemaining, void *context)
 
static void test_EnumDevicesBySemantics (void)
 
static void test_GetDeviceStatus (void)
 
static void test_RunControlPanel (void)
 
static void test_Initialize (void)
 
 START_TEST (dinput)
 

Variables

HINSTANCE hInstance
 
static DIACTIONA actionMapping []
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file dinput.c.

◆ DIRECTINPUT_VERSION

#define DIRECTINPUT_VERSION   0x0800

Definition at line 19 of file dinput.c.

Function Documentation

◆ dummy_callback()

static BOOL CALLBACK dummy_callback ( const DIDEVICEINSTANCEA instance,
void context 
)
static

Definition at line 31 of file dinput.c.

32 {
33  ok(0, "Callback was invoked with parameters (%p, %p)\n", instance, context);
34  return DIENUM_STOP;
35 }
Definition: http.c:7094
#define DIENUM_STOP
Definition: dinput.h:187
#define ok(value,...)
Definition: atltest.h:57
static HINSTANCE instance
Definition: main.c:40

Referenced by test_preinitialization().

◆ enum_devices_callback()

static BOOL CALLBACK enum_devices_callback ( const DIDEVICEINSTANCEA instance,
void context 
)
static

Definition at line 345 of file dinput.c.

346 {
347  struct enum_devices_test *enum_test = context;
348 
349  trace("---- Device Information ----\n"
350  "Product Name : %s\n"
351  "Instance Name : %s\n"
352  "devType : 0x%08x\n"
353  "GUID Product : %s\n"
354  "GUID Instance : %s\n"
355  "HID Page : 0x%04x\n"
356  "HID Usage : 0x%04x\n",
357  instance->tszProductName,
358  instance->tszInstanceName,
359  instance->dwDevType,
360  wine_dbgstr_guid(&instance->guidProduct),
361  wine_dbgstr_guid(&instance->guidInstance),
362  instance->wUsagePage,
363  instance->wUsage);
364 
365  if ((instance->dwDevType & 0xff) == DI8DEVTYPE_KEYBOARD ||
366  (instance->dwDevType & 0xff) == DI8DEVTYPE_MOUSE) {
367  const char *device = ((instance->dwDevType & 0xff) ==
368  DI8DEVTYPE_KEYBOARD) ? "Keyboard" : "Mouse";
369  ok(IsEqualGUID(&instance->guidInstance, &instance->guidProduct),
370  "%s guidInstance (%s) does not match guidProduct (%s)\n",
371  device, wine_dbgstr_guid(&instance->guidInstance),
372  wine_dbgstr_guid(&instance->guidProduct));
373  }
374 
375  enum_test->device_count++;
376  return enum_test->return_value;
377 }
Definition: http.c:7094
const char * wine_dbgstr_guid(const GUID *guid)
#define DI8DEVTYPE_KEYBOARD
Definition: dinput.h:211
BOOL return_value
Definition: dinput.c:372
Definition: devices.h:37
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
static HINSTANCE instance
Definition: main.c:40
unsigned int device_count
Definition: dinput.c:371
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define DI8DEVTYPE_MOUSE
Definition: dinput.h:210

Referenced by test_EnumDevices().

◆ enum_semantics_callback()

static BOOL CALLBACK enum_semantics_callback ( const DIDEVICEINSTANCEA lpddi,
IDirectInputDevice8A *  lpdid,
DWORD  dwFlags,
DWORD  dwRemaining,
void context 
)
static

Definition at line 469 of file dinput.c.

470 {
471  struct enum_semantics_test *data = context;
472 
473  if (context == NULL) return DIENUM_STOP;
474 
475  if (!data->device_count) {
476  data->first_remaining = dwRemaining;
477  }
478  ok (dwRemaining == data->first_remaining - data->device_count,
479  "enum semantics remaining devices is wrong, expected %d, had %d\n",
480  data->first_remaining - data->device_count, dwRemaining);
481  data->device_count++;
482 
483  if (IsEqualGUID(&lpddi->guidInstance, &GUID_SysKeyboard)) data->keyboard = TRUE;
484 
485  if (IsEqualGUID(&lpddi->guidInstance, &GUID_SysMouse)) data->mouse = TRUE;
486 
487  return DIENUM_CONTINUE;
488 }
GUID guidInstance
Definition: dinput.h:413
Definition: http.c:7094
#define TRUE
Definition: types.h:120
#define DIENUM_STOP
Definition: dinput.h:187
smooth NULL
Definition: ftsmooth.c:416
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define DIENUM_CONTINUE
Definition: dinput.h:188

Referenced by test_EnumDevicesBySemantics().

◆ set_action_map_callback()

static BOOL CALLBACK set_action_map_callback ( const DIDEVICEINSTANCEA lpddi,
IDirectInputDevice8A *  lpdid,
DWORD  dwFlags,
DWORD  dwRemaining,
void context 
)
static

Definition at line 490 of file dinput.c.

491 {
492  HRESULT hr;
493  struct enum_semantics_test *data = context;
494 
495  /* Building and setting an action map */
496  /* It should not use any pre-stored mappings so we use DIDBAM_INITIALIZE */
498  ok (SUCCEEDED(hr), "BuildActionMap failed hr=%08x\n", hr);
499 
500  hr = IDirectInputDevice8_SetActionMap(lpdid, data->lpdiaf, data->username, 0);
501  ok (SUCCEEDED(hr), "SetActionMap failed hr=%08x\n", hr);
502 
503  return DIENUM_CONTINUE;
504 }
HRESULT hr
Definition: shlfolder.c:183
Definition: http.c:7094
#define DIDBAM_INITIALIZE
Definition: dinput.h:1354
#define IDirectInputDevice8_BuildActionMap(p, a, b, c)
Definition: dinput.h:2067
smooth NULL
Definition: ftsmooth.c:416
#define IDirectInputDevice8_SetActionMap(p, a, b, c)
Definition: dinput.h:2068
LONG HRESULT
Definition: typedefs.h:79
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define ok(value,...)
Definition: atltest.h:57
#define DIENUM_CONTINUE
Definition: dinput.h:188
#define SUCCEEDED(hr)
Definition: intsafe.h:49

Referenced by test_EnumDevicesBySemantics().

◆ START_TEST()

START_TEST ( dinput  )

Definition at line 712 of file dinput.c.

713 {
715 
725  test_Initialize();
726  CoUninitialize();
727 }
static void test_Initialize(void)
Definition: dinput.c:673
HINSTANCE hInstance
Definition: dinput.c:29
static void test_RunControlPanel(void)
Definition: dinput.c:640
static void test_EnumDevices(void)
Definition: dinput.c:379
smooth NULL
Definition: ftsmooth.c:416
static void test_preinitialization(void)
Definition: dinput.c:37
static void test_CreateDevice(void)
Definition: dinput.c:300
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static void test_GetDeviceStatus(void)
Definition: dinput.c:615
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
static void test_EnumDevicesBySemantics(void)
Definition: dinput.c:506
static void test_QueryInterface(void)
Definition: dinput.c:221
static void test_DirectInput8Create(void)
Definition: dinput.c:130

◆ test_CreateDevice()

static void test_CreateDevice ( void  )
static

Definition at line 300 of file dinput.c.

301 {
302  IDirectInput8A *pDI;
303  HRESULT hr;
304  IDirectInputDevice8A *pDID;
305 
306  hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, &IID_IDirectInput8A, (void **)&pDI, NULL);
307  if (FAILED(hr))
308  {
309  win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr);
310  return;
311  }
312 
314  ok(hr == E_POINTER, "IDirectInput8_CreateDevice returned 0x%08x\n", hr);
315 
316  pDID = (void *)0xdeadbeef;
317  hr = IDirectInput8_CreateDevice(pDI, NULL, &pDID, NULL);
318  ok(hr == E_POINTER, "IDirectInput8_CreateDevice returned 0x%08x\n", hr);
319  ok(pDID == NULL, "Output interface pointer is %p\n", pDID);
320 
321  hr = IDirectInput8_CreateDevice(pDI, &GUID_Unknown, NULL, NULL);
322  ok(hr == E_POINTER, "IDirectInput8_CreateDevice returned 0x%08x\n", hr);
323 
324  pDID = (void *)0xdeadbeef;
325  hr = IDirectInput8_CreateDevice(pDI, &GUID_Unknown, &pDID, NULL);
326  ok(hr == DIERR_DEVICENOTREG, "IDirectInput8_CreateDevice returned 0x%08x\n", hr);
327  ok(pDID == NULL, "Output interface pointer is %p\n", pDID);
328 
329  hr = IDirectInput8_CreateDevice(pDI, &GUID_SysMouse, NULL, NULL);
330  ok(hr == E_POINTER, "IDirectInput8_CreateDevice returned 0x%08x\n", hr);
331 
332  hr = IDirectInput8_CreateDevice(pDI, &GUID_SysMouse, &pDID, NULL);
333  ok(hr == DI_OK, "IDirectInput8_CreateDevice returned 0x%08x\n", hr);
334 
337 }
HRESULT hr
Definition: shlfolder.c:183
#define IDirectInput8_CreateDevice(p, a, b, c)
Definition: dinput.h:2513
HINSTANCE hInstance
Definition: dinput.c:29
#define DIRECTINPUT_VERSION
Definition: dinput.c:19
HRESULT WINAPI DECLSPEC_HOTPATCH DirectInput8Create(HINSTANCE hinst, DWORD version, REFIID iid, void **out, IUnknown *outer)
Definition: dinput_main.c:172
smooth NULL
Definition: ftsmooth.c:416
#define IDirectInputDevice_Release(p)
Definition: dinput.h:1602
LONG HRESULT
Definition: typedefs.h:79
#define DIERR_DEVICENOTREG
Definition: dinput.h:147
#define ok(value,...)
Definition: atltest.h:57
#define DI_OK
Definition: dinput.h:128
#define E_POINTER
Definition: winerror.h:2365
#define win_skip
Definition: test.h:149
#define IDirectInput8_Release(p)
Definition: dinput.h:2511

Referenced by START_TEST().

◆ test_DirectInput8Create()

static void test_DirectInput8Create ( void  )
static

Definition at line 130 of file dinput.c.

131 {
132  static const struct
133  {
134  BOOL hinst;
135  DWORD dwVersion;
136  REFIID riid;
137  BOOL ppdi;
138  HRESULT expected_hr;
139  } invalid_param_list[] =
140  {
141  {FALSE, 0, &IID_IDirectInputA, FALSE, E_POINTER},
142  {FALSE, 0, &IID_IDirectInputA, TRUE, DIERR_NOINTERFACE},
143  {FALSE, 0, &IID_IDirectInput8A, FALSE, E_POINTER},
144  {FALSE, 0, &IID_IDirectInput8A, TRUE, DIERR_INVALIDPARAM},
145  {FALSE, DIRECTINPUT_VERSION, &IID_IDirectInputA, FALSE, E_POINTER},
146  {FALSE, DIRECTINPUT_VERSION, &IID_IDirectInputA, TRUE, DIERR_NOINTERFACE},
147  {FALSE, DIRECTINPUT_VERSION, &IID_IDirectInput8A, FALSE, E_POINTER},
148  {FALSE, DIRECTINPUT_VERSION, &IID_IDirectInput8A, TRUE, DIERR_INVALIDPARAM},
149  {FALSE, DIRECTINPUT_VERSION - 1, &IID_IDirectInputA, FALSE, E_POINTER},
150  {FALSE, DIRECTINPUT_VERSION - 1, &IID_IDirectInputA, TRUE, DIERR_NOINTERFACE},
151  {FALSE, DIRECTINPUT_VERSION - 1, &IID_IDirectInput8A, FALSE, E_POINTER},
152  {FALSE, DIRECTINPUT_VERSION - 1, &IID_IDirectInput8A, TRUE, DIERR_INVALIDPARAM},
153  {FALSE, DIRECTINPUT_VERSION + 1, &IID_IDirectInputA, FALSE, E_POINTER},
154  {FALSE, DIRECTINPUT_VERSION + 1, &IID_IDirectInputA, TRUE, DIERR_NOINTERFACE},
155  {FALSE, DIRECTINPUT_VERSION + 1, &IID_IDirectInput8A, FALSE, E_POINTER},
156  {FALSE, DIRECTINPUT_VERSION + 1, &IID_IDirectInput8A, TRUE, DIERR_INVALIDPARAM},
157  {TRUE, 0, &IID_IDirectInputA, FALSE, E_POINTER},
158  {TRUE, 0, &IID_IDirectInputA, TRUE, DIERR_NOINTERFACE},
159  {TRUE, 0, &IID_IDirectInput8A, FALSE, E_POINTER},
160  {TRUE, 0, &IID_IDirectInput8A, TRUE, DIERR_NOTINITIALIZED},
161  {TRUE, DIRECTINPUT_VERSION, &IID_IDirectInputA, FALSE, E_POINTER},
162  {TRUE, DIRECTINPUT_VERSION, &IID_IDirectInputA, TRUE, DIERR_NOINTERFACE},
163  {TRUE, DIRECTINPUT_VERSION, &IID_IDirectInput8A, FALSE, E_POINTER},
164  {TRUE, DIRECTINPUT_VERSION - 1, &IID_IDirectInputA, FALSE, E_POINTER},
165  {TRUE, DIRECTINPUT_VERSION - 1, &IID_IDirectInputA, TRUE, DIERR_NOINTERFACE},
166  {TRUE, DIRECTINPUT_VERSION - 1, &IID_IDirectInput8A, FALSE, E_POINTER},
167  {TRUE, DIRECTINPUT_VERSION - 1, &IID_IDirectInput8A, TRUE, DIERR_BETADIRECTINPUTVERSION},
168  {TRUE, DIRECTINPUT_VERSION + 1, &IID_IDirectInputA, FALSE, E_POINTER},
169  {TRUE, DIRECTINPUT_VERSION + 1, &IID_IDirectInputA, TRUE, DIERR_NOINTERFACE},
170  {TRUE, DIRECTINPUT_VERSION + 1, &IID_IDirectInput8A, FALSE, E_POINTER},
171  {TRUE, DIRECTINPUT_VERSION + 1, &IID_IDirectInput8A, TRUE, DIERR_OLDDIRECTINPUTVERSION},
172  };
173 
174  static REFIID no_interface_list[] = {&IID_IDirectInputA, &IID_IDirectInputW,
175  &IID_IDirectInput2A, &IID_IDirectInput2W,
176  &IID_IDirectInput7A, &IID_IDirectInput7W,
177  &IID_IDirectInputDeviceA, &IID_IDirectInputDeviceW,
178  &IID_IDirectInputDevice2A, &IID_IDirectInputDevice2W,
179  &IID_IDirectInputDevice7A, &IID_IDirectInputDevice7W,
180  &IID_IDirectInputDevice8A, &IID_IDirectInputDevice8W,
181  &IID_IDirectInputEffect};
182 
183  static REFIID iid_list[] = {&IID_IUnknown, &IID_IDirectInput8A, &IID_IDirectInput8W};
184 
185  int i;
186  IUnknown *pUnk;
187  HRESULT hr;
188 
189  for (i = 0; i < ARRAY_SIZE(invalid_param_list); i++)
190  {
191  if (invalid_param_list[i].ppdi) pUnk = (void *)0xdeadbeef;
192  hr = DirectInput8Create(invalid_param_list[i].hinst ? hInstance : NULL,
193  invalid_param_list[i].dwVersion,
194  invalid_param_list[i].riid,
195  invalid_param_list[i].ppdi ? (void **)&pUnk : NULL,
196  NULL);
197  ok(hr == invalid_param_list[i].expected_hr, "[%d] DirectInput8Create returned 0x%08x\n", i, hr);
198  if (invalid_param_list[i].ppdi)
199  ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk);
200  }
201 
202  for (i = 0; i < ARRAY_SIZE(no_interface_list); i++)
203  {
204  pUnk = (void *)0xdeadbeef;
205  hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, no_interface_list[i], (void **)&pUnk, NULL);
206  ok(hr == DIERR_NOINTERFACE, "[%d] DirectInput8Create returned 0x%08x\n", i, hr);
207  ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk);
208  }
209 
210  for (i = 0; i < ARRAY_SIZE(iid_list); i++)
211  {
212  pUnk = NULL;
213  hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, iid_list[i], (void **)&pUnk, NULL);
214  ok(hr == DI_OK, "[%d] DirectInput8Create returned 0x%08x\n", i, hr);
215  ok(pUnk != NULL, "[%d] Output interface pointer is NULL\n", i);
216  if (pUnk)
217  IUnknown_Release(pUnk);
218  }
219 }
#define DIERR_NOTINITIALIZED
Definition: dinput.h:157
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
REFIID riid
Definition: precomp.h:44
HINSTANCE hInstance
Definition: dinput.c:29
#define DIRECTINPUT_VERSION
Definition: dinput.c:19
HRESULT WINAPI DECLSPEC_HOTPATCH DirectInput8Create(HINSTANCE hinst, DWORD version, REFIID iid, void **out, IUnknown *outer)
Definition: dinput_main.c:172
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 FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define DIERR_INVALIDPARAM
Definition: dinput.h:152
#define DIERR_OLDDIRECTINPUTVERSION
Definition: dinput.h:141
LONG HRESULT
Definition: typedefs.h:79
const GUID IID_IUnknown
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DIERR_NOINTERFACE
Definition: dinput.h:153
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
#define DI_OK
Definition: dinput.h:128
static HINSTANCE hinst
Definition: edit.c:551
#define E_POINTER
Definition: winerror.h:2365
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
#define DIERR_BETADIRECTINPUTVERSION
Definition: dinput.h:143
static REFIID
Definition: dinput.c:53

Referenced by START_TEST().

◆ test_EnumDevices()

static void test_EnumDevices ( void  )
static

Definition at line 379 of file dinput.c.

380 {
381  IDirectInput8A *pDI;
382  HRESULT hr;
383  struct enum_devices_test enum_test, enum_test_return;
384 
385  hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, &IID_IDirectInput8A, (void **)&pDI, NULL);
386  if (FAILED(hr))
387  {
388  win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr);
389  return;
390  }
391 
392  hr = IDirectInput8_EnumDevices(pDI, 0, NULL, NULL, 0);
393  ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_EnumDevices returned 0x%08x\n", hr);
394 
395  hr = IDirectInput8_EnumDevices(pDI, 0, NULL, NULL, ~0u);
396  ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_EnumDevices returned 0x%08x\n", hr);
397 
398  /* Test crashes on Wine. */
399  if (0)
400  {
402  ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_EnumDevices returned 0x%08x\n", hr);
403  }
404 
405  hr = IDirectInput8_EnumDevices(pDI, 0xdeadbeef, NULL, NULL, 0);
406  ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_EnumDevices returned 0x%08x\n", hr);
407 
408  hr = IDirectInput8_EnumDevices(pDI, 0xdeadbeef, NULL, NULL, ~0u);
409  ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_EnumDevices returned 0x%08x\n", hr);
410 
411  hr = IDirectInput8_EnumDevices(pDI, 0xdeadbeef, enum_devices_callback, NULL, 0);
412  ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_EnumDevices returned 0x%08x\n", hr);
413 
414  hr = IDirectInput8_EnumDevices(pDI, 0xdeadbeef, enum_devices_callback, NULL, ~0u);
415  ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_EnumDevices returned 0x%08x\n", hr);
416 
417  enum_test.device_count = 0;
418  enum_test.return_value = DIENUM_CONTINUE;
419  hr = IDirectInput8_EnumDevices(pDI, 0, enum_devices_callback, &enum_test, 0);
420  ok(hr == DI_OK, "IDirectInput8_EnumDevices returned 0x%08x\n", hr);
421  ok(enum_test.device_count != 0, "Device count is %u\n", enum_test.device_count);
422 
423  /* Enumeration only stops with an explicit DIENUM_STOP. */
424  enum_test_return.device_count = 0;
425  enum_test_return.return_value = 42;
426  hr = IDirectInput8_EnumDevices(pDI, 0, enum_devices_callback, &enum_test_return, 0);
427  ok(hr == DI_OK, "IDirectInput8_EnumDevices returned 0x%08x\n", hr);
428  ok(enum_test_return.device_count == enum_test.device_count,
429  "Device count is %u vs. %u\n", enum_test_return.device_count, enum_test.device_count);
430 
431  enum_test.device_count = 0;
432  enum_test.return_value = DIENUM_STOP;
433  hr = IDirectInput8_EnumDevices(pDI, 0, enum_devices_callback, &enum_test, 0);
434  ok(hr == DI_OK, "IDirectInput8_EnumDevices returned 0x%08x\n", hr);
435  ok(enum_test.device_count == 1, "Device count is %u\n", enum_test.device_count);
436 
438 }
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 * u
Definition: glfuncs.h:240
HRESULT hr
Definition: shlfolder.c:183
HINSTANCE hInstance
Definition: dinput.c:29
#define DIRECTINPUT_VERSION
Definition: dinput.c:19
HRESULT WINAPI DECLSPEC_HOTPATCH DirectInput8Create(HINSTANCE hinst, DWORD version, REFIID iid, void **out, IUnknown *outer)
Definition: dinput_main.c:172
#define DIENUM_STOP
Definition: dinput.h:187
smooth NULL
Definition: ftsmooth.c:416
#define DIERR_INVALIDPARAM
Definition: dinput.h:152
LONG HRESULT
Definition: typedefs.h:79
static BOOL CALLBACK enum_devices_callback(const DIDEVICEINSTANCEA *instance, void *context)
Definition: dinput.c:345
#define ok(value,...)
Definition: atltest.h:57
#define DI_OK
Definition: dinput.h:128
#define DIENUM_CONTINUE
Definition: dinput.h:188
#define win_skip
Definition: test.h:149
#define IDirectInput8_EnumDevices(p, a, b, c, d)
Definition: dinput.h:2514
#define IDirectInput8_Release(p)
Definition: dinput.h:2511

Referenced by START_TEST().

◆ test_EnumDevicesBySemantics()

static void test_EnumDevicesBySemantics ( void  )
static

Definition at line 506 of file dinput.c.

507 {
508  IDirectInput8A *pDI;
509  HRESULT hr;
510  DIACTIONFORMATA diaf;
511  const GUID ACTION_MAPPING_GUID = { 0x1, 0x2, 0x3, { 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb } };
512  struct enum_semantics_test data = { 0, 0, FALSE, FALSE, &diaf, NULL };
513  int device_total = 0;
514 
515  hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, &IID_IDirectInput8A, (void **)&pDI, NULL);
516  if (FAILED(hr))
517  {
518  win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr);
519  return;
520  }
521 
522  memset (&diaf, 0, sizeof(diaf));
523  diaf.dwSize = sizeof(diaf);
524  diaf.dwActionSize = sizeof(DIACTIONA);
526  diaf.dwDataSize = 4 * diaf.dwNumActions;
527  diaf.rgoAction = actionMapping;
529  diaf.dwGenre = 0x01000000; /* DIVIRTUAL_DRIVING_RACE */
530  diaf.dwBufferSize = 32;
531 
532  /* Test enumerating all attached and installed devices */
533  data.keyboard = FALSE;
534  data.mouse = FALSE;
535  data.device_count = 0;
537  ok (data.device_count > 0, "EnumDevicesBySemantics did not call the callback hr=%08x\n", hr);
538  ok (data.keyboard, "EnumDevicesBySemantics should enumerate the keyboard\n");
539  ok (data.mouse, "EnumDevicesBySemantics should enumerate the mouse\n");
540 
541  /* Enumerate Force feedback devices. We should get no mouse nor keyboard */
542  data.keyboard = FALSE;
543  data.mouse = FALSE;
544  data.device_count = 0;
546  ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr);
547  ok (!data.keyboard, "Keyboard should not be enumerated when asking for forcefeedback\n");
548  ok (!data.mouse, "Mouse should not be enumerated when asking for forcefeedback\n");
549 
550  /* Enumerate available devices. That is devices not owned by any user.
551  Before setting the action map for all devices we still have them available. */
552  data.device_count = 0;
554  ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr);
555  ok (data.device_count > 0, "There should be devices available before action mapping available=%d\n", data.device_count);
556 
557  /* Keep the device total */
558  device_total = data.device_count;
559 
560  /* There should be no devices for any user. No device should be enumerated with DIEDBSFL_THISUSER.
561  MSDN defines that all unowned devices are also enumerated but this doesn't seem to be happening. */
562  data.device_count = 0;
564  ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr);
565  ok (data.device_count == 0, "No devices should be assigned for this user assigned=%d\n", data.device_count);
566 
567  /* This enumeration builds and sets the action map for all devices with a NULL username */
569  ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed: hr=%08x\n", hr);
570 
571  /* After a successful action mapping we should have no devices available */
572  data.device_count = 0;
574  ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr);
575  ok (data.device_count == 0, "No device should be available after action mapping available=%d\n", data.device_count);
576 
577  /* Now we'll give all the devices to a specific user */
578  data.username = "Sh4d0w M4g3";
580  ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed: hr=%08x\n", hr);
581 
582  /* Testing with the default user, DIEDBSFL_THISUSER has no effect */
583  data.device_count = 0;
585  ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr);
586  ok (data.device_count == device_total, "THISUSER has no effect with NULL username owned=%d, expected=%d\n", data.device_count, device_total);
587 
588  /* Using an empty user string is the same as passing NULL, DIEDBSFL_THISUSER has no effect */
589  data.device_count = 0;
591  ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr);
592  ok (data.device_count == device_total, "THISUSER has no effect with \"\" as username owned=%d, expected=%d\n", data.device_count, device_total);
593 
594  /* Testing with a user with no ownership of the devices */
595  data.device_count = 0;
597  ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr);
598  ok (data.device_count == 0, "This user should own no devices owned=%d\n", data.device_count);
599 
600  /* Sh4d0w M4g3 has ownership of all devices */
601  data.device_count = 0;
603  ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr);
604  ok (data.device_count == device_total, "This user should own %d devices owned=%d\n", device_total, data.device_count);
605 
606  /* The call fails with a zeroed GUID */
607  memset(&diaf.guidActionMap, 0, sizeof(GUID));
608  data.device_count = 0;
610  todo_wine ok(FAILED(hr), "EnumDevicesBySemantics succeeded with invalid GUID hr=%08x\n", hr);
611 
613 }
DWORD dwBufferSize
Definition: dinput.h:1315
HRESULT hr
Definition: shlfolder.c:183
DWORD dwNumActions
Definition: dinput.h:1311
HINSTANCE hInstance
Definition: dinput.c:29
static const GUID ACTION_MAPPING_GUID
Definition: device.c:39
static DIACTIONA actionMapping[]
Definition: dinput.c:450
#define DIRECTINPUT_VERSION
Definition: dinput.c:19
DWORD dwDataSize
Definition: dinput.h:1310
static BOOL CALLBACK set_action_map_callback(const DIDEVICEINSTANCEA *lpddi, IDirectInputDevice8A *lpdid, DWORD dwFlags, DWORD dwRemaining, void *context)
Definition: dinput.c:490
#define DIEDBSFL_FORCEFEEDBACK
Definition: dinput.h:452
HRESULT WINAPI DECLSPEC_HOTPATCH DirectInput8Create(HINSTANCE hinst, DWORD version, REFIID iid, void **out, IUnknown *outer)
Definition: dinput_main.c:172
#define FALSE
Definition: types.h:117
struct _DIACTIONA DIACTIONA
static BOOL CALLBACK enum_semantics_callback(const DIDEVICEINSTANCEA *lpddi, IDirectInputDevice8A *lpdid, DWORD dwFlags, DWORD dwRemaining, void *context)
Definition: dinput.c:469
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:79
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define todo_wine
Definition: test.h:162
#define IDirectInput8_EnumDevicesBySemantics(p, a, b, c, d, e)
Definition: dinput.h:2519
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
DWORD dwActionSize
Definition: dinput.h:1309
#define DIEDBSFL_AVAILABLEDEVICES
Definition: dinput.h:453
LPDIACTIONA rgoAction
Definition: dinput.h:1312
#define DIEDBSFL_THISUSER
Definition: dinput.h:451
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:149
#define DIEDBSFL_ATTACHEDONLY
Definition: dinput.h:450
#define SUCCEEDED(hr)
Definition: intsafe.h:49
#define IDirectInput8_Release(p)
Definition: dinput.h:2511
GUID guidActionMap
Definition: dinput.h:1313

Referenced by START_TEST().

◆ test_GetDeviceStatus()

static void test_GetDeviceStatus ( void  )
static

Definition at line 615 of file dinput.c.

616 {
617  IDirectInput8A *pDI;
618  HRESULT hr;
619 
620  hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, &IID_IDirectInput8A, (void **)&pDI, NULL);
621  if (FAILED(hr))
622  {
623  win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr);
624  return;
625  }
626 
628  ok(hr == E_POINTER, "IDirectInput8_GetDeviceStatus returned 0x%08x\n", hr);
629 
630  hr = IDirectInput8_GetDeviceStatus(pDI, &GUID_Unknown);
631  todo_wine
632  ok(hr == DIERR_DEVICENOTREG, "IDirectInput8_GetDeviceStatus returned 0x%08x\n", hr);
633 
634  hr = IDirectInput8_GetDeviceStatus(pDI, &GUID_SysMouse);
635  ok(hr == DI_OK, "IDirectInput8_GetDeviceStatus returned 0x%08x\n", hr);
636 
638 }
HRESULT hr
Definition: shlfolder.c:183
HINSTANCE hInstance
Definition: dinput.c:29
#define DIRECTINPUT_VERSION
Definition: dinput.c:19
HRESULT WINAPI DECLSPEC_HOTPATCH DirectInput8Create(HINSTANCE hinst, DWORD version, REFIID iid, void **out, IUnknown *outer)
Definition: dinput_main.c:172
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:79
#define DIERR_DEVICENOTREG
Definition: dinput.h:147
#define todo_wine
Definition: test.h:162
#define IDirectInput8_GetDeviceStatus(p, a)
Definition: dinput.h:2515
#define ok(value,...)
Definition: atltest.h:57
#define DI_OK
Definition: dinput.h:128
#define E_POINTER
Definition: winerror.h:2365
#define win_skip
Definition: test.h:149
#define IDirectInput8_Release(p)
Definition: dinput.h:2511

Referenced by START_TEST().

◆ test_Initialize()

static void test_Initialize ( void  )
static

Definition at line 673 of file dinput.c.

674 {
675  IDirectInput8A *pDI;
676  HRESULT hr;
677 
678  hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, &IID_IDirectInput8A, (void **)&pDI, NULL);
679  if (FAILED(hr))
680  {
681  win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr);
682  return;
683  }
684 
685  hr = IDirectInput8_Initialize(pDI, NULL, 0);
686  ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_Initialize returned 0x%08x\n", hr);
687 
689  ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_Initialize returned 0x%08x\n", hr);
690 
692  ok(hr == DIERR_NOTINITIALIZED, "IDirectInput8_Initialize returned 0x%08x\n", hr);
693 
694  /* Invalid DirectInput versions less than DIRECTINPUT_VERSION yield DIERR_BETADIRECTINPUTVERSION. */
696  ok(hr == DIERR_BETADIRECTINPUTVERSION, "IDirectInput8_Initialize returned 0x%08x\n", hr);
697 
698  /* Invalid DirectInput versions greater than DIRECTINPUT_VERSION yield DIERR_BETADIRECTINPUTVERSION. */
700  ok(hr == DIERR_OLDDIRECTINPUTVERSION, "IDirectInput8_Initialize returned 0x%08x\n", hr);
701 
703  ok(hr == DI_OK, "IDirectInput8_Initialize returned 0x%08x\n", hr);
704 
705  /* Parameters are still validated after successful initialization. */
707  ok(hr == DIERR_NOTINITIALIZED, "IDirectInput8_Initialize returned 0x%08x\n", hr);
708 
710 }
#define DIERR_NOTINITIALIZED
Definition: dinput.h:157
HRESULT hr
Definition: shlfolder.c:183
HINSTANCE hInstance
Definition: dinput.c:29
#define DIRECTINPUT_VERSION
Definition: dinput.c:19
HRESULT WINAPI DECLSPEC_HOTPATCH DirectInput8Create(HINSTANCE hinst, DWORD version, REFIID iid, void **out, IUnknown *outer)
Definition: dinput_main.c:172
smooth NULL
Definition: ftsmooth.c:416
#define IDirectInput8_Initialize(p, a, b)
Definition: dinput.h:2517
#define DIERR_INVALIDPARAM
Definition: dinput.h:152
#define DIERR_OLDDIRECTINPUTVERSION
Definition: dinput.h:141
LONG HRESULT
Definition: typedefs.h:79
#define ok(value,...)
Definition: atltest.h:57
#define DI_OK
Definition: dinput.h:128
#define win_skip
Definition: test.h:149
#define DIERR_BETADIRECTINPUTVERSION
Definition: dinput.h:143
#define IDirectInput8_Release(p)
Definition: dinput.h:2511

Referenced by START_TEST().

◆ test_preinitialization()

static void test_preinitialization ( void  )
static

Definition at line 37 of file dinput.c.

38 {
39  static const struct
40  {
41  REFGUID rguid;
42  BOOL pdev;
43  HRESULT expected_hr;
44  } create_device_tests[] =
45  {
46  {NULL, FALSE, E_POINTER},
47  {NULL, TRUE, E_POINTER},
48  {&GUID_Unknown, FALSE, E_POINTER},
49  {&GUID_Unknown, TRUE, DIERR_NOTINITIALIZED},
50  {&GUID_SysMouse, FALSE, E_POINTER},
51  {&GUID_SysMouse, TRUE, DIERR_NOTINITIALIZED},
52  };
53 
54  static const struct
55  {
56  DWORD dwDevType;
57  LPDIENUMDEVICESCALLBACKA lpCallback;
58  DWORD dwFlags;
59  HRESULT expected_hr;
60  int todo;
61  } enum_devices_tests[] =
62  {
63  {0, NULL, 0, DIERR_INVALIDPARAM},
64  {0, NULL, ~0u, DIERR_INVALIDPARAM},
67  {0xdeadbeef, NULL, 0, DIERR_INVALIDPARAM},
68  {0xdeadbeef, NULL, ~0u, DIERR_INVALIDPARAM},
69  {0xdeadbeef, dummy_callback, 0, DIERR_INVALIDPARAM},
70  {0xdeadbeef, dummy_callback, ~0u, DIERR_INVALIDPARAM},
71  };
72 
73  IDirectInput8A *pDI;
74  HRESULT hr;
75  int i;
76  IDirectInputDevice8A *pDID;
77 
78  hr = CoCreateInstance(&CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectInput8A, (void **)&pDI);
79  if (FAILED(hr))
80  {
81  skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr);
82  return;
83  }
84 
85  for (i = 0; i < ARRAY_SIZE(create_device_tests); i++)
86  {
87  if (create_device_tests[i].pdev) pDID = (void *)0xdeadbeef;
88  hr = IDirectInput8_CreateDevice(pDI, create_device_tests[i].rguid,
89  create_device_tests[i].pdev ? &pDID : NULL,
90  NULL);
91  ok(hr == create_device_tests[i].expected_hr, "[%d] IDirectInput8_CreateDevice returned 0x%08x\n", i, hr);
92  if (create_device_tests[i].pdev)
93  ok(pDID == NULL, "[%d] Output interface pointer is %p\n", i, pDID);
94  }
95 
96  for (i = 0; i < ARRAY_SIZE(enum_devices_tests); i++)
97  {
98  hr = IDirectInput8_EnumDevices(pDI, enum_devices_tests[i].dwDevType,
99  enum_devices_tests[i].lpCallback,
100  NULL,
101  enum_devices_tests[i].dwFlags);
102  todo_wine_if(enum_devices_tests[i].todo)
103  ok(hr == enum_devices_tests[i].expected_hr, "[%d] IDirectInput8_EnumDevice returned 0x%08x\n", i, hr);
104  }
105 
107  ok(hr == E_POINTER, "IDirectInput8_GetDeviceStatus returned 0x%08x\n", hr);
108 
109  hr = IDirectInput8_GetDeviceStatus(pDI, &GUID_Unknown);
110  ok(hr == DIERR_NOTINITIALIZED, "IDirectInput8_GetDeviceStatus returned 0x%08x\n", hr);
111 
112  hr = IDirectInput8_GetDeviceStatus(pDI, &GUID_SysMouse);
113  ok(hr == DIERR_NOTINITIALIZED, "IDirectInput8_GetDeviceStatus returned 0x%08x\n", hr);
114 
116  ok(hr == DIERR_NOTINITIALIZED, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr);
117 
119  ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr);
120 
121  hr = IDirectInput8_RunControlPanel(pDI, (HWND)0xdeadbeef, 0);
122  ok(hr == E_HANDLE, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr);
123 
124  hr = IDirectInput8_RunControlPanel(pDI, (HWND)0xdeadbeef, ~0u);
125  ok(hr == E_HANDLE, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr);
126 
128 }
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 * u
Definition: glfuncs.h:240
#define DIERR_NOTINITIALIZED
Definition: dinput.h:157
#define IDirectInput8_RunControlPanel(p, a, b)
Definition: dinput.h:2516
#define E_HANDLE
Definition: winerror.h:2850
HRESULT hr
Definition: shlfolder.c:183
Definition: scsiwmi.h:51
#define TRUE
Definition: types.h:120
BOOL todo
Definition: filedlg.c:313
#define IDirectInput8_CreateDevice(p, a, b, c)
Definition: dinput.h:2513
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 FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define todo_wine_if(is_todo)
Definition: test.h:163
#define DIERR_INVALIDPARAM
Definition: dinput.h:152
LONG HRESULT
Definition: typedefs.h:79
BOOL(CALLBACK * LPDIENUMDEVICESCALLBACKA)(LPCDIDEVICEINSTANCEA, LPVOID)
Definition: dinput.h:441
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define IDirectInput8_GetDeviceStatus(p, a)
Definition: dinput.h:2515
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define E_POINTER
Definition: winerror.h:2365
static BOOL CALLBACK dummy_callback(const DIDEVICEINSTANCEA *instance, void *context)
Definition: dinput.c:31
#define IDirectInput8_EnumDevices(p, a, b, c, d)
Definition: dinput.h:2514
#define IDirectInput8_Release(p)
Definition: dinput.h:2511

Referenced by START_TEST().

◆ test_QueryInterface()

static void test_QueryInterface ( void  )
static

Definition at line 221 of file dinput.c.

222 {
223  static REFIID iid_list[] = {&IID_IUnknown, &IID_IDirectInput8A, &IID_IDirectInput8W, &IID_IDirectInputJoyConfig8};
224 
225  static REFIID no_interface_list[] =
226  {
227  &IID_IDirectInputA,
228  &IID_IDirectInputW,
229  &IID_IDirectInput2A,
230  &IID_IDirectInput2W,
231  &IID_IDirectInput7A,
232  &IID_IDirectInput7W,
233  &IID_IDirectInputDeviceA,
234  &IID_IDirectInputDeviceW,
235  &IID_IDirectInputDevice2A,
236  &IID_IDirectInputDevice2W,
237  &IID_IDirectInputDevice7A,
238  &IID_IDirectInputDevice7W,
239  &IID_IDirectInputDevice8A,
240  &IID_IDirectInputDevice8W,
241  &IID_IDirectInputEffect,
242  };
243 
244  IDirectInput8A *pDI;
245  HRESULT hr;
246  IUnknown *pUnk;
247  int i;
248 
249  hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, &IID_IDirectInput8A, (void **)&pDI, NULL);
250  if (FAILED(hr))
251  {
252  win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr);
253  return;
254  }
255 
257  ok(hr == E_POINTER, "IDirectInput8_QueryInterface returned 0x%08x\n", hr);
258 
259  pUnk = (void *)0xdeadbeef;
260  hr = IDirectInput8_QueryInterface(pDI, NULL, (void **)&pUnk);
261  ok(hr == E_POINTER, "IDirectInput8_QueryInterface returned 0x%08x\n", hr);
262  ok(pUnk == (void *)0xdeadbeef, "Output interface pointer is %p\n", pUnk);
263 
265  ok(hr == E_POINTER, "IDirectInput8_QueryInterface returned 0x%08x\n", hr);
266 
267  for (i = 0; i < ARRAY_SIZE(iid_list); i++)
268  {
269  pUnk = NULL;
270  hr = IDirectInput8_QueryInterface(pDI, iid_list[i], (void **)&pUnk);
271  ok(hr == S_OK, "[%d] IDirectInput8_QueryInterface returned 0x%08x\n", i, hr);
272  ok(pUnk != NULL, "[%d] Output interface pointer is NULL\n", i);
273  if (pUnk)
274  {
275  int j;
276  for (j = 0; j < ARRAY_SIZE(iid_list); j++)
277  {
278  IUnknown *pUnk1 = NULL;
279  hr = IDirectInput8_QueryInterface(pUnk, iid_list[j], (void **)&pUnk1);
280  ok(hr == S_OK, "[%d] IDirectInput8_QueryInterface(pUnk) returned 0x%08x\n", j, hr);
281  ok(pUnk1 != NULL, "[%d] Output interface pointer is NULL\n", i);
282  if (pUnk1) IUnknown_Release(pUnk1);
283  }
284  IUnknown_Release(pUnk);
285  }
286  }
287 
288  for (i = 0; i < ARRAY_SIZE(no_interface_list); i++)
289  {
290  pUnk = (void *)0xdeadbeef;
291  hr = IDirectInput8_QueryInterface(pDI, no_interface_list[i], (void **)&pUnk);
292 
293  ok(hr == E_NOINTERFACE, "[%d] IDirectInput8_QueryInterface returned 0x%08x\n", i, hr);
294  ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk);
295  }
296 
298 }
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT hr
Definition: shlfolder.c:183
HINSTANCE hInstance
Definition: dinput.c:29
#define DIRECTINPUT_VERSION
Definition: dinput.c:19
HRESULT WINAPI DECLSPEC_HOTPATCH DirectInput8Create(HINSTANCE hinst, DWORD version, REFIID iid, void **out, IUnknown *outer)
Definition: dinput_main.c:172
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 IDirectInput8_QueryInterface(p, a, b)
Definition: dinput.h:2509
smooth NULL
Definition: ftsmooth.c:416
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 j
Definition: glfuncs.h:250
LONG HRESULT
Definition: typedefs.h:79
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:51
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
#define E_POINTER
Definition: winerror.h:2365
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
#define win_skip
Definition: test.h:149
static REFIID
Definition: dinput.c:53
#define IDirectInput8_Release(p)
Definition: dinput.h:2511

Referenced by START_TEST().

◆ test_RunControlPanel()

static void test_RunControlPanel ( void  )
static

Definition at line 640 of file dinput.c.

641 {
642  IDirectInput8A *pDI;
643  HRESULT hr;
644 
645  hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, &IID_IDirectInput8A, (void **)&pDI, NULL);
646  if (FAILED(hr))
647  {
648  win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr);
649  return;
650  }
651 
653  {
655  ok(hr == S_OK, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr);
656 
658  ok(hr == S_OK, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr);
659  }
660 
662  ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr);
663 
664  hr = IDirectInput8_RunControlPanel(pDI, (HWND)0xdeadbeef, 0);
665  ok(hr == E_HANDLE, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr);
666 
667  hr = IDirectInput8_RunControlPanel(pDI, (HWND)0xdeadbeef, ~0u);
668  ok(hr == E_HANDLE, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr);
669 
671 }
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 * u
Definition: glfuncs.h:240
#define IDirectInput8_RunControlPanel(p, a, b)
Definition: dinput.h:2516
#define E_HANDLE
Definition: winerror.h:2850
HRESULT hr
Definition: shlfolder.c:183
HINSTANCE hInstance
Definition: dinput.c:29
int winetest_interactive
#define DIRECTINPUT_VERSION
Definition: dinput.c:19
HRESULT WINAPI DECLSPEC_HOTPATCH DirectInput8Create(HINSTANCE hinst, DWORD version, REFIID iid, void **out, IUnknown *outer)
Definition: dinput_main.c:172
smooth NULL
Definition: ftsmooth.c:416
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:656
#define DIERR_INVALIDPARAM
Definition: dinput.h:152
LONG HRESULT
Definition: typedefs.h:79
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57
#define win_skip
Definition: test.h:149
#define IDirectInput8_Release(p)
Definition: dinput.h:2511

Referenced by START_TEST().

Variable Documentation

◆ actionMapping

DIACTIONA actionMapping[]
static
Initial value:
=
{
{ 0, 0x01008A01 , 0, { "Steer.\0" } },
{ 1, 0x01000C01 , 0, { "Upshift.\0" } },
{ 2, DIKEYBOARD_SPACE, 0, { "Missile.\0" } },
{ 3, DIMOUSE_BUTTON0, 0, { "Select\0" } },
{ 4, DIMOUSE_YAXIS, 0, { "Y Axis\0" } }
}
#define DIMOUSE_YAXIS
Definition: dinput.h:2143
#define DIKEYBOARD_SPACE
Definition: dinput.h:667
#define DIMOUSE_BUTTON0
Definition: dinput.h:2145

Definition at line 450 of file dinput.c.

Referenced by test_EnumDevicesBySemantics().

◆ hInstance

HINSTANCE hInstance

Definition at line 29 of file dinput.c.