ReactOS  0.4.13-dev-464-g6b95727
joystick.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004-2005 Robert Reif
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #define DIRECTINPUT_VERSION 0x0700
20 
21 #define COBJMACROS
22 #include <windows.h>
23 
24 #include <math.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 
28 #include "wine/test.h"
29 #include "windef.h"
30 #include "wingdi.h"
31 #include "dinput.h"
32 
33 typedef struct tagUserData {
34  IDirectInputA *pDI;
36 } UserData;
37 
56 };
57 
59  sizeof(DIDATAFORMAT),
60  sizeof(DIOBJECTDATAFORMAT),
62  sizeof(DIJOYSTATE2),
65 };
66 
67 static HWND get_hwnd(void)
68 {
70  if (!hwnd)
72  return hwnd;
73 }
74 
75 typedef struct tagJoystickInfo
76 {
77  IDirectInputDeviceA *pJoystick;
83 } JoystickInfo;
84 
85 static int get_refcount(IUnknown *object)
86 {
87  IUnknown_AddRef( object );
88  return IUnknown_Release( object );
89 }
90 
91 static BOOL CALLBACK EnumAxes(const DIDEVICEOBJECTINSTANCEA *pdidoi, void *pContext)
92 {
93  HRESULT hr;
94  JoystickInfo * info = pContext;
95 
96  if (IsEqualIID(&pdidoi->guidType, &GUID_XAxis) ||
97  IsEqualIID(&pdidoi->guidType, &GUID_YAxis) ||
98  IsEqualIID(&pdidoi->guidType, &GUID_ZAxis) ||
99  IsEqualIID(&pdidoi->guidType, &GUID_RxAxis) ||
100  IsEqualIID(&pdidoi->guidType, &GUID_RyAxis) ||
101  IsEqualIID(&pdidoi->guidType, &GUID_RzAxis) ||
102  IsEqualIID(&pdidoi->guidType, &GUID_Slider))
103  {
104  DIPROPRANGE diprg;
105  DIPROPDWORD dipdw;
106 
107  diprg.diph.dwSize = sizeof(DIPROPRANGE);
108  diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
109  diprg.diph.dwHow = DIPH_BYID;
110  diprg.diph.dwObj = pdidoi->dwType;
111 
112  dipdw.diph.dwSize = sizeof(dipdw);
113  dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
114  dipdw.diph.dwHow = DIPH_BYID;
115  dipdw.diph.dwObj = pdidoi->dwType;
116 
117  hr = IDirectInputDevice_GetProperty(info->pJoystick, DIPROP_RANGE, &diprg.diph);
118  ok(SUCCEEDED(hr), "IDirectInputDevice_GetProperty() failed: %08x\n", hr);
119  ok(info->lMin == diprg.lMin && info->lMax == diprg.lMax, "Min/Max range invalid: "
120  "expected %d..%d got %d..%d\n", info->lMin, info->lMax, diprg.lMin, diprg.lMax);
121 
122  diprg.lMin = -2000;
123  diprg.lMax = +2000;
124 
126  ok(hr==E_INVALIDARG,"IDirectInputDevice_SetProperty() should have returned "
127  "E_INVALIDARG, returned: %08x\n", hr);
128 
129  hr = IDirectInputDevice_SetProperty(info->pJoystick, DIPROP_RANGE, &diprg.diph);
130  ok(hr==DI_OK,"IDirectInputDevice_SetProperty() failed: %08x\n", hr);
131 
132  /* dead zone */
134  ok(SUCCEEDED(hr), "IDirectInputDevice_GetProperty() failed: %08x\n", hr);
135  ok(info->dZone == dipdw.dwData, "deadzone invalid: expected %d got %d\n",
136  info->dZone, dipdw.dwData);
137 
138  dipdw.dwData = 123;
139 
141  ok(hr==DI_OK,"IDirectInputDevice_SetProperty() failed: %08x\n", hr);
142 
143  /* ensure DIDOI_ASPECTPOSITION is set for axes objects */
144  ok(pdidoi->dwFlags & DIDOI_ASPECTPOSITION, "Missing DIDOI_ASPECTPOSITION, flags are 0x%x\n",
145  pdidoi->dwFlags);
146 
147  info->axis++;
148  } else if (IsEqualIID(&pdidoi->guidType, &GUID_POV))
149  info->pov++;
150  else if (IsEqualIID(&pdidoi->guidType, &GUID_Button))
151  info->button++;
152 
153  return DIENUM_CONTINUE;
154 }
155 
156 static const struct effect_id
157 {
158  const GUID *guid;
159  int dieft;
160  const char *name;
161 } effect_conversion[] = {
162  {&GUID_ConstantForce, DIEFT_CONSTANTFORCE, "Constant"},
163  {&GUID_RampForce, DIEFT_RAMPFORCE, "Ramp"},
164  {&GUID_Square, DIEFT_PERIODIC, "Square"},
165  {&GUID_Sine, DIEFT_PERIODIC, "Sine"},
166  {&GUID_Triangle, DIEFT_PERIODIC, "Triangle"},
167  {&GUID_SawtoothUp, DIEFT_PERIODIC, "Saw Tooth Up"},
168  {&GUID_SawtoothDown, DIEFT_PERIODIC, "Saw Tooth Down"},
169  {&GUID_Spring, DIEFT_CONDITION, "Spring"},
170  {&GUID_Damper, DIEFT_CONDITION, "Damper"},
171  {&GUID_Inertia, DIEFT_CONDITION, "Inertia"},
172  {&GUID_Friction, DIEFT_CONDITION, "Friction"},
173  {&GUID_CustomForce, DIEFT_CUSTOMFORCE, "Custom"}
174 };
175 
176 static const struct effect_id* effect_from_guid(const GUID *guid)
177 {
178  unsigned int i;
179  for (i = 0; i < ARRAY_SIZE(effect_conversion); i++)
181  return &effect_conversion[i];
182  return NULL;
183 }
184 
186 {
190  const char *effect_name;
191 };
192 
193 /* The last enumerated effect will be used for force feedback testing */
194 static BOOL CALLBACK EnumEffects(const DIEFFECTINFOA *lpef, void *ref)
195 {
196  const struct effect_id *id = effect_from_guid(&lpef->guid);
197  static union
198  {
200  DIPERIODIC periodic;
203  } specific;
204  struct effect_enum *data = ref;
205  int type = DIDFT_GETTYPE(lpef->dwEffType);
206 
207  /* Insanity check */
208  if (!id)
209  {
210  ok(0, "unsupported effect enumerated, GUID %s!\n", wine_dbgstr_guid(&lpef->guid));
211  return DIENUM_CONTINUE;
212  }
213  trace("controller supports '%s' effect\n", id->name);
214  ok(type == id->dieft, "Invalid effect type, expected 0x%x, got 0x%x\n",
215  id->dieft, lpef->dwEffType);
216 
217  /* Can't use custom for test as we don't know the data format */
218  if (type == DIEFT_CUSTOMFORCE)
219  return DIENUM_CONTINUE;
220 
221  data->effect_count++;
222  data->effect_name = id->name;
223  data->guid = *id->guid;
224 
225  ZeroMemory(&specific, sizeof(specific));
226  switch (type)
227  {
228  case DIEFT_PERIODIC:
229  data->eff.cbTypeSpecificParams = sizeof(specific.periodic);
230  data->eff.lpvTypeSpecificParams = &specific.periodic;
231  specific.periodic.dwMagnitude = DI_FFNOMINALMAX / 2;
232  specific.periodic.dwPeriod = DI_SECONDS; /* 1 second */
233  break;
234  case DIEFT_CONSTANTFORCE:
235  data->eff.cbTypeSpecificParams = sizeof(specific.constant);
236  data->eff.lpvTypeSpecificParams = &specific.constant;
237  specific.constant.lMagnitude = DI_FFNOMINALMAX / 2;
238  break;
239  case DIEFT_RAMPFORCE:
240  data->eff.cbTypeSpecificParams = sizeof(specific.ramp);
241  data->eff.lpvTypeSpecificParams = &specific.ramp;
242  specific.ramp.lStart = -DI_FFNOMINALMAX / 2;
243  specific.ramp.lEnd = +DI_FFNOMINALMAX / 2;
244  break;
245  case DIEFT_CONDITION:
246  {
247  int i;
248  data->eff.cbTypeSpecificParams = sizeof(specific.condition);
249  data->eff.lpvTypeSpecificParams = specific.condition;
250  for (i = 0; i < 2; i++)
251  {
252  specific.condition[i].lNegativeCoefficient = -DI_FFNOMINALMAX / 2;
253  specific.condition[i].lPositiveCoefficient = +DI_FFNOMINALMAX / 2;
254  }
255  break;
256  }
257  }
258  return DIENUM_CONTINUE;
259 }
260 
261 static const HRESULT SetCoop_null_window[16] = {
266 
267 static const HRESULT SetCoop_real_window[16] = {
272 
273 static BOOL CALLBACK EnumJoysticks(const DIDEVICEINSTANCEA *lpddi, void *pvRef)
274 {
275  HRESULT hr;
276  UserData * data = pvRef;
277  IDirectInputDeviceA *pJoystick;
279  DIDEVCAPS caps;
280  DIJOYSTATE2 js;
282  int i, count;
283  ULONG ref;
284  DIDEVICEINSTANCEA inst;
285  DIDEVICEINSTANCE_DX3A inst3;
286  DIPROPDWORD dipw;
287  DIPROPSTRING dps;
288  DIPROPGUIDANDPATH dpg;
289  WCHAR nameBuffer[MAX_PATH];
290  HWND hWnd = get_hwnd();
291  char oldstate[248], curstate[248];
292  DWORD axes[2] = {DIJOFS_X, DIJOFS_Y};
293  LONG direction[2] = {0, 0};
294  LPDIRECTINPUTEFFECT effect = NULL;
295  LONG cnt1, cnt2;
296  HWND real_hWnd;
298  DIPROPDWORD dip_gain_set, dip_gain_get;
299  struct effect_enum effect_data;
300 
301  ok(data->version > 0x0300, "Joysticks not supported in version 0x%04x\n", data->version);
302 
304  ok(hr==E_POINTER,"IDirectInput_CreateDevice() should have returned "
305  "E_POINTER, returned: %08x\n", hr);
306 
307  hr = IDirectInput_CreateDevice(data->pDI, NULL, &pJoystick, NULL);
308  ok(hr==E_POINTER,"IDirectInput_CreateDevice() should have returned "
309  "E_POINTER, returned: %08x\n", hr);
310 
312  ok(hr==E_POINTER,"IDirectInput_CreateDevice() should have returned "
313  "E_POINTER, returned: %08x\n", hr);
314 
316  &pJoystick, NULL);
317  ok(hr==DI_OK,"IDirectInput_CreateDevice() failed: %08x\n", hr);
318  if (hr!=DI_OK)
319  goto DONE;
320 
321  trace("---- Controller Information ----\n"
322  "Product Name : %s\n"
323  "Instance Name : %s\n"
324  "devType : 0x%08x\n"
325  "GUID Product : %s\n"
326  "GUID Instance : %s\n"
327  "HID Page : 0x%04x\n"
328  "HID Usage : 0x%04x\n",
329  lpddi->tszProductName,
330  lpddi->tszInstanceName,
331  lpddi->dwDevType,
332  wine_dbgstr_guid(&lpddi->guidProduct),
334  lpddi->wUsagePage,
335  lpddi->wUsage);
336 
337  /* Check if this is a HID device */
338  if (lpddi->dwDevType & DIDEVTYPE_HID)
339  ok(lpddi->wUsagePage == 0x01 && (lpddi->wUsage == 0x04 || lpddi->wUsage == 0x05),
340  "Expected a game controller HID UsagePage and Usage, got page 0x%x usage 0x%x\n",
341  lpddi->wUsagePage, lpddi->wUsage);
342 
343  /* Test for joystick ID property */
344  ZeroMemory(&dipw, sizeof(dipw));
345  dipw.diph.dwSize = sizeof(DIPROPDWORD);
346  dipw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
347  dipw.diph.dwObj = 0;
348  dipw.diph.dwHow = DIPH_DEVICE;
349 
351  ok(SUCCEEDED(hr), "IDirectInputDevice_GetProperty() for DIPROP_JOYSTICKID failed\n");
352 
353  /* Test for INSTANCENAME property */
354  memset(&dps, 0, sizeof(dps));
355  dps.diph.dwSize = sizeof(DIPROPSTRING);
356  dps.diph.dwHeaderSize = sizeof(DIPROPHEADER);
357  dps.diph.dwHow = DIPH_DEVICE;
358 
360  ok(SUCCEEDED(hr), "IDirectInput_GetProperty() for DIPROP_INSTANCENAME failed: %08x\n", hr);
361 
362  /* Test if instance name is the same as present in DIDEVICEINSTANCE */
363  MultiByteToWideChar(CP_ACP, 0, lpddi->tszInstanceName, -1, nameBuffer, MAX_PATH);
364  ok(!lstrcmpW(nameBuffer, dps.wsz), "DIPROP_INSTANCENAME returned is wrong. Expected: %s Got: %s\n",
365  wine_dbgstr_w(nameBuffer), wine_dbgstr_w(dps.wsz));
366 
368  ok(SUCCEEDED(hr), "IDirectInput_GetProperty() for DIPROP_PRODUCTNAME failed: %08x\n", hr);
369 
370  /* Test if product name is the same as present in DIDEVICEINSTANCE */
371  MultiByteToWideChar(CP_ACP, 0, lpddi->tszProductName, -1, nameBuffer, MAX_PATH);
372  ok(!lstrcmpW(nameBuffer, dps.wsz), "DIPROP_PRODUCTNAME returned is wrong. Expected: %s Got: %s\n",
373  wine_dbgstr_w(nameBuffer), wine_dbgstr_w(dps.wsz));
374 
375  /* Test for GUIDPATH properties */
376  memset(&dpg, 0, sizeof(dpg));
377  dpg.diph.dwSize = sizeof(DIPROPGUIDANDPATH);
378  dpg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
379  dpg.diph.dwHow = DIPH_DEVICE;
380 
382  todo_wine ok(SUCCEEDED(hr), "IDirectInput_GetProperty() for DIPROP_GUIDANDPATH failed: %08x\n", hr);
383 
385  ok(hr==E_POINTER,"IDirectInputDevice_SetDataFormat() should have returned "
386  "E_POINTER, returned: %08x\n", hr);
387 
388  ZeroMemory(&format, sizeof(format));
390  ok(hr==DIERR_INVALIDPARAM,"IDirectInputDevice_SetDataFormat() should have "
391  "returned DIERR_INVALIDPARAM, returned: %08x\n", hr);
392 
393  /* try the default formats */
395  ok(hr==DI_OK,"IDirectInputDevice_SetDataFormat() failed: %08x\n", hr);
396 
398  ok(hr==DI_OK,"IDirectInputDevice_SetDataFormat() failed: %08x\n", hr);
399 
400  /* try an alternate format */
402  ok(hr==DI_OK,"IDirectInputDevice_SetDataFormat() failed: %08x\n", hr);
403 
405  ok(hr==DI_OK,"IDirectInputDevice_SetDataFormat() failed: %08x\n", hr);
406  if (hr != DI_OK)
407  goto RELEASE;
408 
409  for (i=0; i<16; i++)
410  {
412  ok(hr == SetCoop_null_window[i], "SetCooperativeLevel(NULL, %d): %08x\n", i, hr);
413  }
414  for (i=0; i<16; i++)
415  {
417  ok(hr == SetCoop_real_window[i], "SetCooperativeLevel(hwnd, %d): %08x\n", i, hr);
418  }
419 
422  ok(hr==DI_OK,"IDirectInputDevice_SetCooperativeLevel() failed: %08x\n", hr);
423 
424  /* get capabilities */
426  ok(hr==E_POINTER,"IDirectInputDevice_GetCapabilities() "
427  "should have returned E_POINTER, returned: %08x\n", hr);
428 
429  ZeroMemory(&caps, sizeof(caps));
430  hr = IDirectInputDevice_GetCapabilities(pJoystick, &caps);
431  ok(hr==DIERR_INVALIDPARAM,"IDirectInputDevice_GetCapabilities() "
432  "should have returned DIERR_INVALIDPARAM, returned: %08x\n", hr);
433 
434  caps.dwSize = sizeof(caps);
435  hr = IDirectInputDevice_GetCapabilities(pJoystick, &caps);
436  ok(hr==DI_OK,"IDirectInputDevice_GetCapabilities() failed: %08x\n", hr);
437 
438  ZeroMemory(&info, sizeof(info));
439  info.pJoystick = pJoystick;
440 
441  /* default min/max limits */
442  info.lMin = 0;
443  info.lMax = 0xffff;
444  /* enumerate objects */
446  ok(hr==DI_OK,"IDirectInputDevice_EnumObjects() failed: %08x\n", hr);
447 
448  ok(caps.dwAxes == info.axis, "Number of enumerated axes (%d) doesn't match capabilities (%d)\n", info.axis, caps.dwAxes);
449  ok(caps.dwButtons == info.button, "Number of enumerated buttons (%d) doesn't match capabilities (%d)\n", info.button, caps.dwButtons);
450  ok(caps.dwPOVs == info.pov, "Number of enumerated POVs (%d) doesn't match capabilities (%d)\n", info.pov, caps.dwPOVs);
451 
452  /* Set format and check limits again */
454  ok(hr==DI_OK,"IDirectInputDevice_SetDataFormat() failed: %08x\n", hr);
455  info.lMin = -2000;
456  info.lMax = +2000;
457  info.dZone= 123;
459  ok(hr==DI_OK,"IDirectInputDevice_EnumObjects() failed: %08x\n", hr);
460 
461  hr = IDirectInputDevice_GetDeviceInfo(pJoystick, 0);
462  ok(hr==E_POINTER, "IDirectInputDevice_GetDeviceInfo() "
463  "should have returned E_POINTER, returned: %08x\n", hr);
464 
465  ZeroMemory(&inst, sizeof(inst));
466  ZeroMemory(&inst3, sizeof(inst3));
467 
468  hr = IDirectInputDevice_GetDeviceInfo(pJoystick, &inst);
469  ok(hr==DIERR_INVALIDPARAM, "IDirectInputDevice_GetDeviceInfo() "
470  "should have returned DIERR_INVALIDPARAM, returned: %08x\n", hr);
471 
472  inst.dwSize = sizeof(inst);
473  hr = IDirectInputDevice_GetDeviceInfo(pJoystick, &inst);
474  ok(hr==DI_OK,"IDirectInputDevice_GetDeviceInfo() failed: %08x\n", hr);
475 
476  inst3.dwSize = sizeof(inst3);
478  ok(hr==DI_OK,"IDirectInputDevice_GetDeviceInfo() failed: %08x\n", hr);
479 
480  hr = IDirectInputDevice_Unacquire(pJoystick);
481  ok(hr == S_FALSE, "IDirectInputDevice_Unacquire() should have returned S_FALSE, got: %08x\n", hr);
482 
483  hr = IDirectInputDevice_Acquire(pJoystick);
484  ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %08x\n", hr);
485  if (hr != DI_OK)
486  goto RELEASE;
487 
488  hr = IDirectInputDevice_Acquire(pJoystick);
489  ok(hr == S_FALSE, "IDirectInputDevice_Acquire() should have returned S_FALSE, got: %08x\n", hr);
490 
491  if (info.pov < 4)
492  {
493  hr = IDirectInputDevice_GetDeviceState(pJoystick, sizeof(DIJOYSTATE2), &js);
494  ok(hr == DI_OK, "IDirectInputDevice_GetDeviceState() failed: %08x\n", hr);
495  ok(js.rgdwPOV[3] == -1, "Default for unassigned POV should be -1 not: %d\n", js.rgdwPOV[3]);
496  }
497 
498  trace("Testing force feedback\n");
499  ZeroMemory(&effect_data, sizeof(effect_data));
500  effect_data.eff.dwSize = sizeof(effect_data.eff);
502  effect_data.eff.dwDuration = INFINITE;
503  effect_data.eff.dwGain = DI_FFNOMINALMAX;
504  effect_data.eff.dwTriggerButton = DIEB_NOTRIGGER;
505  effect_data.eff.cAxes = ARRAY_SIZE(axes);
506  effect_data.eff.rgdwAxes = axes;
507  effect_data.eff.rglDirection = direction;
508 
509  /* Sending effects to joystick requires
510  * calling IDirectInputEffect_Initialize, which requires
511  * having exclusive access to the device, which requires
512  * - not having acquired the joystick when calling
513  * IDirectInputDevice_SetCooperativeLevel
514  * - a visible window
515  */
516  real_hWnd = CreateWindowExA(0, "EDIT", "Test text", 0, 10, 10, 300, 300, NULL, NULL,
517  hInstance, NULL);
518  ok(real_hWnd!=0,"CreateWindowExA failed: %p\n", real_hWnd);
519  ShowWindow(real_hWnd, SW_SHOW);
520  hr = IDirectInputDevice_Unacquire(pJoystick);
521  ok(hr==DI_OK,"IDirectInputDevice_Unacquire() failed: %08x\n", hr);
522  hr = IDirectInputDevice_SetCooperativeLevel(pJoystick, real_hWnd,
524  ok(hr==DI_OK,"IDirectInputDevice_SetCooperativeLevel() failed: %08x\n", hr);
525  hr = IDirectInputDevice_Acquire(pJoystick);
526  ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %08x\n", hr);
527 
528  cnt1 = get_refcount((IUnknown*)pJoystick);
529 
530  hr = IDirectInputDevice2_EnumEffects((IDirectInputDevice2A*)pJoystick, EnumEffects, &effect_data, DIEFT_ALL);
531  ok(hr==DI_OK,"IDirectInputDevice2_EnumEffects() failed: %08x\n", hr);
532 
533  /* If the controller does not support ANY effect use the constant effect to make
534  * CreateEffect fail but with the unsupported reason instead of invalid parameters. */
535  if (!effect_data.effect_count)
536  {
537  static DICONSTANTFORCE constant;
538  effect_data.guid = GUID_ConstantForce;
539  effect_data.eff.cbTypeSpecificParams = sizeof(constant);
540  effect_data.eff.lpvTypeSpecificParams = &constant;
541  effect_data.effect_name = "Constant";
542  constant.lMagnitude = DI_FFNOMINALMAX / 2;
543 
544  ok(!(caps.dwFlags & DIDC_FORCEFEEDBACK), "effect count is zero but controller supports force feedback?\n");
545  }
546 
547  effect = (void *)0xdeadbeef;
548  hr = IDirectInputDevice2_CreateEffect((IDirectInputDevice2A*)pJoystick, &effect_data.guid,
549  &effect_data.eff, &effect, NULL);
550  if (caps.dwFlags & DIDC_FORCEFEEDBACK)
551  {
552  trace("force feedback supported with %d effects, using '%s' for test\n",
553  effect_data.effect_count, effect_data.effect_name);
554  ok(hr == DI_OK, "IDirectInputDevice_CreateEffect() failed: %08x\n", hr);
555  cnt2 = get_refcount((IUnknown*)pJoystick);
556  ok(cnt1 == cnt2, "Ref count is wrong %d != %d\n", cnt1, cnt2);
557 
558  if (effect)
559  {
560  DWORD effect_status;
561  struct DIPROPDWORD diprop_word;
562  GUID guid = {0};
563 
564  hr = IDirectInputEffect_Initialize(effect, hInstance, data->version,
565  &effect_data.guid);
566  ok(hr==DI_OK,"IDirectInputEffect_Initialize failed: %08x\n", hr);
569  ok(hr==DI_OK,"IDirectInputEffect_SetParameters failed: %08x\n", hr);
570  if (hr==DI_OK) {
571  /* Test that upload, unacquire, acquire still permits updating
572  * uploaded effect. */
573  hr = IDirectInputDevice_Unacquire(pJoystick);
574  ok(hr==DI_OK,"IDirectInputDevice_Unacquire() failed: %08x\n", hr);
575  hr = IDirectInputDevice_Acquire(pJoystick);
576  ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %08x\n", hr);
577  hr = IDirectInputEffect_SetParameters(effect, &effect_data.eff, DIEP_GAIN);
578  ok(hr==DI_OK,"IDirectInputEffect_SetParameters failed: %08x\n", hr);
579  }
580 
581  /* Check effect status.
582  * State: initially stopped
583  * start
584  * State: started
585  * unacquire, acquire, download
586  * State: stopped
587  * start
588  * State: started
589  *
590  * Shows that:
591  * - effects are stopped after Unacquire + Acquire
592  * - effects are preserved (Download + Start doesn't complain
593  * about incomplete effect)
594  */
596  ok(hr==E_POINTER,"IDirectInputEffect_GetEffectStatus() must fail with E_POINTER, got: %08x\n", hr);
597  effect_status = 0xdeadbeef;
598  hr = IDirectInputEffect_GetEffectStatus(effect, &effect_status);
599  ok(hr==DI_OK,"IDirectInputEffect_GetEffectStatus() failed: %08x\n", hr);
600  ok(effect_status==0,"IDirectInputEffect_GetEffectStatus() reported effect as started\n");
601  hr = IDirectInputEffect_SetParameters(effect, &effect_data.eff, DIEP_START);
602  ok(hr==DI_OK,"IDirectInputEffect_SetParameters failed: %08x\n", hr);
603  hr = IDirectInputEffect_GetEffectStatus(effect, &effect_status);
604  ok(hr==DI_OK,"IDirectInputEffect_GetEffectStatus() failed: %08x\n", hr);
605  todo_wine ok(effect_status!=0,"IDirectInputEffect_GetEffectStatus() reported effect as stopped\n");
606  hr = IDirectInputDevice_Unacquire(pJoystick);
607  ok(hr==DI_OK,"IDirectInputDevice_Unacquire() failed: %08x\n", hr);
608  hr = IDirectInputDevice_Acquire(pJoystick);
609  ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %08x\n", hr);
611  ok(hr==DI_OK,"IDirectInputEffect_Download() failed: %08x\n", hr);
612  hr = IDirectInputEffect_GetEffectStatus(effect, &effect_status);
613  ok(hr==DI_OK,"IDirectInputEffect_GetEffectStatus() failed: %08x\n", hr);
614  ok(effect_status==0,"IDirectInputEffect_GetEffectStatus() reported effect as started\n");
615  hr = IDirectInputEffect_Start(effect, 1, 0);
616  ok(hr==DI_OK,"IDirectInputEffect_Start() failed: %08x\n", hr);
617  hr = IDirectInputEffect_GetEffectStatus(effect, &effect_status);
618  ok(hr==DI_OK,"IDirectInputEffect_GetEffectStatus() failed: %08x\n", hr);
619  Sleep(250); /* feel the magic */
620  todo_wine ok(effect_status!=0,"IDirectInputEffect_GetEffectStatus() reported effect as stopped\n");
622  ok(hr==DI_OK,"IDirectInputEffect_GetEffectGuid() failed: %08x\n", hr);
623  ok(IsEqualGUID(&effect_data.guid, &guid), "Wrong guid returned\n");
624 
625  /* Check autocenter status
626  * State: initially stopped
627  * enable
628  * State: enabled
629  * acquire
630  * State: enabled
631  * unacquire
632  * State: enabled
633  *
634  * IDirectInputDevice2_SetProperty(DIPROP_AUTOCENTER) can only be
635  * executed when the device is released.
636  *
637  * If Executed interactively, user can feel that autocenter is
638  * only disabled when the joystick is acquired.
639  */
640  diprop_word.diph.dwSize = sizeof(diprop_word);
641  diprop_word.diph.dwHeaderSize = sizeof(diprop_word.diph);
642  diprop_word.diph.dwObj = 0;
643  diprop_word.diph.dwHow = DIPH_DEVICE;
644  hr = IDirectInputDevice_Unacquire(pJoystick);
645  ok(hr==DI_OK,"IDirectInputDevice_Unacquire() failed: %08x\n", hr);
646  hr = IDirectInputDevice2_GetProperty(pJoystick, DIPROP_AUTOCENTER, &diprop_word.diph);
647  ok(hr==DI_OK,"IDirectInputDevice2_GetProperty() failed: %08x\n", hr);
648  ok(diprop_word.dwData==DIPROPAUTOCENTER_ON,"IDirectInputDevice2_GetProperty() reported autocenter as disabled\n");
649  diprop_word.dwData = DIPROPAUTOCENTER_OFF;
650  hr = IDirectInputDevice2_SetProperty(pJoystick, DIPROP_AUTOCENTER, &diprop_word.diph);
651  ok(hr==DI_OK,"IDirectInputDevice2_SetProperty() failed: %08x\n", hr);
652  hr = IDirectInputDevice2_GetProperty(pJoystick, DIPROP_AUTOCENTER, &diprop_word.diph);
653  ok(hr==DI_OK,"IDirectInputDevice2_GetProperty() failed: %08x\n", hr);
654  ok(diprop_word.dwData==DIPROPAUTOCENTER_OFF,"IDirectInputDevice2_GetProperty() reported autocenter as enabled\n");
655  if (winetest_interactive) {
656  trace("Acquiring in 2s, autocenter will be disabled.\n");
657  Sleep(2000);
658  }
659  hr = IDirectInputDevice_Acquire(pJoystick);
660  ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %08x\n", hr);
662  trace("Acquired.\n");
663  hr = IDirectInputDevice2_GetProperty(pJoystick, DIPROP_AUTOCENTER, &diprop_word.diph);
664  ok(hr==DI_OK,"IDirectInputDevice2_GetProperty() failed: %08x\n", hr);
665  ok(diprop_word.dwData==DIPROPAUTOCENTER_OFF,"IDirectInputDevice2_GetProperty() reported autocenter as enabled\n");
666  if (winetest_interactive) {
667  trace("Releasing in 2s, autocenter will be re-enabled.\n");
668  Sleep(2000);
669  }
670  hr = IDirectInputDevice_Unacquire(pJoystick);
671  ok(hr==DI_OK,"IDirectInputDevice_Unacquire() failed: %08x\n", hr);
673  trace("Released\n");
674  hr = IDirectInputDevice2_GetProperty(pJoystick, DIPROP_AUTOCENTER, &diprop_word.diph);
675  ok(hr==DI_OK,"IDirectInputDevice2_GetProperty() failed: %08x\n", hr);
676  ok(diprop_word.dwData==DIPROPAUTOCENTER_OFF,"IDirectInputDevice2_GetProperty() reported autocenter as enabled\n");
677  hr = IDirectInputDevice_Acquire(pJoystick);
678  ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %08x\n", hr);
679  hr = IDirectInputDevice2_GetProperty(pJoystick, DIPROP_AUTOCENTER, &diprop_word.diph);
680  ok(hr==DI_OK,"IDirectInputDevice2_GetProperty() failed: %08x\n", hr);
681 
682  /* Device gain (DIPROP_FFGAIN).
683  * From MSDN:
684  * 0..10000 range, otherwise DIERR_INVALIDPARAM.
685  * Can be changed even if device is acquired.
686  * Difference found by tests:
687  * <0 is refused, >10000 is accepted
688  */
689  dip_gain_set.diph.dwSize = sizeof(DIPROPDWORD);
690  dip_gain_set.diph.dwHeaderSize = sizeof(DIPROPHEADER);
691  dip_gain_set.diph.dwObj = 0;
692  dip_gain_set.diph.dwHow = DIPH_DEVICE;
693  dip_gain_get.diph.dwSize = sizeof(DIPROPDWORD);
694  dip_gain_get.diph.dwHeaderSize = sizeof(DIPROPHEADER);
695  dip_gain_get.diph.dwObj = 0;
696  dip_gain_get.diph.dwHow = DIPH_DEVICE;
697  dip_gain_get.dwData = 0;
698 
699  /* Test device is acquisition (non)impact. */
700  hr = IDirectInputDevice_Unacquire(pJoystick);
701  ok(hr == DI_OK, "IDirectInputDevice_Unacquire() should have returned S_FALSE, got: %08x\n", hr);
702  dip_gain_set.dwData = 1;
703  hr = IDirectInputDevice_SetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_set.diph);
704  ok(hr==DI_OK, "IDirectInputDevice_SetProperty() failed: %08x\n", hr);
705  hr = IDirectInputDevice_GetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_get.diph);
706  ok(hr==DI_OK, "IDirectInputDevice_GetProperty() failed: %08x\n", hr);
707  ok(dip_gain_get.dwData==dip_gain_set.dwData, "Gain not updated: %i\n", dip_gain_get.dwData);
708  hr = IDirectInputDevice_Acquire(pJoystick);
709  ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %08x\n", hr);
710  dip_gain_set.dwData = 2;
711  hr = IDirectInputDevice_SetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_set.diph);
712  ok(hr==DI_OK, "IDirectInputDevice_SetProperty() failed: %08x\n", hr);
713  hr = IDirectInputDevice_GetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_get.diph);
714  ok(hr==DI_OK, "IDirectInputDevice_GetProperty() failed: %08x\n", hr);
715  ok(dip_gain_get.dwData==dip_gain_set.dwData, "Gain not updated: %i\n", dip_gain_get.dwData);
716  /* Test range and internal clamping. */
717  dip_gain_set.dwData = -1;
718  hr = IDirectInputDevice_SetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_set.diph);
719  todo_wine ok(hr==DIERR_INVALIDPARAM, "IDirectInputDevice_SetProperty() should have returned %08x: %08x\n", DIERR_INVALIDPARAM, hr);
720  dip_gain_set.dwData = 0;
721  hr = IDirectInputDevice_SetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_set.diph);
722  ok(hr==DI_OK, "IDirectInputDevice_SetProperty() failed: %08x\n", hr);
723  hr = IDirectInputDevice_GetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_get.diph);
724  ok(hr==DI_OK, "IDirectInputDevice_GetProperty() failed: %08x\n", hr);
725  ok(dip_gain_get.dwData==dip_gain_set.dwData, "Gain not updated: %i\n", dip_gain_get.dwData);
726  dip_gain_set.dwData = 10000;
727  hr = IDirectInputDevice_SetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_set.diph);
728  ok(hr==DI_OK, "IDirectInputDevice_SetProperty() failed: %08x\n", hr);
729  hr = IDirectInputDevice_GetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_get.diph);
730  ok(hr==DI_OK, "IDirectInputDevice_GetProperty() failed: %08x\n", hr);
731  ok(dip_gain_get.dwData==dip_gain_set.dwData, "Gain not updated: %i\n", dip_gain_get.dwData);
732  /* WARNING: This call succeeds, on the contrary of what is stated on MSDN. */
733  dip_gain_set.dwData = 10001;
734  hr = IDirectInputDevice_SetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_set.diph);
735  ok(hr==DI_OK, "IDirectInputDevice_SetProperty() failed: %08x\n", hr);
736  hr = IDirectInputDevice_GetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_get.diph);
737  ok(hr==DI_OK, "IDirectInputDevice_GetProperty() failed: %08x\n", hr);
738  ok(dip_gain_get.dwData==dip_gain_set.dwData, "Gain not updated: %i\n", dip_gain_get.dwData);
739 
740  /* Test SendForceFeedbackCommand
741  * DISFFC_STOPALL - Should stop effects only
742  * DISFFC_RESET - Should stop effects and unload them (NOT release them)
743  * Tests for game Odallus (bug 41623) */
744  hr = IDirectInputDevice2_SendForceFeedbackCommand((IDirectInputDevice2A*)pJoystick, 0);
745  ok(hr==DIERR_INVALIDPARAM, "IDirectInputDevice_SendForceFeedbackCommand() failed: %08x\n", hr);
746  hr = IDirectInputDevice2_SendForceFeedbackCommand((IDirectInputDevice2A*)pJoystick, 0xFF);
747  ok(hr==DIERR_INVALIDPARAM, "IDirectInputDevice_SendForceFeedbackCommand() failed: %08x\n", hr);
748 
750  ok(hr==DI_OK,"IDirectInputEffect_Download() failed: %08x\n", hr);
751 
752  /* Send STOPALL and prove that the effect can still be started */
753  hr = IDirectInputDevice2_SendForceFeedbackCommand((IDirectInputDevice2A*)pJoystick, DISFFC_STOPALL);
754  ok(hr==DI_OK, "IDirectInputDevice_SendForceFeedbackCommand() failed: %08x\n", hr);
755  hr = IDirectInputEffect_GetEffectStatus(effect, &effect_status);
756  ok(hr==DI_OK,"IDirectInputEffect_GetEffectStatus() failed: %08x\n", hr);
757  ok(effect_status==0,"IDirectInputEffect_GetEffectStatus() reported effect as started\n");
758  hr = IDirectInputEffect_Start(effect, 1, 0);
759  ok(hr==DI_OK,"IDirectInputEffect_Start() failed: %08x\n", hr);
761  ok(hr==DI_OK,"IDirectInputEffect_GetEffectGuid() failed: %08x\n", hr);
762  ok(IsEqualGUID(&effect_data.guid, &guid), "Wrong guid returned\n");
763 
764  /* Send RESET and prove that we can still manipulate the effect, thus not released */
765  hr = IDirectInputDevice2_SendForceFeedbackCommand((IDirectInputDevice2A*)pJoystick, DISFFC_RESET);
766  ok(hr==DI_OK, "IDirectInputDevice_SendForceFeedbackCommand() failed: %08x\n", hr);
767  hr = IDirectInputEffect_GetEffectStatus(effect, &effect_status);
768  ok(hr==DIERR_NOTDOWNLOADED,"IDirectInputEffect_GetEffectStatus() failed: %08x\n", hr);
770  ok(hr==DI_OK,"IDirectInputEffect_Download() failed: %08x\n", hr);
771  hr = IDirectInputEffect_GetEffectStatus(effect, &effect_status);
772  ok(hr==DI_OK,"IDirectInputEffect_GetEffectStatus() failed: %08x\n", hr);
773  ok(effect_status==0,"IDirectInputEffect_GetEffectStatus() reported effect as started\n");
774  hr = IDirectInputEffect_Start(effect, 1, 0);
775  ok(hr==DI_OK,"IDirectInputEffect_Start() failed: %08x\n", hr);
777  ok(hr==DI_OK,"IDirectInputEffect_GetEffectGuid() failed: %08x\n", hr);
778  ok(IsEqualGUID(&effect_data.guid, &guid), "Wrong guid returned\n");
779 
780  ref = IUnknown_Release(effect);
781  ok(ref == 0, "IDirectInputDevice_Release() reference count = %d\n", ref);
782  }
783  cnt1 = get_refcount((IUnknown*)pJoystick);
784  ok(cnt1 == cnt2, "Ref count is wrong %d != %d\n", cnt1, cnt2);
785  }
786  /* No force feedback support, CreateEffect is supposed to fail. Fairy Bloom Freesia
787  * calls CreateEffect without checking the DIDC_FORCEFEEDBACK. It expects the correct
788  * error return to determine if force feedback is unsupported. */
789  else
790  {
791  trace("No force feedback support\n");
792  ok(hr==DIERR_UNSUPPORTED, "IDirectInputDevice_CreateEffect() must fail with DIERR_UNSUPPORTED, got: %08x\n", hr);
793  ok(effect == NULL, "effect must be NULL, got %p\n", effect);
794  }
795 
796  /* Before destroying the window, release joystick to revert to
797  * non-exclusive, background cooperative level. */
798  hr = IDirectInputDevice_Unacquire(pJoystick);
799  ok(hr==DI_OK,"IDirectInputDevice_Unacquire() failed: %08x\n", hr);
802  ok(hr==DI_OK,"IDirectInputDevice_SetCooperativeLevel() failed: %08x\n", hr);
803  DestroyWindow (real_hWnd);
804  hr = IDirectInputDevice_Acquire(pJoystick);
805  ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %08x\n", hr);
806 
807  if (winetest_interactive) {
808  trace("You have 30 seconds to test all axes, sliders, POVs and buttons\n");
809  count = 300;
810  } else
811  count = 1;
812 
813  trace("\n");
814  oldstate[0]='\0';
815  for (i = 0; i < count; i++) {
816  hr = IDirectInputDevice_GetDeviceState(pJoystick, sizeof(DIJOYSTATE2), &js);
817  ok(hr==DI_OK,"IDirectInputDevice_GetDeviceState() failed: %08x\n", hr);
818  if (hr != DI_OK)
819  break;
820  sprintf(curstate, "X%5d Y%5d Z%5d Rx%5d Ry%5d Rz%5d "
821  "S0%5d S1%5d POV0%5d POV1%5d POV2%5d POV3%5d "
822  "B %d %d %d %d %d %d %d %d %d %d %d %d\n",
823  js.lX, js.lY, js.lZ, js.lRx, js.lRy, js.lRz,
824  js.rglSlider[0], js.rglSlider[1],
825  js.rgdwPOV[0], js.rgdwPOV[1], js.rgdwPOV[2], js.rgdwPOV[3],
826  js.rgbButtons[0]>>7, js.rgbButtons[1]>>7, js.rgbButtons[2]>>7,
827  js.rgbButtons[3]>>7, js.rgbButtons[4]>>7, js.rgbButtons[5]>>7,
828  js.rgbButtons[6]>>7, js.rgbButtons[7]>>7, js.rgbButtons[8]>>7,
829  js.rgbButtons[9]>>7, js.rgbButtons[10]>>7, js.rgbButtons[11]>>7);
830  if (strcmp(oldstate, curstate) != 0)
831  {
832  trace("%s\n", curstate);
833  strcpy(oldstate, curstate);
834  }
835  Sleep(100);
836  }
837  trace("\n");
838 
839  hr = IDirectInputDevice_Unacquire(pJoystick);
840  ok(hr==DI_OK,"IDirectInputDevice_Unacquire() failed: %08x\n", hr);
841 
842 RELEASE:
843  ref = IDirectInputDevice_Release(pJoystick);
844  ok(ref==0,"IDirectInputDevice_Release() reference count = %d\n", ref);
845 
846 DONE:
847  return DIENUM_CONTINUE;
848 }
849 
851 {
852  HRESULT hr;
853  IDirectInputA *pDI;
854  ULONG ref;
856 
857  trace("-- Testing Direct Input Version 0x%04x --\n", version);
859  ok(hr==DI_OK||hr==DIERR_OLDDIRECTINPUTVERSION, "DirectInputCreateA() failed: %08x\n", hr);
860  if (hr==DI_OK && pDI!=0) {
861  UserData data;
862  data.pDI = pDI;
863  data.version = version;
866  ok(hr==DI_OK,"IDirectInput_EnumDevices() failed: %08x\n", hr);
867  ref = IDirectInput_Release(pDI);
868  ok(ref==0,"IDirectInput_Release() reference count = %d\n", ref);
869  } else if (hr==DIERR_OLDDIRECTINPUTVERSION)
870  trace(" Version Not Supported\n");
871 }
872 
873 START_TEST(joystick)
874 {
876 
877  joystick_tests(0x0700);
878  joystick_tests(0x0500);
879  joystick_tests(0x0300);
880 
881  CoUninitialize();
882 }
DWORD cAxes
Definition: dinput.h:1114
char * name
Definition: wpp.c:36
#define DIEP_AXES
Definition: dinput.h:1021
LONG lRx
Definition: dinput.h:1178
GUID guidInstance
Definition: dinput.h:413
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define IDirectInputDevice2_SendForceFeedbackCommand(p, a)
Definition: dinput.h:1749
#define trace(...)
Definition: kmt_test.h:217
DWORD dwDuration
Definition: dinput.h:1109
#define IDirectInputEffect_GetEffectGuid(p, a)
Definition: dinput.h:1514
#define DIEFT_CONDITION
Definition: dinput.h:998
DWORD dwSize
Definition: dinput.h:828
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
#define DIDF_ABSAXIS
Definition: dinput.h:775
#define E_HANDLE
Definition: winerror.h:2850
static const DIDATAFORMAT c_dfDIJoystickTest
Definition: joystick.c:58
HRESULT hr
Definition: shlfolder.c:183
#define DIJOFS_RZ
Definition: dinput.h:1212
#define DIPH_BYID
Definition: dinput.h:837
#define DIPROP_PRODUCTNAME
Definition: dinput.h:911
#define IDirectInputDevice_SetCooperativeLevel(p, a, b)
Definition: dinput.h:1616
static BOOL CALLBACK EnumEffects(const DIEFFECTINFOA *lpef, void *ref)
Definition: joystick.c:194
#define IDirectInputDevice_EnumObjects(p, a, b, c)
Definition: dinput.h:1607
#define IDirectInput_CreateDevice(p, a, b, c)
Definition: dinput.h:2243
#define CP_ACP
Definition: compat.h:99
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define DIEFT_PERIODIC
Definition: dinput.h:997
static const struct effect_id effect_conversion[]
#define DIEP_GAIN
Definition: dinput.h:1018
struct DIPROPGUIDANDPATH DIPROPGUIDANDPATH
#define CALLBACK
Definition: compat.h:27
#define DIJOFS_BUTTON(n)
Definition: dinput.h:1217
HWND hWnd
Definition: settings.c:17
#define wine_dbgstr_w
Definition: kernel32.h:34
#define IDirectInputDevice_GetDeviceState(p, a, b)
Definition: dinput.h:1612
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
const char * wine_dbgstr_guid(const GUID *guid)
#define ZeroMemory
Definition: winbase.h:1635
const char * effect_name
Definition: joystick.c:190
DWORD dwGain
Definition: dinput.h:1111
LPVOID lpvTypeSpecificParams
Definition: dinput.h:1119
#define DIPROP_RANGE
Definition: dinput.h:892
struct DIJOYSTATE2 DIJOYSTATE2
int winetest_interactive
static const BYTE ramp[17]
Definition: dib.c:2709
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
DWORD dwHow
Definition: dinput.h:831
#define IDirectInputDevice2_CreateEffect(p, a, b, c, d)
Definition: dinput.h:1745
BOOL WINAPI DestroyWindow(_In_ HWND)
#define IDirectInputDevice_GetProperty(p, a, b)
Definition: dinput.h:1608
Definition: send.c:47
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define DIPH_DEVICE
Definition: dinput.h:835
#define DIJOFS_X
Definition: dinput.h:1207
#define DIERR_UNSUPPORTED
Definition: dinput.h:156
#define DISCL_NONEXCLUSIVE
Definition: dinput.h:966
struct _test_info info[]
Definition: SetCursorPos.c:19
const DIDATAFORMAT c_dfDIJoystick
Definition: data_formats.c:75
struct _DIOBJECTDATAFORMAT * LPDIOBJECTDATAFORMAT
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define IDirectInputEffect_SetParameters(p, a, b)
Definition: dinput.h:1516
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
HINSTANCE hInstance
Definition: charmap.c:20
#define DIEP_TYPESPECIFICPARAMS
Definition: dinput.h:1024
DIPROPHEADER diph
Definition: dinput.h:843
const GUID * guid
int dieft
Definition: joystick.c:159
struct DIPROPRANGE DIPROPRANGE
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define DIDFT_BUTTON
Definition: dinput.h:756
GUID guid
Definition: joystick.c:188
#define DIEFT_CUSTOMFORCE
Definition: dinput.h:999
#define DI_SECONDS
Definition: dinput.h:1041
const char * name
Definition: joystick.c:160
LONG lRy
Definition: dinput.h:1179
GLenum GLint ref
Definition: glext.h:6028
DWORD dwDevType
Definition: dinput.h:415
#define ok(value,...)
DWORD dwSize
Definition: dinput.h:1107
IDirectInputA * pDI
Definition: joystick.c:34
GLenum condition
Definition: glext.h:9255
#define S_FALSE
Definition: winerror.h:2357
struct _DIDATAFORMAT DIDATAFORMAT
DWORD dwFlags
Definition: dinput.h:935
#define E_INVALIDARG
Definition: ddrawi.h:101
GUID guidProduct
Definition: dinput.h:414
static const DIOBJECTDATAFORMAT dfDIJoystickTest[]
Definition: joystick.c:38
#define DIEP_DIRECTION
Definition: dinput.h:1022
const GUID * guid
Definition: joystick.c:158
smooth NULL
Definition: ftsmooth.c:416
static const HRESULT SetCoop_null_window[16]
Definition: joystick.c:261
static const HRESULT SetCoop_real_window[16]
Definition: joystick.c:267
static const WCHAR version[]
Definition: asmname.c:64
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:622
#define IDirectInputDevice_GetCapabilities(p, a)
Definition: dinput.h:1606
DIEFFECT eff
Definition: joystick.c:187
DWORD dwAxes
Definition: dinput.h:937
DWORD dwPOVs
Definition: dinput.h:939
#define IDirectInputDevice_Release(p)
Definition: dinput.h:1604
#define SW_SHOW
Definition: winuser.h:769
static int get_refcount(IUnknown *object)
Definition: joystick.c:85
static BOOL CALLBACK EnumAxes(const DIDEVICEOBJECTINSTANCEA *pdidoi, void *pContext)
Definition: joystick.c:91
#define DISFFC_RESET
Definition: dinput.h:972
struct DIPROPSTRING DIPROPSTRING
#define DIPROP_DEADZONE
Definition: dinput.h:893
#define DIJOFS_Y
Definition: dinput.h:1208
#define DIERR_INVALIDPARAM
Definition: dinput.h:152
#define DISCL_BACKGROUND
Definition: dinput.h:968
#define IDirectInputEffect_Start(p, a, b)
Definition: dinput.h:1517
LPDWORD rgdwAxes
Definition: dinput.h:1115
DIPROPHEADER diph
Definition: dinput.h:849
#define IDirectInput_Release(p)
Definition: dinput.h:2241
#define DIDFT_ANYINSTANCE
Definition: dinput.h:760
DIPROPHEADER diph
Definition: dinput.h:867
DWORD dwSize
Definition: dinput.h:934
#define DIEFT_CONSTANTFORCE
Definition: dinput.h:995
LONG lX
Definition: dinput.h:1175
DWORD cbTypeSpecificParams
Definition: dinput.h:1118
#define DIERR_OLDDIRECTINPUTVERSION
Definition: dinput.h:141
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG lY
Definition: dinput.h:1176
#define DIDOI_ASPECTPOSITION
Definition: dinput.h:820
LONG HRESULT
Definition: typedefs.h:77
#define IDirectInputEffect_Initialize(p, a, b, c)
Definition: dinput.h:1513
DWORD dwButtons
Definition: dinput.h:938
struct tagUserData UserData
#define MAX_PATH
Definition: compat.h:26
START_TEST(joystick)
Definition: joystick.c:873
#define DIDFT_OPTIONAL
Definition: dinput.h:771
static BOOL CALLBACK EnumJoysticks(const DIDEVICEINSTANCEA *lpddi, void *pvRef)
Definition: joystick.c:273
#define DIJOFS_Z
Definition: dinput.h:1209
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD rgdwPOV[4]
Definition: dinput.h:1182
#define DIERR_NOTDOWNLOADED
Definition: dinput.h:177
WCHAR wsz[MAX_PATH]
Definition: dinput.h:875
#define DIPROP_FFGAIN
Definition: dinput.h:895
#define DIDEVTYPE_JOYSTICK
Definition: dinput.h:200
#define DISCL_FOREGROUND
Definition: dinput.h:967
struct IDirectInputEffect * LPDIRECTINPUTEFFECT
Definition: dinput.h:107
#define DIEP_START
Definition: dinput.h:1028
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
LONG lRz
Definition: dinput.h:1180
#define DIEFF_CARTESIAN
Definition: dinput.h:1012
#define DIJOFS_RX
Definition: dinput.h:1210
#define DIEB_NOTRIGGER
Definition: dinput.h:1031
#define todo_wine
Definition: test.h:154
#define DIDFT_AXIS
Definition: dinput.h:753
#define DIEFF_OBJECTOFFSETS
Definition: dinput.h:1011
DWORD dwData
Definition: dinput.h:844
CHAR tszInstanceName[MAX_PATH]
Definition: dinput.h:416
#define DIPROP_JOYSTICKID
Definition: dinput.h:912
#define DIPROP_GUIDANDPATH
Definition: dinput.h:908
LPLONG rglDirection
Definition: dinput.h:1116
#define DIEDFL_ALLDEVICES
Definition: dinput.h:190
const DIDATAFORMAT c_dfDIJoystick2
Definition: data_formats.c:251
static HWND get_hwnd(void)
Definition: joystick.c:67
#define IDirectInputDevice_SetProperty(p, a, b)
Definition: dinput.h:1609
#define IDirectInputDevice_Acquire(p)
Definition: dinput.h:1610
struct DIPROPHEADER DIPROPHEADER
#define DIPROP_AUTOCENTER
Definition: dinput.h:897
LONG rglSlider[2]
Definition: dinput.h:1181
#define S_OK
Definition: intsafe.h:59
#define DIPROPAUTOCENTER_ON
Definition: dinput.h:900
#define DIPROPAUTOCENTER_OFF
Definition: dinput.h:899
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
#define ARRAY_SIZE(a)
Definition: main.h:24
#define DIDEVTYPE_HID
Definition: dinput.h:201
#define IDirectInputDevice2_EnumEffects(p, a, b, c)
Definition: dinput.h:1746
LONG lZ
Definition: dinput.h:1177
#define IDirectInputEffect_Download(p)
Definition: dinput.h:1520
DWORD dwObj
Definition: dinput.h:830
IDirectInputDeviceA * pJoystick
Definition: joystick.c:77
#define IDirectInputDevice_SetDataFormat(p, a)
Definition: dinput.h:1614
#define IDirectInputDevice_GetDeviceInfo(p, a)
Definition: dinput.h:1618
DWORD dwTriggerButton
Definition: dinput.h:1112
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
#define IDirectInput_EnumDevices(p, a, b, c, d)
Definition: dinput.h:2244
#define MultiByteToWideChar
Definition: compat.h:100
#define IDirectInputDevice2_SetProperty(p, a, b)
Definition: dinput.h:1732
#define IDirectInputEffect_GetEffectStatus(p, a)
Definition: dinput.h:1519
DWORD version
Definition: joystick.c:35
#define DISFFC_STOPALL
Definition: dinput.h:973
DWORD dwEffType
Definition: dinput.h:1129
#define IDirectInputDevice2_GetProperty(p, a, b)
Definition: dinput.h:1731
CHAR tszProductName[MAX_PATH]
Definition: dinput.h:417
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1897
struct tagJoystickInfo JoystickInfo
int effect_count
Definition: joystick.c:189
LONG lMin
Definition: dinput.h:850
#define DI_OK
Definition: dinput.h:128
#define DIENUM_CONTINUE
Definition: dinput.h:188
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define DIEFT_RAMPFORCE
Definition: dinput.h:996
#define IDirectInputDevice_Unacquire(p)
Definition: dinput.h:1611
DWORD dwHeaderSize
Definition: dinput.h:829
unsigned int ULONG
Definition: retypes.h:1
GLenum GLuint id
Definition: glext.h:5579
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:845
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define DIJOFS_RY
Definition: dinput.h:1211
#define DIEFT_ALL
Definition: dinput.h:993
DWORD dwFlags
Definition: dinput.h:1108
LONG lMax
Definition: dinput.h:851
#define DONE
Definition: rnr20lib.h:14
#define DIDFT_ALL
Definition: dinput.h:750
DWORD button
Definition: joystick.c:80
BYTE rgbButtons[128]
Definition: dinput.h:1183
#define DI_FFNOMINALMAX
Definition: dinput.h:1040
#define DIDFT_GETTYPE(n)
Definition: dinput.h:763
static const struct effect_id * effect_from_guid(const GUID *guid)
Definition: joystick.c:176
#define E_POINTER
Definition: winerror.h:2365
#define INFINITE
Definition: serial.h:102
struct DIPROPDWORD DIPROPDWORD
#define memset(x, y, z)
Definition: compat.h:39
#define DIDC_FORCEFEEDBACK
Definition: dinput.h:951
DIPROPHEADER diph
Definition: dinput.h:874
HRESULT WINAPI DECLSPEC_HOTPATCH DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter)
Definition: dinput_main.c:227
static void joystick_tests(DWORD version)
Definition: joystick.c:850
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90
#define DISCL_EXCLUSIVE
Definition: dinput.h:965
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define DIPROP_INSTANCENAME
Definition: dinput.h:910