ReactOS  0.4.14-dev-77-gd9e7c48
joystick.c
Go to the documentation of this file.
1 /* DirectInput Generic Joystick device
2  *
3  * Copyright 1998 Marcus Meissner
4  * Copyright 1998,1999 Lionel Ulmer
5  * Copyright 2000-2001 TransGaming Technologies Inc.
6  * Copyright 2009 Aric Stewart, CodeWeavers
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22 
23 /*
24  * To Do:
25  * dead zone
26  * force feedback
27  */
28 
29 #include <stdio.h>
30 
31 #include "joystick_private.h"
32 #include "wine/debug.h"
33 #include "winreg.h"
34 
36 
37 static inline JoystickGenericImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
38 {
39  return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface), JoystickGenericImpl, base);
40 }
41 static inline JoystickGenericImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
42 {
43  return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface), JoystickGenericImpl, base);
44 }
45 static inline IDirectInputDevice8A *IDirectInputDevice8A_from_impl(JoystickGenericImpl *This)
46 {
47  return &This->base.IDirectInputDevice8A_iface;
48 }
49 static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickGenericImpl *This)
50 {
51  return &This->base.IDirectInputDevice8W_iface;
52 }
53 
55 {
56  if (IsEqualGUID(guid, &GUID_ConstantForce)) {
57  return DIEFT_CONSTANTFORCE;
58  } else if (IsEqualGUID(guid, &GUID_Square)
59  || IsEqualGUID(guid, &GUID_Sine)
60  || IsEqualGUID(guid, &GUID_Triangle)
61  || IsEqualGUID(guid, &GUID_SawtoothUp)
62  || IsEqualGUID(guid, &GUID_SawtoothDown)) {
63  return DIEFT_PERIODIC;
64  } else if (IsEqualGUID(guid, &GUID_RampForce)) {
65  return DIEFT_RAMPFORCE;
66  } else if (IsEqualGUID(guid, &GUID_Spring)
67  || IsEqualGUID(guid, &GUID_Damper)
68  || IsEqualGUID(guid, &GUID_Inertia)
69  || IsEqualGUID(guid, &GUID_Friction)) {
70  return DIEFT_CONDITION;
71  } else if (IsEqualGUID(guid, &GUID_CustomForce)) {
72  return DIEFT_CUSTOMFORCE;
73  } else {
74  WARN("GUID (%s) is not a known force type\n", _dump_dinput_GUID(guid));
75  return 0;
76  }
77 }
78 
80 {
81  if (TRACE_ON(dinput)) {
82  unsigned int i;
83  static const struct {
84  DWORD mask;
85  const char *name;
86  } flags[] = {
87 #define FE(x) { x, #x}
91  FE(DIEFF_POLAR),
93 #undef FE
94  };
95  for (i = 0; i < ARRAY_SIZE(flags); i++)
96  if (flags[i].mask & dwFlags)
97  TRACE("%s ", flags[i].name);
98  TRACE("\n");
99  }
100 }
101 
103 {
104  if (env->dwSize != sizeof(DIENVELOPE)) {
105  WARN("Non-standard DIENVELOPE structure size %d.\n", env->dwSize);
106  }
107  TRACE("Envelope has attack (level: %d time: %d), fade (level: %d time: %d)\n",
108  env->dwAttackLevel, env->dwAttackTime, env->dwFadeLevel, env->dwFadeTime);
109 }
110 
112 {
113  TRACE("Constant force has magnitude %d\n", frc->lMagnitude);
114 }
115 
117 {
118  TRACE("Periodic force has magnitude %d, offset %d, phase %d, period %d\n",
119  frc->dwMagnitude, frc->lOffset, frc->dwPhase, frc->dwPeriod);
120 }
121 
123 {
124  TRACE("Ramp force has start %d, end %d\n",
125  frc->lStart, frc->lEnd);
126 }
127 
129 {
130  TRACE("Condition has offset %d, pos/neg coefficients %d and %d, pos/neg saturations %d and %d, deadband %d\n",
133 }
134 
136 {
137  unsigned int i;
138  TRACE("Custom force uses %d channels, sample period %d. Has %d samples at %p.\n",
139  frc->cChannels, frc->dwSamplePeriod, frc->cSamples, frc->rglForceData);
140  if (frc->cSamples % frc->cChannels != 0)
141  WARN("Custom force has a non-integral samples-per-channel count!\n");
142  if (TRACE_ON(dinput)) {
143  TRACE("Custom force data (time aligned, axes in order):\n");
144  for (i = 1; i <= frc->cSamples; ++i) {
145  TRACE("%d ", frc->rglForceData[i]);
146  if (i % frc->cChannels == 0)
147  TRACE("\n");
148  }
149  }
150 }
151 
153 {
155  unsigned int i;
156 
157  TRACE("Dumping DIEFFECT structure:\n");
158  TRACE(" - dwSize: %d\n", eff->dwSize);
159  if ((eff->dwSize != sizeof(DIEFFECT)) && (eff->dwSize != sizeof(DIEFFECT_DX5))) {
160  WARN("Non-standard DIEFFECT structure size %d\n", eff->dwSize);
161  }
162  TRACE(" - dwFlags: %d\n", eff->dwFlags);
163  TRACE(" ");
165  TRACE(" - dwDuration: %d\n", eff->dwDuration);
166  TRACE(" - dwGain: %d\n", eff->dwGain);
167 
168  if (eff->dwGain > 10000)
169  WARN("dwGain is out of range (>10,000)\n");
170 
171  TRACE(" - dwTriggerButton: %d\n", eff->dwTriggerButton);
172  TRACE(" - dwTriggerRepeatInterval: %d\n", eff->dwTriggerRepeatInterval);
173  TRACE(" - rglDirection: %p\n", eff->rglDirection);
174  TRACE(" - cbTypeSpecificParams: %d\n", eff->cbTypeSpecificParams);
175  TRACE(" - lpvTypeSpecificParams: %p\n", eff->lpvTypeSpecificParams);
176 
177  /* Only trace some members if dwFlags indicates they have data */
178  if (dwFlags & DIEP_AXES) {
179  TRACE(" - cAxes: %d\n", eff->cAxes);
180  TRACE(" - rgdwAxes: %p\n", eff->rgdwAxes);
181 
182  if (TRACE_ON(dinput) && eff->rgdwAxes) {
183  TRACE(" ");
184  for (i = 0; i < eff->cAxes; ++i)
185  TRACE("%d ", eff->rgdwAxes[i]);
186  TRACE("\n");
187  }
188  }
189 
190  if (dwFlags & DIEP_ENVELOPE) {
191  TRACE(" - lpEnvelope: %p\n", eff->lpEnvelope);
192  if (eff->lpEnvelope != NULL)
194  }
195 
196  if (eff->dwSize > sizeof(DIEFFECT_DX5))
197  TRACE(" - dwStartDelay: %d\n", eff->dwStartDelay);
198 
199  if (type == DIEFT_CONSTANTFORCE) {
200  if (eff->cbTypeSpecificParams != sizeof(DICONSTANTFORCE)) {
201  WARN("Effect claims to be a constant force but the type-specific params are the wrong size!\n");
202  } else {
204  }
205  } else if (type == DIEFT_PERIODIC) {
206  if (eff->cbTypeSpecificParams != sizeof(DIPERIODIC)) {
207  WARN("Effect claims to be a periodic force but the type-specific params are the wrong size!\n");
208  } else {
210  }
211  } else if (type == DIEFT_RAMPFORCE) {
212  if (eff->cbTypeSpecificParams != sizeof(DIRAMPFORCE)) {
213  WARN("Effect claims to be a ramp force but the type-specific params are the wrong size!\n");
214  } else {
216  }
217  } else if (type == DIEFT_CONDITION) {
218  if (eff->cbTypeSpecificParams == sizeof(DICONDITION)) {
220  } else if (eff->cbTypeSpecificParams == 2 * sizeof(DICONDITION)) {
224  } else {
225  WARN("Effect claims to be a condition but the type-specific params are the wrong size!\n");
226  }
227  } else if (type == DIEFT_CUSTOMFORCE) {
228  if (eff->cbTypeSpecificParams != sizeof(DICUSTOMFORCE)) {
229  WARN("Effect claims to be a custom force but the type-specific params are the wrong size!\n");
230  } else {
232  }
233  }
234 }
235 
237 {
238  static const char disabled_str[] = "disabled";
239  static const char joystick_key[] = "Joysticks";
240  char buffer[MAX_PATH];
241  HKEY hkey, appkey, temp;
242  BOOL do_disable = FALSE;
243 
244  get_app_key(&hkey, &appkey);
245 
246  /* Joystick settings are in the 'joysticks' subkey */
247  if (appkey)
248  {
249  if (RegOpenKeyA(appkey, joystick_key, &temp)) temp = 0;
250  RegCloseKey(appkey);
251  appkey = temp;
252  }
253  if (hkey)
254  {
255  if (RegOpenKeyA(hkey, joystick_key, &temp)) temp = 0;
256  RegCloseKey(hkey);
257  hkey = temp;
258  }
259 
260  /* Look for the "controllername"="disabled" key */
261  if (!get_config_key(hkey, appkey, name, buffer, sizeof(buffer)))
262  if (!strcmp(disabled_str, buffer))
263  {
264  TRACE("Disabling joystick '%s' based on registry key.\n", name);
265  do_disable = TRUE;
266  }
267 
268  if (appkey) RegCloseKey(appkey);
269  if (hkey) RegCloseKey(hkey);
270 
271  return do_disable;
272 }
273 
274 /******************************************************************************
275  * SetProperty : change input device properties
276  */
278 {
280  DWORD i;
281  ObjProps remap_props;
282 
283  TRACE("(%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
284 
285  if (ph == NULL) {
286  WARN("invalid parameter: ph == NULL\n");
287  return DIERR_INVALIDPARAM;
288  }
289 
290  if (TRACE_ON(dinput))
291  _dump_DIPROPHEADER(ph);
292 
293  if (IS_DIPROP(rguid)) {
294  switch (LOWORD(rguid)) {
295  case (DWORD_PTR)DIPROP_RANGE: {
297  if (ph->dwHow == DIPH_DEVICE) {
298 
299  /* Many games poll the joystick immediately after setting the range
300  * for calibration purposes, so the old values need to be remapped
301  * to the new range before it does so */
302 
303  TRACE("proprange(%d,%d) all\n", pr->lMin, pr->lMax);
304  for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++) {
305 
306  remap_props.lDevMin = This->props[i].lMin;
307  remap_props.lDevMax = This->props[i].lMax;
308 
309  remap_props.lDeadZone = This->props[i].lDeadZone;
310  remap_props.lSaturation = This->props[i].lSaturation;
311 
312  remap_props.lMin = pr->lMin;
313  remap_props.lMax = pr->lMax;
314 
315  switch (This->base.data_format.wine_df->rgodf[i].dwOfs) {
316  case DIJOFS_X : This->js.lX = joystick_map_axis(&remap_props, This->js.lX); break;
317  case DIJOFS_Y : This->js.lY = joystick_map_axis(&remap_props, This->js.lY); break;
318  case DIJOFS_Z : This->js.lZ = joystick_map_axis(&remap_props, This->js.lZ); break;
319  case DIJOFS_RX : This->js.lRx = joystick_map_axis(&remap_props, This->js.lRx); break;
320  case DIJOFS_RY : This->js.lRy = joystick_map_axis(&remap_props, This->js.lRy); break;
321  case DIJOFS_RZ : This->js.lRz = joystick_map_axis(&remap_props, This->js.lRz); break;
322  case DIJOFS_SLIDER(0): This->js.rglSlider[0] = joystick_map_axis(&remap_props, This->js.rglSlider[0]); break;
323  case DIJOFS_SLIDER(1): This->js.rglSlider[1] = joystick_map_axis(&remap_props, This->js.rglSlider[1]); break;
324  default: break;
325  }
326 
327  This->props[i].lMin = pr->lMin;
328  This->props[i].lMax = pr->lMax;
329  }
330  } else {
331  int obj = find_property(&This->base.data_format, ph);
332 
333  TRACE("proprange(%d,%d) obj=%d\n", pr->lMin, pr->lMax, obj);
334  if (obj >= 0) {
335 
336  remap_props.lDevMin = This->props[obj].lMin;
337  remap_props.lDevMax = This->props[obj].lMax;
338 
339  remap_props.lDeadZone = This->props[obj].lDeadZone;
340  remap_props.lSaturation = This->props[obj].lSaturation;
341 
342  remap_props.lMin = pr->lMin;
343  remap_props.lMax = pr->lMax;
344 
345  switch (This->base.data_format.wine_df->rgodf[obj].dwOfs) {
346  case DIJOFS_X : This->js.lX = joystick_map_axis(&remap_props, This->js.lX); break;
347  case DIJOFS_Y : This->js.lY = joystick_map_axis(&remap_props, This->js.lY); break;
348  case DIJOFS_Z : This->js.lZ = joystick_map_axis(&remap_props, This->js.lZ); break;
349  case DIJOFS_RX : This->js.lRx = joystick_map_axis(&remap_props, This->js.lRx); break;
350  case DIJOFS_RY : This->js.lRy = joystick_map_axis(&remap_props, This->js.lRy); break;
351  case DIJOFS_RZ : This->js.lRz = joystick_map_axis(&remap_props, This->js.lRz); break;
352  case DIJOFS_SLIDER(0): This->js.rglSlider[0] = joystick_map_axis(&remap_props, This->js.rglSlider[0]); break;
353  case DIJOFS_SLIDER(1): This->js.rglSlider[1] = joystick_map_axis(&remap_props, This->js.rglSlider[1]); break;
354  default: break;
355  }
356 
357  This->props[obj].lMin = pr->lMin;
358  This->props[obj].lMax = pr->lMax;
359  return DI_OK;
360  }
361  }
362  break;
363  }
364  case (DWORD_PTR)DIPROP_DEADZONE: {
366  if (ph->dwHow == DIPH_DEVICE) {
367  TRACE("deadzone(%d) all\n", pd->dwData);
368  for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
369  This->props[i].lDeadZone = pd->dwData;
370  } else {
371  int obj = find_property(&This->base.data_format, ph);
372 
373  TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
374  if (obj >= 0) {
375  This->props[obj].lDeadZone = pd->dwData;
376  return DI_OK;
377  }
378  }
379  break;
380  }
383  if (ph->dwHow == DIPH_DEVICE) {
384  TRACE("saturation(%d) all\n", pd->dwData);
385  for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
386  This->props[i].lSaturation = pd->dwData;
387  } else {
388  int obj = find_property(&This->base.data_format, ph);
389 
390  TRACE("saturation(%d) obj=%d\n", pd->dwData, obj);
391  if (obj >= 0) {
392  This->props[obj].lSaturation = pd->dwData;
393  return DI_OK;
394  }
395  }
396  break;
397  }
398  default:
399  return IDirectInputDevice2WImpl_SetProperty(iface, rguid, ph);
400  }
401  }
402 
403  return DI_OK;
404 }
405 
407 {
410 }
411 
412 #define DEBUG_TYPE(x) case (x): str = #x; break
413 void _dump_DIDEVCAPS(const DIDEVCAPS *lpDIDevCaps)
414 {
415  int type = GET_DIDEVICE_TYPE(lpDIDevCaps->dwDevType);
416  const char *str, *hid = "";
417  TRACE("dwSize: %d\n", lpDIDevCaps->dwSize);
418  TRACE("dwFlags: %08x\n", lpDIDevCaps->dwFlags);
419  switch(type)
420  {
421  /* Direct X <= 7 definitions */
426  /* Direct X >= 8 definitions */
439  default: str = "UNKNOWN";
440  }
441 
442  if (lpDIDevCaps->dwDevType & DIDEVTYPE_HID)
443  hid = " (HID)";
444 
445  TRACE("dwDevType: %08x %s%s\n", lpDIDevCaps->dwDevType, str, hid);
446  TRACE("dwAxes: %d\n", lpDIDevCaps->dwAxes);
447  TRACE("dwButtons: %d\n", lpDIDevCaps->dwButtons);
448  TRACE("dwPOVs: %d\n", lpDIDevCaps->dwPOVs);
449  if (lpDIDevCaps->dwSize > sizeof(DIDEVCAPS_DX3)) {
450  TRACE("dwFFSamplePeriod: %d\n", lpDIDevCaps->dwFFSamplePeriod);
451  TRACE("dwFFMinTimeResolution: %d\n", lpDIDevCaps->dwFFMinTimeResolution);
452  TRACE("dwFirmwareRevision: %d\n", lpDIDevCaps->dwFirmwareRevision);
453  TRACE("dwHardwareRevision: %d\n", lpDIDevCaps->dwHardwareRevision);
454  TRACE("dwFFDriverVersion: %d\n", lpDIDevCaps->dwFFDriverVersion);
455  }
456 }
457 #undef DEBUG_TYPE
458 
460 {
462  int size;
463 
464  TRACE("%p->(%p)\n",iface,lpDIDevCaps);
465 
466  if (lpDIDevCaps == NULL) {
467  WARN("invalid pointer\n");
468  return E_POINTER;
469  }
470 
471  size = lpDIDevCaps->dwSize;
472 
473  if (!(size == sizeof(DIDEVCAPS) || size == sizeof(DIDEVCAPS_DX3))) {
474  WARN("invalid parameter\n");
475  return DIERR_INVALIDPARAM;
476  }
477 
478  CopyMemory(lpDIDevCaps, &This->devcaps, size);
479  lpDIDevCaps->dwSize = size;
480 
481  if (TRACE_ON(dinput))
482  _dump_DIDEVCAPS(lpDIDevCaps);
483 
484  return DI_OK;
485 }
486 
488 {
491 }
492 
493 /******************************************************************************
494  * GetObjectInfo : get object info
495  */
497  LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow)
498 {
499  static const WCHAR axisW[] = {'A','x','i','s',' ','%','d',0};
500  static const WCHAR povW[] = {'P','O','V',' ','%','d',0};
501  static const WCHAR buttonW[] = {'B','u','t','t','o','n',' ','%','d',0};
502  HRESULT res;
503 
504  res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
505  if (res != DI_OK) return res;
506 
507  if (pdidoi->dwType & DIDFT_AXIS) {
508  sprintfW(pdidoi->tszName, axisW, DIDFT_GETINSTANCE(pdidoi->dwType));
509  pdidoi->dwFlags |= DIDOI_ASPECTPOSITION;
510  } else if (pdidoi->dwType & DIDFT_POV)
511  sprintfW(pdidoi->tszName, povW, DIDFT_GETINSTANCE(pdidoi->dwType));
512  else if (pdidoi->dwType & DIDFT_BUTTON)
513  sprintfW(pdidoi->tszName, buttonW, DIDFT_GETINSTANCE(pdidoi->dwType));
514 
515  _dump_OBJECTINSTANCEW(pdidoi);
516  return res;
517 }
518 
520  LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow)
521 {
523  HRESULT res;
525  DWORD dwSize = pdidoi->dwSize;
526 
527  didoiW.dwSize = sizeof(didoiW);
529  if (res != DI_OK) return res;
530 
531  memset(pdidoi, 0, pdidoi->dwSize);
532  memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName));
533  pdidoi->dwSize = dwSize;
534  WideCharToMultiByte(CP_ACP, 0, didoiW.tszName, -1, pdidoi->tszName,
535  sizeof(pdidoi->tszName), NULL, NULL);
536 
537  return res;
538 }
539 
540 /******************************************************************************
541  * GetProperty : get input device properties
542  */
544 {
546 
547  TRACE("(%p,%s,%p)\n", iface, debugstr_guid(rguid), pdiph);
548 
549  if (TRACE_ON(dinput))
550  _dump_DIPROPHEADER(pdiph);
551 
552  if (IS_DIPROP(rguid)) {
553  switch (LOWORD(rguid)) {
554  case (DWORD_PTR) DIPROP_RANGE: {
555  LPDIPROPRANGE pr = (LPDIPROPRANGE)pdiph;
556  int obj = find_property(&This->base.data_format, pdiph);
557 
558  /* The app is querying the current range of the axis
559  * return the lMin and lMax values */
560  if (obj >= 0) {
561  pr->lMin = This->props[obj].lMin;
562  pr->lMax = This->props[obj].lMax;
563  TRACE("range(%d, %d) obj=%d\n", pr->lMin, pr->lMax, obj);
564  return DI_OK;
565  }
566  break;
567  }
568  case (DWORD_PTR) DIPROP_DEADZONE: {
569  LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
570  int obj = find_property(&This->base.data_format, pdiph);
571 
572  if (obj >= 0) {
573  pd->dwData = This->props[obj].lDeadZone;
574  TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
575  return DI_OK;
576  }
577  break;
578  }
579  case (DWORD_PTR) DIPROP_SATURATION: {
580  LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
581  int obj = find_property(&This->base.data_format, pdiph);
582 
583  if (obj >= 0) {
584  pd->dwData = This->props[obj].lSaturation;
585  TRACE("saturation(%d) obj=%d\n", pd->dwData, obj);
586  return DI_OK;
587  }
588  break;
589  }
592  DIPROPSTRING *ps = (DIPROPSTRING*) pdiph;
593  DIDEVICEINSTANCEW didev;
594 
595  didev.dwSize = sizeof(didev);
596 
597  IDirectInputDevice_GetDeviceInfo(iface, &didev);
598  if (LOWORD(rguid) == (DWORD_PTR) DIPROP_PRODUCTNAME)
599  lstrcpynW(ps->wsz, didev.tszProductName, MAX_PATH);
600  else
601  lstrcpynW(ps->wsz, didev.tszInstanceName, MAX_PATH);
602 
603  return DI_OK;
604  }
605  default:
606  return IDirectInputDevice2WImpl_GetProperty(iface, rguid, pdiph);
607  }
608  }
609 
610  return DI_OK;
611 }
612 
614 {
617 }
618 
619 /******************************************************************************
620  * GetDeviceInfo : get information about a device's identity
621  */
623  LPDIRECTINPUTDEVICE8A iface,
624  LPDIDEVICEINSTANCEA pdidi)
625 {
627  DIPROPDWORD pd;
628  DWORD index = 0;
629 
630  TRACE("(%p,%p)\n", iface, pdidi);
631 
632  if (pdidi == NULL) {
633  WARN("invalid pointer\n");
634  return E_POINTER;
635  }
636 
637  if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3A)) &&
638  (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA))) {
639  WARN("invalid parameter: pdidi->dwSize = %d\n", pdidi->dwSize);
640  return DIERR_INVALIDPARAM;
641  }
642 
643  /* Try to get joystick index */
644  pd.diph.dwSize = sizeof(pd);
645  pd.diph.dwHeaderSize = sizeof(pd.diph);
646  pd.diph.dwObj = 0;
647  pd.diph.dwHow = DIPH_DEVICE;
649  index = pd.dwData;
650 
651  /* Return joystick */
652  pdidi->guidInstance = This->guidInstance;
653  pdidi->guidProduct = This->guidProduct;
654  /* we only support traditional joysticks for now */
655  pdidi->dwDevType = This->devcaps.dwDevType;
656  snprintf(pdidi->tszInstanceName, MAX_PATH, "Joystick %d", index);
657  strcpy(pdidi->tszProductName, This->name);
658  if (pdidi->dwSize > sizeof(DIDEVICEINSTANCE_DX3A)) {
659  pdidi->guidFFDriver = GUID_NULL;
660  pdidi->wUsagePage = 0;
661  pdidi->wUsage = 0;
662  }
663 
664  return DI_OK;
665 }
666 
667 /******************************************************************************
668  * GetDeviceInfo : get information about a device's identity
669  */
671  LPDIRECTINPUTDEVICE8W iface,
672  LPDIDEVICEINSTANCEW pdidi)
673 {
676  DIPROPDWORD pd;
677  DWORD index = 0;
678 
679  TRACE("(%p,%p)\n", iface, pdidi);
680 
681  if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3W)) &&
682  (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW))) {
683  WARN("invalid parameter: pdidi->dwSize = %d\n", pdidi->dwSize);
684  return DIERR_INVALIDPARAM;
685  }
686 
687  /* Try to get joystick index */
688  pd.diph.dwSize = sizeof(pd);
689  pd.diph.dwHeaderSize = sizeof(pd.diph);
690  pd.diph.dwObj = 0;
691  pd.diph.dwHow = DIPH_DEVICE;
693  index = pd.dwData;
694 
695  /* Return joystick */
696  pdidi->guidInstance = This->guidInstance;
697  pdidi->guidProduct = This->guidProduct;
698  /* we only support traditional joysticks for now */
699  pdidi->dwDevType = This->devcaps.dwDevType;
700  snprintf(buffer, sizeof(buffer), "Joystick %d", index);
702  MultiByteToWideChar(CP_ACP, 0, This->name, -1, pdidi->tszProductName, MAX_PATH);
703  if (pdidi->dwSize > sizeof(DIDEVICEINSTANCE_DX3W)) {
704  pdidi->guidFFDriver = GUID_NULL;
705  pdidi->wUsagePage = 0;
706  pdidi->wUsage = 0;
707  }
708 
709  return DI_OK;
710 }
711 
713 {
715 
716  TRACE("(%p)\n",This);
717 
718  if (!This->base.acquired) {
719  WARN("not acquired\n");
720  return DIERR_NOTACQUIRED;
721  }
722 
724  return DI_OK;
725 }
726 
728 {
731 }
732 
733 /******************************************************************************
734  * GetDeviceState : returns the "state" of the joystick.
735  *
736  */
738 {
740 
741  TRACE("(%p,0x%08x,%p)\n", This, len, ptr);
742 
743  if (!This->base.acquired) {
744  WARN("not acquired\n");
745  return DIERR_NOTACQUIRED;
746  }
747 
748  /* update joystick state */
750 
751  /* convert and copy data to user supplied buffer */
752  fill_DataFormat(ptr, len, &This->js, &This->base.data_format);
753 
754  return DI_OK;
755 }
756 
758 {
761 }
762 
763 
765  LPDIACTIONFORMATW lpdiaf,
766  LPCWSTR lpszUserName,
767  DWORD dwFlags)
768 {
769  static const DWORD object_types[] = { DIDFT_AXIS, DIDFT_BUTTON };
770  static const DWORD type_map[] = { DIDFT_RELAXIS, DIDFT_PSHBUTTON };
772  unsigned int i, j;
773  BOOL has_actions = FALSE;
774 
775  FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
776 
777  for (i=0; i < lpdiaf->dwNumActions; i++)
778  {
779  DWORD inst = (0x000000ff & (lpdiaf->rgoAction[i].dwSemantic)) - 1;
780  DWORD type = 0x000000ff & (lpdiaf->rgoAction[i].dwSemantic >> 8);
781  DWORD genre = 0xff000000 & lpdiaf->rgoAction[i].dwSemantic;
782 
783  /* Don't touch a user configured action */
784  if (lpdiaf->rgoAction[i].dwHow == DIAH_USERCONFIG) continue;
785 
786  /* Only consider actions of the right genre */
787  if (lpdiaf->dwGenre != genre && genre != DIGENRE_ANY) continue;
788 
789  for (j = 0; j < ARRAY_SIZE(object_types); j++)
790  {
791  if (type & object_types[j])
792  {
793  /* Ensure that the object exists */
794  LPDIOBJECTDATAFORMAT odf = dataformat_to_odf_by_type(This->base.data_format.wine_df, inst, object_types[j]);
795 
796  if (odf != NULL)
797  {
798  lpdiaf->rgoAction[i].dwObjID = type_map[j] | (0x0000ff00 & (inst << 8));
799  lpdiaf->rgoAction[i].guidInstance = This->base.guid;
800  lpdiaf->rgoAction[i].dwHow = DIAH_DEFAULT;
801 
802  has_actions = TRUE;
803 
804  /* No need to try other types if the action was already mapped */
805  break;
806  }
807  }
808  }
809  }
810 
811  if (!has_actions) return DI_NOEFFECT;
812 
813  return IDirectInputDevice8WImpl_BuildActionMap(iface, lpdiaf, lpszUserName, dwFlags);
814 }
815 
817  LPDIACTIONFORMATA lpdiaf,
818  LPCSTR lpszUserName,
819  DWORD dwFlags)
820 {
822  DIACTIONFORMATW diafW;
823  HRESULT hr;
824  WCHAR *lpszUserNameW = NULL;
825  int username_size;
826 
827  diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions);
828  _copy_diactionformatAtoW(&diafW, lpdiaf);
829 
830  if (lpszUserName != NULL)
831  {
832  username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
833  lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size);
834  MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size);
835  }
836 
837  hr = JoystickWGenericImpl_BuildActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
838 
839  _copy_diactionformatWtoA(lpdiaf, &diafW);
840  HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
841  HeapFree(GetProcessHeap(), 0, lpszUserNameW);
842 
843  return hr;
844 }
845 
847  LPDIACTIONFORMATW lpdiaf,
848  LPCWSTR lpszUserName,
849  DWORD dwFlags)
850 {
852 
853  FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
854 
855  return _set_action_map(iface, lpdiaf, lpszUserName, dwFlags, This->base.data_format.wine_df);
856 }
857 
859  LPDIACTIONFORMATA lpdiaf,
860  LPCSTR lpszUserName,
861  DWORD dwFlags)
862 {
864  DIACTIONFORMATW diafW;
865  HRESULT hr;
866  WCHAR *lpszUserNameW = NULL;
867  int username_size;
868 
869  diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions);
870  _copy_diactionformatAtoW(&diafW, lpdiaf);
871 
872  if (lpszUserName != NULL)
873  {
874  username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
875  lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size);
876  MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size);
877  }
878 
879  hr = JoystickWGenericImpl_SetActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
880 
881  HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
882  HeapFree(GetProcessHeap(), 0, lpszUserNameW);
883 
884  return hr;
885 }
886 
887 /*
888  * This maps the read value (from the input event) to a value in the
889  * 'wanted' range.
890  * Notes:
891  * Dead zone is in % multiplied by a 100 (range 0..10000)
892  */
894 {
895  LONG ret;
896  LONG dead_zone = MulDiv( props->lDeadZone, props->lDevMax - props->lDevMin, 10000 );
897  LONG dev_range = props->lDevMax - props->lDevMin - dead_zone;
898 
899  /* Center input */
900  val -= (props->lDevMin + props->lDevMax) / 2;
901 
902  /* Remove dead zone */
903  if (abs( val ) <= dead_zone / 2)
904  val = 0;
905  else
906  val = val < 0 ? val + dead_zone / 2 : val - dead_zone / 2;
907 
908  /* Scale and map the value from the device range into the required range */
909  ret = MulDiv( val, props->lMax - props->lMin, dev_range ) +
910  (props->lMin + props->lMax) / 2;
911 
912  /* Clamp in case or rounding errors */
913  if (ret > props->lMax) ret = props->lMax;
914  else if (ret < props->lMin) ret = props->lMin;
915 
916  TRACE( "(%d <%d> %d) -> (%d <%d> %d): val=%d ret=%d\n",
917  props->lDevMin, dead_zone, props->lDevMax,
918  props->lMin, props->lDeadZone, props->lMax,
919  val, ret );
920 
921  return ret;
922 }
923 
924 /*
925  * Maps POV x & y event values to a DX "clock" position:
926  * 0
927  * 31500 4500
928  * 27000 -1 9000
929  * 22500 13500
930  * 18000
931  */
933 {
934  if (p->x > 0)
935  return p->y < 0 ? 4500 : !p->y ? 9000 : 13500;
936  else if (p->x < 0)
937  return p->y < 0 ? 31500 : !p->y ? 27000 : 22500;
938  else
939  return p->y < 0 ? 0 : !p->y ? -1 : 18000;
940 }
941 
942 /*
943  * Setup the dinput options.
944  */
945 
946 HRESULT setup_dinput_options(JoystickGenericImpl *This, const int *default_axis_map)
947 {
948  char buffer[MAX_PATH+16];
949  HKEY hkey, appkey;
950  int tokens = 0;
951  int axis = 0;
952  int pov = 0;
953 
954  get_app_key(&hkey, &appkey);
955 
956  /* get options */
957 
958  if (!get_config_key(hkey, appkey, "DefaultDeadZone", buffer, sizeof(buffer)))
959  {
960  This->deadzone = atoi(buffer);
961  TRACE("setting default deadzone to: \"%s\" %d\n", buffer, This->deadzone);
962  }
963 
964  This->axis_map = HeapAlloc(GetProcessHeap(), 0, This->device_axis_count * sizeof(int));
965  if (!This->axis_map) return DIERR_OUTOFMEMORY;
966 
967  if (!get_config_key(hkey, appkey, This->name, buffer, sizeof(buffer)))
968  {
969  static const char *axis_names[] = {"X", "Y", "Z", "Rx", "Ry", "Rz",
970  "Slider1", "Slider2",
971  "POV1", "POV2", "POV3", "POV4"};
972  const char *delim = ",";
973  char * ptr;
974  TRACE("\"%s\" = \"%s\"\n", This->name, buffer);
975 
976  if ((ptr = strtok(buffer, delim)) != NULL)
977  {
978  do
979  {
980  int i;
981 
982  for (i = 0; i < ARRAY_SIZE(axis_names); i++)
983  {
984  if (!strcmp(ptr, axis_names[i]))
985  {
986  if (!strncmp(ptr, "POV", 3))
987  {
988  if (pov >= 4)
989  {
990  WARN("Only 4 POVs supported - ignoring extra\n");
991  i = -1;
992  }
993  else
994  {
995  /* Pov takes two axes */
996  This->axis_map[tokens++] = i;
997  pov++;
998  }
999  }
1000  else
1001  {
1002  if (axis >= 8)
1003  {
1004  FIXME("Only 8 Axes supported - ignoring extra\n");
1005  i = -1;
1006  }
1007  else
1008  axis++;
1009  }
1010  break;
1011  }
1012  }
1013 
1014  if (i == ARRAY_SIZE(axis_names))
1015  {
1016  ERR("invalid joystick axis type: \"%s\"\n", ptr);
1017  i = -1;
1018  }
1019 
1020  This->axis_map[tokens] = i;
1021  tokens++;
1022  } while ((ptr = strtok(NULL, delim)) != NULL);
1023 
1024  if (tokens != This->device_axis_count)
1025  {
1026  ERR("not all joystick axes mapped: %d axes(%d,%d), %d arguments\n",
1027  This->device_axis_count, axis, pov, tokens);
1028  while (tokens < This->device_axis_count)
1029  {
1030  This->axis_map[tokens] = -1;
1031  tokens++;
1032  }
1033  }
1034  }
1035  }
1036  else
1037  {
1038  int i;
1039 
1040  if (default_axis_map)
1041  {
1042  /* Use default mapping from the driver */
1043  for (i = 0; i < This->device_axis_count; i++)
1044  {
1045  This->axis_map[i] = default_axis_map[i];
1046  tokens = default_axis_map[i];
1047  if (tokens < 0)
1048  continue;
1049  if (tokens < 8)
1050  axis++;
1051  else if (tokens < 15)
1052  {
1053  i++;
1054  pov++;
1055  This->axis_map[i] = default_axis_map[i];
1056  }
1057  }
1058  }
1059  else
1060  {
1061  /* No config - set default mapping. */
1062  for (i = 0; i < This->device_axis_count; i++)
1063  {
1064  if (i < 8)
1065  This->axis_map[i] = axis++;
1066  else if (i < 15)
1067  {
1068  This->axis_map[i++] = 8 + pov;
1069  This->axis_map[i ] = 8 + pov++;
1070  }
1071  else
1072  This->axis_map[i] = -1;
1073  }
1074  }
1075  }
1076  This->devcaps.dwAxes = axis;
1077  This->devcaps.dwPOVs = pov;
1078 
1079  if (appkey) RegCloseKey(appkey);
1080  if (hkey) RegCloseKey(hkey);
1081 
1082  return DI_OK;
1083 }
DWORD cAxes
Definition: dinput.h:1114
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3257
#define DIEP_AXES
Definition: dinput.h:1021
#define abs(i)
Definition: fconv.c:206
GUID guidInstance
Definition: dinput.h:413
DWORD dwTriggerRepeatInterval
Definition: dinput.h:1113
HRESULT WINAPI JoystickAGenericImpl_GetCapabilities(LPDIRECTINPUTDEVICE8A iface, LPDIDEVCAPS lpDIDevCaps)
Definition: joystick.c:487
DWORD dwDuration
Definition: dinput.h:1109
static void _dump_DIPERIODIC(LPCDIPERIODIC frc)
Definition: joystick.c:116
LPDIOBJECTDATAFORMAT dataformat_to_odf_by_type(LPCDIDATAFORMAT df, int n, DWORD type)
Definition: device.c:411
#define DIEFT_CONDITION
Definition: dinput.h:998
#define TRUE
Definition: types.h:120
DWORD dwSamplePeriod
Definition: dinput.h:1074
DWORD dwFFMinTimeResolution
Definition: dinput.h:941
DWORD dwSize
Definition: dinput.h:828
DWORD dwDevType
Definition: dinput.h:428
LONG lMagnitude
Definition: dinput.h:1044
HRESULT WINAPI JoystickAGenericImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER ph)
Definition: joystick.c:406
DWORD dwObjID
Definition: dinput.h:1286
LPDIENVELOPE lpEnvelope
Definition: dinput.h:1117
#define WideCharToMultiByte
Definition: compat.h:101
HRESULT hr
Definition: shlfolder.c:183
Definition: scsiwmi.h:51
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
HRESULT WINAPI IDirectInputDevice2WImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph)
Definition: device.c:1291
#define DIJOFS_RZ
Definition: dinput.h:1212
HRESULT WINAPI JoystickWGenericImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph)
Definition: joystick.c:543
const char * _dump_dinput_GUID(const GUID *guid)
Definition: device.c:196
#define DEBUG_TYPE(x)
Definition: joystick.c:412
#define DIPROP_PRODUCTNAME
Definition: dinput.h:911
#define DIDFT_PSHBUTTON
Definition: dinput.h:754
#define DIGENRE_ANY
#define DI8DEVTYPE_DEVICECTRL
Definition: dinput.h:217
#define DIERR_NOTACQUIRED
Definition: dinput.h:167
#define DI8DEVTYPE_SCREENPOINTER
Definition: dinput.h:218
HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, LPCDIDATAFORMAT df)
Definition: device.c:824
#define CP_ACP
Definition: compat.h:99
#define DIEFT_PERIODIC
Definition: dinput.h:997
char CHAR
Definition: xmlstorage.h:175
static const WCHAR buttonW[]
Definition: htmlelem.c:24
DWORD dwPositiveSaturation
Definition: dinput.h:1066
void _dump_OBJECTINSTANCEW(const DIDEVICEOBJECTINSTANCEW *ddoi)
Definition: device.c:190
#define WARN(fmt,...)
Definition: debug.h:111
HRESULT WINAPI JoystickAGenericImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8A iface, LPDIDEVICEINSTANCEA pdidi)
Definition: joystick.c:622
DWORD dwNumActions
Definition: dinput.h:1313
#define DIDEVTYPE_DEVICE
Definition: dinput.h:197
#define snprintf
Definition: wintirpc.h:48
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
WCHAR tszName[MAX_PATH]
Definition: dinput.h:371
DWORD dwGain
Definition: dinput.h:1111
LPVOID lpvTypeSpecificParams
Definition: dinput.h:1119
GUID guidFFDriver
Definition: dinput.h:431
GUID guidInstance
Definition: dinput.h:1285
#define DIJOFS_SLIDER(n)
Definition: dinput.h:1213
#define DIPROP_RANGE
Definition: dinput.h:892
HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags)
Definition: device.c:1817
HRESULT WINAPI JoystickWGenericImpl_Poll(LPDIRECTINPUTDEVICE8W iface)
Definition: joystick.c:712
DWORD dwHow
Definition: dinput.h:831
#define DI8DEVTYPE_KEYBOARD
Definition: dinput.h:211
HRESULT WINAPI JoystickWGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow)
Definition: joystick.c:496
static JoystickGenericImpl * impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
Definition: joystick.c:37
DWORD typeFromGUID(REFGUID guid)
Definition: joystick.c:54
static IDirectInputDevice8A * IDirectInputDevice8A_from_impl(JoystickGenericImpl *This)
Definition: joystick.c:45
#define DIDFT_GETINSTANCE(n)
Definition: dinput.h:764
DWORD dwStartDelay
Definition: dinput.h:1120
#define DIPH_DEVICE
Definition: dinput.h:835
#define FE(x)
HRESULT setup_dinput_options(JoystickGenericImpl *This, const int *default_axis_map)
Definition: joystick.c:946
#define lstrcpynW
Definition: compat.h:397
DWORD dwDevType
Definition: dinput.h:936
#define DIJOFS_X
Definition: dinput.h:1207
static JoystickGenericImpl * impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
Definition: joystick.c:41
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
static void _dump_DIRAMPFORCE(LPCDIRAMPFORCE frc)
Definition: joystick.c:122
struct DIPROPRANGE * LPDIPROPRANGE
WINE_DEFAULT_DEBUG_CHANNEL(dinput)
const DIPROPDWORD * LPCDIPROPDWORD
Definition: dinput.h:846
#define DI8DEVTYPE_1STPERSON
Definition: dinput.h:216
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
DIPROPHEADER diph
Definition: dinput.h:843
const GUID * guid
#define DIDEVTYPE_MOUSE
Definition: dinput.h:198
GLenum GLint GLuint mask
Definition: glext.h:6028
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
DWORD dwFFSamplePeriod
Definition: dinput.h:940
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define DIDFT_BUTTON
Definition: dinput.h:756
DWORD dwPhase
Definition: dinput.h:1057
HRESULT WINAPI JoystickAGenericImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface, LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags)
Definition: joystick.c:858
#define DIEFT_CUSTOMFORCE
Definition: dinput.h:999
HRESULT WINAPI JoystickWGenericImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIPROPHEADER ph)
Definition: joystick.c:277
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
DWORD dwDevType
Definition: dinput.h:415
static PVOID ptr
Definition: dispmode.c:27
DWORD dwSize
Definition: dinput.h:1107
void _dump_DIDEVCAPS(const DIDEVCAPS *lpDIDevCaps)
Definition: joystick.c:413
GLenum condition
Definition: glext.h:9255
HRESULT WINAPI JoystickAGenericImpl_GetDeviceState(LPDIRECTINPUTDEVICE8A iface, DWORD len, LPVOID ptr)
Definition: joystick.c:757
DWORD dwFlags
Definition: dinput.h:935
GUID guidProduct
Definition: dinput.h:414
const WCHAR * str
static void _dump_DICONSTANTFORCE(LPCDICONSTANTFORCE frc)
Definition: joystick.c:111
smooth NULL
Definition: ftsmooth.c:416
DWORD dwAxes
Definition: dinput.h:937
DWORD dwPOVs
Definition: dinput.h:939
GLuint index
Definition: glext.h:6031
const char * LPCSTR
Definition: xmlstorage.h:183
#define debugstr_guid
Definition: kernel32.h:35
LONG lSaturation
DWORD dwHardwareRevision
Definition: dinput.h:943
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static void _dump_DIEFFECT_flags(DWORD dwFlags)
Definition: joystick.c:79
int find_property(const DataFormat *df, LPCDIPROPHEADER ph)
Definition: device.c:606
GLuint GLfloat * val
Definition: glext.h:7180
#define DI8DEVTYPE_REMOTE
Definition: dinput.h:219
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
HRESULT WINAPI JoystickAGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface, LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow)
Definition: joystick.c:519
#define DIPROP_DEADZONE
Definition: dinput.h:893
DWORD cSamples
Definition: dinput.h:1075
#define DIJOFS_Y
Definition: dinput.h:1208
#define DIERR_INVALIDPARAM
Definition: dinput.h:152
LONG lStart
Definition: dinput.h:1049
LPDWORD rgdwAxes
Definition: dinput.h:1115
#define TRACE(s)
Definition: solgame.cpp:4
void _dump_DIPROPHEADER(LPCDIPROPHEADER diph)
Definition: device.c:175
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
DWORD dwSize
Definition: dinput.h:934
#define DIEP_ENVELOPE
Definition: dinput.h:1023
#define DIEFT_CONSTANTFORCE
Definition: dinput.h:995
DWORD cbTypeSpecificParams
Definition: dinput.h:1118
#define DIERR_OUTOFMEMORY
Definition: dinput.h:155
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define DIDOI_ASPECTPOSITION
Definition: dinput.h:820
LONG HRESULT
Definition: typedefs.h:77
void fill_DataFormat(void *out, DWORD size, const void *in, const DataFormat *df)
Definition: device.c:325
DWORD dwFFDriverVersion
Definition: dinput.h:944
DWORD dwButtons
Definition: dinput.h:938
#define MAX_PATH
Definition: compat.h:26
#define WINAPI
Definition: msvc.h:8
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define CopyMemory
Definition: winbase.h:1633
#define DIJOFS_Z
Definition: dinput.h:1209
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR wsz[MAX_PATH]
Definition: dinput.h:875
#define GET_DIDEVICE_TYPE(dwDevType)
Definition: dinput.h:320
#define DIDEVTYPE_JOYSTICK
Definition: dinput.h:200
CHAR tszName[MAX_PATH]
Definition: dinput.h:352
#define DI8DEVTYPE_GAMEPAD
Definition: dinput.h:213
GLbitfield flags
Definition: glext.h:7161
#define DIEFF_CARTESIAN
Definition: dinput.h:1012
#define DIJOFS_RX
Definition: dinput.h:1210
#define DIEFF_POLAR
Definition: dinput.h:1013
WCHAR tszProductName[MAX_PATH]
Definition: dinput.h:430
#define DIDEVTYPE_KEYBOARD
Definition: dinput.h:199
int ret
static void _dump_DICUSTOMFORCE(LPCDICUSTOMFORCE frc)
Definition: joystick.c:135
#define DIDFT_AXIS
Definition: dinput.h:753
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define DIEFF_OBJECTOFFSETS
Definition: dinput.h:1011
DWORD dwData
Definition: dinput.h:844
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
void dump_DIEFFECT(LPCDIEFFECT eff, REFGUID guid, DWORD dwFlags)
Definition: joystick.c:152
CHAR tszInstanceName[MAX_PATH]
Definition: dinput.h:416
#define DIPROP_JOYSTICKID
Definition: dinput.h:912
#define GUID_NULL
Definition: ks.h:106
#define DI_NOEFFECT
Definition: dinput.h:132
uint32_t DWORD_PTR
Definition: typedefs.h:63
LPLONG rglDirection
Definition: dinput.h:1116
WCHAR tszInstanceName[MAX_PATH]
Definition: dinput.h:429
LPDIACTIONW rgoAction
Definition: dinput.h:1332
#define DI8DEVTYPE_JOYSTICK
Definition: dinput.h:212
BOOL device_disabled_registry(const char *name)
Definition: joystick.c:236
HRESULT WINAPI JoystickAGenericImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface, LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags)
Definition: joystick.c:816
LONG lDeadBand
Definition: dinput.h:1068
#define ERR(fmt,...)
Definition: debug.h:109
DWORD get_config_key(HKEY defkey, HKEY appkey, const char *name, char *buffer, DWORD size)
Definition: device.c:312
static IDirectInputDevice8W * IDirectInputDevice8W_from_impl(JoystickGenericImpl *This)
Definition: joystick.c:49
#define DIPROP_SATURATION
Definition: dinput.h:894
struct IDirectInputDevice8W * LPDIRECTINPUTDEVICE8W
Definition: dinput.h:106
LPLONG rglForceData
Definition: dinput.h:1076
void _copy_diactionformatAtoW(LPDIACTIONFORMATW to, LPDIACTIONFORMATA from)
Definition: dinput_main.c:323
#define DIAH_USERCONFIG
Definition: dinput.h:1302
LONG joystick_map_axis(ObjProps *props, int val)
Definition: joystick.c:893
HRESULT WINAPI JoystickWGenericImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags)
Definition: joystick.c:764
DWORD dwMagnitude
Definition: dinput.h:1055
HRESULT WINAPI JoystickAGenericImpl_Poll(LPDIRECTINPUTDEVICE8A iface)
Definition: joystick.c:727
static calc_node_t temp
Definition: rpn_ieee.c:38
#define ARRAY_SIZE(a)
Definition: main.h:24
#define DIDEVTYPE_HID
Definition: dinput.h:201
LONG lOffset
Definition: dinput.h:1063
#define DIDFT_POV
Definition: dinput.h:757
#define sprintfW
Definition: unicode.h:58
DWORD dwNegativeSaturation
Definition: dinput.h:1067
GUID guidFFDriver
Definition: dinput.h:418
DWORD joystick_map_pov(const POINTL *p)
Definition: joystick.c:932
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow)
Definition: device.c:1481
static void _dump_DICONDITION(LPCDICONDITION frc)
Definition: joystick.c:128
#define DI8DEVTYPE_DEVICE
Definition: dinput.h:209
HRESULT WINAPI JoystickAGenericImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph)
Definition: joystick.c:613
void _copy_diactionformatWtoA(LPDIACTIONFORMATA to, LPDIACTIONFORMATW from)
Definition: dinput_main.c:350
HRESULT WINAPI JoystickWGenericImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W iface, LPDIDEVCAPS lpDIDevCaps)
Definition: joystick.c:459
DWORD dwObj
Definition: dinput.h:830
#define DIAH_DEFAULT
Definition: dinput.h:1306
#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
#define DI8DEVTYPE_FLIGHT
Definition: dinput.h:215
HRESULT WINAPI JoystickWGenericImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W iface, DWORD len, LPVOID ptr)
Definition: joystick.c:737
#define DI8DEVTYPE_MOUSE
Definition: dinput.h:210
#define DI8DEVTYPE_SUPPLEMENTAL
Definition: dinput.h:220
GUID guidInstance
Definition: dinput.h:426
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:168
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
#define MultiByteToWideChar
Definition: compat.h:100
BOOL get_app_key(HKEY *defkey, HKEY *appkey)
Definition: device.c:277
#define DI8DEVTYPE_DRIVING
Definition: dinput.h:214
#define IDirectInputDevice2_GetProperty(p, a, b)
Definition: dinput.h:1731
CHAR tszProductName[MAX_PATH]
Definition: dinput.h:417
LONG lNegativeCoefficient
Definition: dinput.h:1065
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
DWORD cChannels
Definition: dinput.h:1073
struct IDirectInputDevice8A * LPDIRECTINPUTDEVICE8A
Definition: dinput.h:105
Definition: name.c:36
LONG lMin
Definition: dinput.h:850
HRESULT WINAPI JoystickWGenericImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi)
Definition: joystick.c:670
static const WCHAR props[]
Definition: wbemdisp.c:288
GLuint res
Definition: glext.h:9613
#define DI_OK
Definition: dinput.h:128
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define DIEFT_RAMPFORCE
Definition: dinput.h:996
DWORD dwFirmwareRevision
Definition: dinput.h:942
#define DIEFF_SPHERICAL
Definition: dinput.h:1014
DWORD dwHeaderSize
Definition: dinput.h:829
#define DIEFF_OBJECTIDS
Definition: dinput.h:1010
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
DWORD dwHow
Definition: dinput.h:1287
HRESULT WINAPI IDirectInputDevice2WImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIPROPHEADER pdiph)
Definition: device.c:1355
#define DIJOFS_RY
Definition: dinput.h:1211
LONG lOffset
Definition: dinput.h:1056
DWORD dwFlags
Definition: dinput.h:1108
LONG lMax
Definition: dinput.h:851
#define IS_DIPROP(x)
static void _dump_DIENVELOPE(LPCDIENVELOPE env)
Definition: joystick.c:102
DWORD dwNumActions
Definition: dinput.h:1331
const DIPROPRANGE * LPCDIPROPRANGE
Definition: dinput.h:853
GLfloat GLfloat p
Definition: glext.h:8902
#define E_POINTER
Definition: winerror.h:2365
LONG lPositiveCoefficient
Definition: dinput.h:1064
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE_ON(x)
Definition: compat.h:65
HRESULT WINAPI JoystickWGenericImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags)
Definition: joystick.c:846
struct DIPROPDWORD * LPDIPROPDWORD
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:394
LONG lDeadZone
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
LONG lEnd
Definition: dinput.h:1050
#define SUCCEEDED(hr)
Definition: intsafe.h:57
DWORD dwPeriod
Definition: dinput.h:1058
#define DIDFT_RELAXIS
Definition: dinput.h:751
#define DIPROP_INSTANCENAME
Definition: dinput.h:910
DWORD dwSemantic
Definition: dinput.h:1279
GUID guidProduct
Definition: dinput.h:427
GLuint const GLchar * name
Definition: glext.h:6031