win32_joystick.c
Go to the documentation of this file.
1 //========================================================================
2 // GLFW 3.3 Win32 - www.glfw.org
3 //------------------------------------------------------------------------
4 // Copyright (c) 2002-2006 Marcus Geelnard
5 // Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
6 //
7 // This software is provided 'as-is', without any express or implied
8 // warranty. In no event will the authors be held liable for any damages
9 // arising from the use of this software.
10 //
11 // Permission is granted to anyone to use this software for any purpose,
12 // including commercial applications, and to alter it and redistribute it
13 // freely, subject to the following restrictions:
14 //
15 // 1. The origin of this software must not be misrepresented; you must not
16 // claim that you wrote the original software. If you use this software
17 // in a product, an acknowledgment in the product documentation would
18 // be appreciated but is not required.
19 //
20 // 2. Altered source versions must be plainly marked as such, and must not
21 // be misrepresented as being the original software.
22 //
23 // 3. This notice may not be removed or altered from any source
24 // distribution.
25 //
26 //========================================================================
27 
28 #include "internal.h"
29 
30 #include <stdio.h>
31 #include <math.h>
32 
33 #define _GLFW_TYPE_AXIS 0
34 #define _GLFW_TYPE_SLIDER 1
35 #define _GLFW_TYPE_BUTTON 2
36 #define _GLFW_TYPE_POV 3
37 
38 // Data produced with DirectInput device object enumeration
39 //
40 typedef struct _GLFWobjenumWin32
41 {
42  IDirectInputDevice8W* device;
45  int axisCount;
48  int povCount;
50 
51 // Define local copies of the necessary GUIDs
52 //
54  {0xbf798031,0x483a,0x4da2,{0xaa,0x99,0x5d,0x64,0xed,0x36,0x97,0x00}};
55 static const GUID _glfw_GUID_XAxis =
56  {0xa36d02e0,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
57 static const GUID _glfw_GUID_YAxis =
58  {0xa36d02e1,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
59 static const GUID _glfw_GUID_ZAxis =
60  {0xa36d02e2,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
61 static const GUID _glfw_GUID_RxAxis =
62  {0xa36d02f4,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
63 static const GUID _glfw_GUID_RyAxis =
64  {0xa36d02f5,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
65 static const GUID _glfw_GUID_RzAxis =
66  {0xa36d02e3,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
67 static const GUID _glfw_GUID_Slider =
68  {0xa36d02e4,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
69 static const GUID _glfw_GUID_POV =
70  {0xa36d02f2,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
71 
72 #define IID_IDirectInput8W _glfw_IID_IDirectInput8W
73 #define GUID_XAxis _glfw_GUID_XAxis
74 #define GUID_YAxis _glfw_GUID_YAxis
75 #define GUID_ZAxis _glfw_GUID_ZAxis
76 #define GUID_RxAxis _glfw_GUID_RxAxis
77 #define GUID_RyAxis _glfw_GUID_RyAxis
78 #define GUID_RzAxis _glfw_GUID_RzAxis
79 #define GUID_Slider _glfw_GUID_Slider
80 #define GUID_POV _glfw_GUID_POV
81 
82 // Object data array for our clone of c_dfDIJoystick
83 // Generated with https://github.com/elmindreda/c_dfDIJoystick2
84 //
86 {
131 };
132 
133 // Our clone of c_dfDIJoystick
134 //
136 {
137  sizeof(DIDATAFORMAT),
138  sizeof(DIOBJECTDATAFORMAT),
140  sizeof(DIJOYSTATE),
141  sizeof(_glfwObjectDataFormats) / sizeof(DIOBJECTDATAFORMAT),
142  _glfwObjectDataFormats
143 };
144 
145 // Returns a description fitting the specified XInput capabilities
146 //
147 static const char* getDeviceDescription(const XINPUT_CAPABILITIES* xic)
148 {
149  switch (xic->SubType)
150  {
152  return "XInput Wheel";
154  return "XInput Arcade Stick";
156  return "XInput Flight Stick";
158  return "XInput Dance Pad";
160  return "XInput Guitar";
162  return "XInput Drum Kit";
164  {
165  if (xic->Flags & XINPUT_CAPS_WIRELESS)
166  return "Wireless Xbox Controller";
167  else
168  return "Xbox Controller";
169  }
170  }
171 
172  return "Unknown XInput Device";
173 }
174 
175 // Lexically compare device objects
176 //
177 static int compareJoystickObjects(const void* first, const void* second)
178 {
179  const _GLFWjoyobjectWin32* fo = first;
180  const _GLFWjoyobjectWin32* so = second;
181 
182  if (fo->type != so->type)
183  return fo->type - so->type;
184 
185  return fo->offset - so->offset;
186 }
187 
188 // Checks whether the specified device supports XInput
189 // Technique from FDInputJoystickManager::IsXInputDeviceFast in ZDoom
190 //
191 static GLFWbool supportsXInput(const GUID* guid)
192 {
193  UINT i, count = 0;
194  RAWINPUTDEVICELIST* ridl;
196 
197  if (GetRawInputDeviceList(NULL, &count, sizeof(RAWINPUTDEVICELIST)) != 0)
198  return GLFW_FALSE;
199 
200  ridl = calloc(count, sizeof(RAWINPUTDEVICELIST));
201 
202  if (GetRawInputDeviceList(ridl, &count, sizeof(RAWINPUTDEVICELIST)) == (UINT) -1)
203  {
204  free(ridl);
205  return GLFW_FALSE;
206  }
207 
208  for (i = 0; i < count; i++)
209  {
210  RID_DEVICE_INFO rdi;
211  char name[256];
212  UINT size;
213 
214  if (ridl[i].dwType != RIM_TYPEHID)
215  continue;
216 
217  ZeroMemory(&rdi, sizeof(rdi));
218  rdi.cbSize = sizeof(rdi);
219  size = sizeof(rdi);
220 
221  if ((INT) GetRawInputDeviceInfoA(ridl[i].hDevice,
222  RIDI_DEVICEINFO,
223  &rdi, &size) == -1)
224  {
225  continue;
226  }
227 
228  if (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) != (LONG) guid->Data1)
229  continue;
230 
231  memset(name, 0, sizeof(name));
232  size = sizeof(name);
233 
234  if ((INT) GetRawInputDeviceInfoA(ridl[i].hDevice,
235  RIDI_DEVICENAME,
236  name, &size) == -1)
237  {
238  break;
239  }
240 
241  name[sizeof(name) - 1] = '\0';
242  if (strstr(name, "IG_"))
243  {
244  result = GLFW_TRUE;
245  break;
246  }
247  }
248 
249  free(ridl);
250  return result;
251 }
252 
253 // Frees all resources associated with the specified joystick
254 //
255 static void closeJoystick(_GLFWjoystick* js)
256 {
257  if (js->win32.device)
258  {
259  IDirectInputDevice8_Unacquire(js->win32.device);
260  IDirectInputDevice8_Release(js->win32.device);
261  }
262 
263  _glfwFreeJoystick(js);
265 }
266 
267 // DirectInput device object enumeration callback
268 // Insights gleaned from SDL
269 //
270 static BOOL CALLBACK deviceObjectCallback(const DIDEVICEOBJECTINSTANCEW* doi,
271  void* user)
272 {
273  _GLFWobjenumWin32* data = user;
274  _GLFWjoyobjectWin32* object = data->objects + data->objectCount;
275 
276  if (DIDFT_GETTYPE(doi->dwType) & DIDFT_AXIS)
277  {
278  DIPROPRANGE dipr;
279 
280  if (memcmp(&doi->guidType, &GUID_Slider, sizeof(GUID)) == 0)
281  object->offset = DIJOFS_SLIDER(data->sliderCount);
282  else if (memcmp(&doi->guidType, &GUID_XAxis, sizeof(GUID)) == 0)
283  object->offset = DIJOFS_X;
284  else if (memcmp(&doi->guidType, &GUID_YAxis, sizeof(GUID)) == 0)
285  object->offset = DIJOFS_Y;
286  else if (memcmp(&doi->guidType, &GUID_ZAxis, sizeof(GUID)) == 0)
287  object->offset = DIJOFS_Z;
288  else if (memcmp(&doi->guidType, &GUID_RxAxis, sizeof(GUID)) == 0)
289  object->offset = DIJOFS_RX;
290  else if (memcmp(&doi->guidType, &GUID_RyAxis, sizeof(GUID)) == 0)
291  object->offset = DIJOFS_RY;
292  else if (memcmp(&doi->guidType, &GUID_RzAxis, sizeof(GUID)) == 0)
293  object->offset = DIJOFS_RZ;
294  else
295  return DIENUM_CONTINUE;
296 
297  ZeroMemory(&dipr, sizeof(dipr));
298  dipr.diph.dwSize = sizeof(dipr);
299  dipr.diph.dwHeaderSize = sizeof(dipr.diph);
300  dipr.diph.dwObj = doi->dwType;
301  dipr.diph.dwHow = DIPH_BYID;
302  dipr.lMin = -32768;
303  dipr.lMax = 32767;
304 
305  if (FAILED(IDirectInputDevice8_SetProperty(data->device,
306  DIPROP_RANGE,
307  &dipr.diph)))
308  {
309  return DIENUM_CONTINUE;
310  }
311 
312  if (memcmp(&doi->guidType, &GUID_Slider, sizeof(GUID)) == 0)
313  {
314  object->type = _GLFW_TYPE_SLIDER;
315  data->sliderCount++;
316  }
317  else
318  {
319  object->type = _GLFW_TYPE_AXIS;
320  data->axisCount++;
321  }
322  }
323  else if (DIDFT_GETTYPE(doi->dwType) & DIDFT_BUTTON)
324  {
325  object->offset = DIJOFS_BUTTON(data->buttonCount);
326  object->type = _GLFW_TYPE_BUTTON;
327  data->buttonCount++;
328  }
329  else if (DIDFT_GETTYPE(doi->dwType) & DIDFT_POV)
330  {
331  object->offset = DIJOFS_POV(data->povCount);
332  object->type = _GLFW_TYPE_POV;
333  data->povCount++;
334  }
335 
336  data->objectCount++;
337  return DIENUM_CONTINUE;
338 }
339 
340 // DirectInput device enumeration callback
341 //
342 static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
343 {
344  int jid = 0;
345  DIDEVCAPS dc;
346  DIPROPDWORD dipd;
349  _GLFWjoystick* js;
350  char guid[33];
351  char name[256];
352 
353  for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
354  {
355  _GLFWjoystick* js = _glfw.joysticks + jid;
356  if (js->present)
357  {
358  if (memcmp(&js->win32.guid, &di->guidInstance, sizeof(GUID)) == 0)
359  return DIENUM_CONTINUE;
360  }
361  }
362 
363  if (supportsXInput(&di->guidProduct))
364  return DIENUM_CONTINUE;
365 
366  if (FAILED(IDirectInput8_CreateDevice(_glfw.win32.dinput8.api,
367  &di->guidInstance,
368  &device,
369  NULL)))
370  {
371  _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to create device");
372  return DIENUM_CONTINUE;
373  }
374 
375  if (FAILED(IDirectInputDevice8_SetDataFormat(device, &_glfwDataFormat)))
376  {
378  "Win32: Failed to set device data format");
379 
381  return DIENUM_CONTINUE;
382  }
383 
384  ZeroMemory(&dc, sizeof(dc));
385  dc.dwSize = sizeof(dc);
386 
387  if (FAILED(IDirectInputDevice8_GetCapabilities(device, &dc)))
388  {
390  "Win32: Failed to query device capabilities");
391 
393  return DIENUM_CONTINUE;
394  }
395 
396  ZeroMemory(&dipd, sizeof(dipd));
397  dipd.diph.dwSize = sizeof(dipd);
398  dipd.diph.dwHeaderSize = sizeof(dipd.diph);
399  dipd.diph.dwHow = DIPH_DEVICE;
400  dipd.dwData = DIPROPAXISMODE_ABS;
401 
402  if (FAILED(IDirectInputDevice8_SetProperty(device,
404  &dipd.diph)))
405  {
407  "Win32: Failed to set device axis mode");
408 
410  return DIENUM_CONTINUE;
411  }
412 
413  memset(&data, 0, sizeof(data));
414  data.device = device;
415  data.objects = calloc(dc.dwAxes + dc.dwButtons + dc.dwPOVs,
416  sizeof(_GLFWjoyobjectWin32));
417 
418  if (FAILED(IDirectInputDevice8_EnumObjects(device,
420  &data,
422  {
424  "Win32: Failed to enumerate device objects");
425 
427  free(data.objects);
428  return DIENUM_CONTINUE;
429  }
430 
431  qsort(data.objects, data.objectCount,
432  sizeof(_GLFWjoyobjectWin32),
434 
435  if (!WideCharToMultiByte(CP_UTF8, 0,
436  di->tszInstanceName, -1,
437  name, sizeof(name),
438  NULL, NULL))
439  {
441  "Win32: Failed to convert joystick name to UTF-8");
442 
444  free(data.objects);
445  return DIENUM_STOP;
446  }
447 
448  // Generate a joystick GUID that matches the SDL 2.0.5+ one
449  if (memcmp(&di->guidProduct.Data4[2], "PIDVID", 6) == 0)
450  {
451  sprintf(guid, "03000000%02x%02x0000%02x%02x000000000000",
452  (uint8_t) di->guidProduct.Data1,
453  (uint8_t) (di->guidProduct.Data1 >> 8),
454  (uint8_t) (di->guidProduct.Data1 >> 16),
455  (uint8_t) (di->guidProduct.Data1 >> 24));
456  }
457  else
458  {
459  sprintf(guid, "05000000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00",
460  name[0], name[1], name[2], name[3],
461  name[4], name[5], name[6], name[7],
462  name[8], name[9], name[10]);
463  }
464 
465  js = _glfwAllocJoystick(name, guid,
466  data.axisCount + data.sliderCount,
467  data.buttonCount,
468  data.povCount);
469  if (!js)
470  {
472  free(data.objects);
473  return DIENUM_STOP;
474  }
475 
476  js->win32.device = device;
477  js->win32.guid = di->guidInstance;
478  js->win32.objects = data.objects;
479  js->win32.objectCount = data.objectCount;
480 
482  return DIENUM_CONTINUE;
483 }
484 
485 
489 
490 // Initialize joystick interface
491 //
493 {
494  if (_glfw.win32.dinput8.instance)
495  {
496  if (FAILED(DirectInput8Create(GetModuleHandle(NULL),
499  (void**) &_glfw.win32.dinput8.api,
500  NULL)))
501  {
503  "Win32: Failed to create interface");
504  }
505  }
506 
508 }
509 
510 // Close all opened joystick handles
511 //
513 {
514  int jid;
515 
516  for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
518 
519  if (_glfw.win32.dinput8.api)
520  IDirectInput8_Release(_glfw.win32.dinput8.api);
521 }
522 
523 // Checks for new joysticks after DBT_DEVICEARRIVAL
524 //
526 {
527  if (_glfw.win32.xinput.instance)
528  {
529  DWORD index;
530 
531  for (index = 0; index < XUSER_MAX_COUNT; index++)
532  {
533  int jid;
534  char guid[33];
536  _GLFWjoystick* js;
537 
538  for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
539  {
540  if (_glfw.joysticks[jid].present &&
541  _glfw.joysticks[jid].win32.device == NULL &&
542  _glfw.joysticks[jid].win32.index == index)
543  {
544  break;
545  }
546  }
547 
548  if (jid <= GLFW_JOYSTICK_LAST)
549  continue;
550 
551  if (XInputGetCapabilities(index, 0, &xic) != ERROR_SUCCESS)
552  continue;
553 
554  // Generate a joystick GUID that matches the SDL 2.0.5+ one
555  sprintf(guid, "78696e707574%02x000000000000000000",
556  xic.SubType & 0xff);
557 
558  js = _glfwAllocJoystick(getDeviceDescription(&xic), guid, 6, 10, 1);
559  if (!js)
560  continue;
561 
562  js->win32.index = index;
563 
565  }
566  }
567 
568  if (_glfw.win32.dinput8.api)
569  {
570  if (FAILED(IDirectInput8_EnumDevices(_glfw.win32.dinput8.api,
573  NULL,
575  {
577  "Failed to enumerate DirectInput8 devices");
578  return;
579  }
580  }
581 }
582 
583 // Checks for joystick disconnection after DBT_DEVICEREMOVECOMPLETE
584 //
586 {
587  int jid;
588 
589  for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
590  {
591  _GLFWjoystick* js = _glfw.joysticks + jid;
592  if (js->present)
594  }
595 }
596 
597 
601 
603 {
604  if (js->win32.device)
605  {
606  int i, ai = 0, bi = 0, pi = 0;
607  HRESULT result;
609 
610  IDirectInputDevice8_Poll(js->win32.device);
611  result = IDirectInputDevice8_GetDeviceState(js->win32.device,
612  sizeof(state),
613  &state);
614  if (result == DIERR_NOTACQUIRED || result == DIERR_INPUTLOST)
615  {
616  IDirectInputDevice8_Acquire(js->win32.device);
617  IDirectInputDevice8_Poll(js->win32.device);
618  result = IDirectInputDevice8_GetDeviceState(js->win32.device,
619  sizeof(state),
620  &state);
621  }
622 
623  if (FAILED(result))
624  {
625  closeJoystick(js);
626  return GLFW_FALSE;
627  }
628 
629  if (mode == _GLFW_POLL_PRESENCE)
630  return GLFW_TRUE;
631 
632  for (i = 0; i < js->win32.objectCount; i++)
633  {
634  const void* data = (char*) &state + js->win32.objects[i].offset;
635 
636  switch (js->win32.objects[i].type)
637  {
638  case _GLFW_TYPE_AXIS:
639  case _GLFW_TYPE_SLIDER:
640  {
641  const float value = (*((LONG*) data) + 0.5f) / 32767.5f;
642  _glfwInputJoystickAxis(js, ai, value);
643  ai++;
644  break;
645  }
646 
647  case _GLFW_TYPE_BUTTON:
648  {
649  const char value = (*((BYTE*) data) & 0x80) != 0;
650  _glfwInputJoystickButton(js, bi, value);
651  bi++;
652  break;
653  }
654 
655  case _GLFW_TYPE_POV:
656  {
657  const int states[9] =
658  {
659  GLFW_HAT_UP,
668  };
669 
670  // Screams of horror are appropriate at this point
671  int state = LOWORD(*(DWORD*) data) / (45 * DI_DEGREES);
672  if (state < 0 || state > 8)
673  state = 8;
674 
675  _glfwInputJoystickHat(js, pi, states[state]);
676  pi++;
677  break;
678  }
679  }
680  }
681  }
682  else
683  {
684  int i, dpad = 0;
685  DWORD result;
686  XINPUT_STATE xis;
687  const WORD buttons[10] =
688  {
699  };
700 
701  result = XInputGetState(js->win32.index, &xis);
702  if (result != ERROR_SUCCESS)
703  {
704  if (result == ERROR_DEVICE_NOT_CONNECTED)
705  closeJoystick(js);
706 
707  return GLFW_FALSE;
708  }
709 
710  if (mode == _GLFW_POLL_PRESENCE)
711  return GLFW_TRUE;
712 
713  _glfwInputJoystickAxis(js, 0, (xis.Gamepad.sThumbLX + 0.5f) / 32767.5f);
714  _glfwInputJoystickAxis(js, 1, -(xis.Gamepad.sThumbLY + 0.5f) / 32767.5f);
715  _glfwInputJoystickAxis(js, 2, (xis.Gamepad.sThumbRX + 0.5f) / 32767.5f);
716  _glfwInputJoystickAxis(js, 3, -(xis.Gamepad.sThumbRY + 0.5f) / 32767.5f);
717  _glfwInputJoystickAxis(js, 4, xis.Gamepad.bLeftTrigger / 127.5f - 1.f);
718  _glfwInputJoystickAxis(js, 5, xis.Gamepad.bRightTrigger / 127.5f - 1.f);
719 
720  for (i = 0; i < 10; i++)
721  {
722  const char value = (xis.Gamepad.wButtons & buttons[i]) ? 1 : 0;
723  _glfwInputJoystickButton(js, i, value);
724  }
725 
727  dpad |= GLFW_HAT_UP;
729  dpad |= GLFW_HAT_RIGHT;
731  dpad |= GLFW_HAT_DOWN;
733  dpad |= GLFW_HAT_LEFT;
734 
735  _glfwInputJoystickHat(js, 0, dpad);
736  }
737 
738  return GLFW_TRUE;
739 }
740 
742 {
743  if (strcmp(guid + 20, "504944564944") == 0)
744  {
745  char original[33];
746  strcpy(original, guid);
747  sprintf(guid, "03000000%.4s0000%.4s000000000000",
748  original, original + 4);
749  }
750 }
751 
XINPUT_GAMEPAD Gamepad
Definition: xinput.h:175
#define DIJOFS_POV(n)
Definition: dinput.h:1197
#define IDirectInputDevice8_EnumObjects(p, a, b, c)
Definition: dinput.h:2037
#define GLFW_HAT_LEFT
Definition: glfw3.h:325
DWORD dwSize
Definition: dinput.h:757
#define XUSER_MAX_COUNT
Definition: xinput.h:156
static const GUID _glfw_GUID_XAxis
#define XINPUT_GAMEPAD_RIGHT_SHOULDER
Definition: xinput.h:41
#define DIPROPAXISMODE_ABS
Definition: dinput.h:836
SHORT sThumbLX
Definition: xinput.h:167
void _glfwInputJoystickButton(_GLFWjoystick *js, int button, char value)
Definition: input.c:385
GLuint const GLchar * name
static const GUID _glfw_IID_IDirectInput8W
static const DIDATAFORMAT _glfwDataFormat
static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE *di, void *user)
#define XINPUT_GAMEPAD_Y
Definition: xinput.h:45
#define GLFW_HAT_UP
Definition: glfw3.h:322
#define XINPUT_GAMEPAD_BACK
Definition: xinput.h:37
#define DIJOFS_RZ
Definition: dinput.h:1194
#define DIPH_BYID
Definition: dinput.h:766
void _glfwFreeJoystick(_GLFWjoystick *js)
Definition: input.c:447
#define GUID_Slider
void _glfwDetectJoystickConnectionWin32(void)
#define DIERR_NOTACQUIRED
Definition: dinput.h:194
#define _GLFW_TYPE_AXIS
#define XINPUT_CAPS_WIRELESS
#define XINPUT_GAMEPAD_DPAD_UP
Definition: xinput.h:32
void _glfwTerminateJoysticksWin32(void)
#define XINPUT_DEVSUBTYPE_WHEEL
Definition: xinput.h:115
void _glfwPlatformUpdateGamepadGUID(char *guid)
#define _GLFW_POLL_PRESENCE
Definition: internal.h:54
#define DIJOFS_BUTTON(n)
Definition: dinput.h:1199
GLfloat value
#define XINPUT_DEVSUBTYPE_FLIGHT_STICK
#define IDirectInput8_CreateDevice(p, a, b, c)
Definition: dinput.h:2421
#define DIJOFS_SLIDER(n)
Definition: dinput.h:1195
#define DIPROP_RANGE
Definition: dinput.h:840
#define GLFW_FALSE
Zero.
Definition: glfw3.h:287
DWORD dwHow
Definition: dinput.h:760
#define IDirectInputDevice8_Acquire(p)
Definition: dinput.h:2040
_GLFWjoystick * _glfwAllocJoystick(const char *name, const char *guid, int axisCount, int buttonCount, int hatCount)
Definition: input.c:411
GLFWbool present
Definition: internal.h:478
#define IDirectInputDevice8
Definition: dinput.h:151
DWORD WINAPI XInputGetCapabilities(DWORD, DWORD, XINPUT_CAPABILITIES *)
#define DIDFT_ABSAXIS
Definition: dinput.h:672
HRESULT WINAPI DirectInput8Create(HINSTANCE, DWORD, REFIID, LPVOID *, LPUNKNOWN)
#define DIPH_DEVICE
Definition: dinput.h:764
#define DIJOFS_X
Definition: dinput.h:1189
unsigned char uint8_t
Definition: stdint.h:78
int GLFWbool
Definition: internal.h:61
#define XINPUT_GAMEPAD_DPAD_RIGHT
Definition: xinput.h:35
DIPROPHEADER diph
Definition: dinput.h:774
void _glfwInputJoystick(_GLFWjoystick *js, int event)
Definition: input.c:368
GLuint index
#define IID_IDirectInput8W
#define _GLFW_TYPE_BUTTON
struct DIJOYSTATE DIJOYSTATE
#define DIDFT_BUTTON
Definition: dinput.h:676
#define GLFW_DISCONNECTED
Definition: glfw3.h:1059
#define XINPUT_GAMEPAD_DPAD_DOWN
Definition: xinput.h:33
#define XINPUT_GAMEPAD_LEFT_THUMB
Definition: xinput.h:38
#define GLFW_HAT_RIGHT
Definition: glfw3.h:323
static const GUID _glfw_GUID_RzAxis
#define GLFW_CONNECTED
Definition: glfw3.h:1058
static int compareJoystickObjects(const void *first, const void *second)
#define GUID_ZAxis
GLdouble f
struct _DIDATAFORMAT DIDATAFORMAT
GLenum mode
unsigned char BYTE
Definition: lz4.c:145
#define DIENUM_STOP
Definition: dinput.h:214
BYTE bRightTrigger
Definition: xinput.h:166
GLsizeiptr size
DWORD dwAxes
Definition: dinput.h:910
DWORD dwPOVs
Definition: dinput.h:912
#define GLFW_PLATFORM_ERROR
A platform-specific error occurred that does not match any of the more specific categories.
Definition: glfw3.h:726
#define IDirectInputDevice8_GetCapabilities(p, a)
Definition: dinput.h:2036
_GLFWlibrary _glfw
Definition: init.c:44
#define DIRECTINPUT_VERSION
Definition: dinput.h:27
#define XINPUT_DEVSUBTYPE_DANCE_PAD
Definition: xinput.h:118
#define IDirectInputDevice8_Release(p)
Definition: dinput.h:2034
#define GLFW_HAT_LEFT_UP
Definition: glfw3.h:328
static const GUID _glfw_GUID_RxAxis
#define GUID_POV
#define IDirectInputDevice8_Poll(p)
Definition: dinput.h:2059
#define GUID_RzAxis
#define DIJOFS_Y
Definition: dinput.h:1190
static const GUID _glfw_GUID_Slider
#define GLFW_JOYSTICK_1
Definition: glfw3.h:558
#define XINPUT_GAMEPAD_START
Definition: xinput.h:36
DIPROPHEADER diph
Definition: dinput.h:780
GLuint * states
Definition: glext.h:9573
#define DIDFT_ANYINSTANCE
Definition: dinput.h:680
#define XINPUT_GAMEPAD_B
Definition: xinput.h:43
WORD wButtons
Definition: xinput.h:164
DWORD dwSize
Definition: dinput.h:907
#define GLFW_JOYSTICK_LAST
Definition: glfw3.h:574
#define DIDOI_ASPECTPOSITION
Definition: dinput.h:746
char guid[33]
Definition: internal.h:487
DWORD dwButtons
Definition: dinput.h:911
#define DIDFT_OPTIONAL
Definition: dinput.h:693
#define XINPUT_GAMEPAD_X
Definition: xinput.h:44
#define GUID_YAxis
#define DIJOFS_Z
Definition: dinput.h:1191
GLint first
#define GLFW_HAT_RIGHT_DOWN
Definition: glfw3.h:327
void _glfwInputError(int code, const char *format,...)
Definition: init.c:129
#define GLFW_HAT_DOWN
Definition: glfw3.h:324
void _glfwInputJoystickHat(_GLFWjoystick *js, int hat, char value)
Definition: input.c:392
void _glfwInitJoysticksWin32(void)
#define DIJOFS_RX
Definition: dinput.h:1192
_GLFWjoyobjectWin32 * objects
#define _GLFW_TYPE_SLIDER
static DIOBJECTDATAFORMAT _glfwObjectDataFormats[]
struct _DIOBJECTDATAFORMAT DIOBJECTDATAFORMAT
#define GLFW_HAT_RIGHT_UP
Definition: glfw3.h:326
static const GUID _glfw_GUID_YAxis
int _glfwPlatformPollJoystick(_GLFWjoystick *js, int mode)
#define DIDFT_AXIS
Definition: dinput.h:673
#define IDirectInputDevice8_Unacquire(p)
Definition: dinput.h:2041
IDirectInputDevice8W * device
#define XINPUT_GAMEPAD_A
Definition: xinput.h:42
DWORD dwData
Definition: dinput.h:775
void _glfwInputJoystickAxis(_GLFWjoystick *js, int axis, float value)
Definition: input.c:378
#define DIEDFL_ALLDEVICES
Definition: dinput.h:217
#define GLFW_TRUE
One.
Definition: glfw3.h:279
SHORT sThumbRY
Definition: xinput.h:170
#define GUID_RxAxis
#define DI_DEGREES
Definition: dinput.h:1019
#define GLFW_HAT_LEFT_DOWN
Definition: glfw3.h:329
static const GUID _glfw_GUID_RyAxis
static const GUID _glfw_GUID_POV
#define DIPROP_AXISMODE
Definition: dinput.h:834
static GLFWbool supportsXInput(const GUID *guid)
SHORT sThumbLY
Definition: xinput.h:168
#define XINPUT_GAMEPAD_DPAD_LEFT
Definition: xinput.h:34
#define XINPUT_GAMEPAD_RIGHT_THUMB
Definition: xinput.h:39
#define IDirectInputDevice8_GetDeviceState(p, a, b)
Definition: dinput.h:2042
#define DIDFT_POV
Definition: dinput.h:677
#define GLFW_HAT_CENTERED
Definition: glfw3.h:321
GLint GLsizei count
void _glfwDetectJoystickDisconnectionWin32(void)
#define XINPUT_DEVSUBTYPE_ARCADE_STICK
Definition: xinput.h:116
static const GUID _glfw_GUID_ZAxis
#define GUID_RyAxis
DWORD dwObj
Definition: dinput.h:759
static const double pi
Definition: src/types.h:57
SHORT sThumbRX
Definition: xinput.h:169
static const FGuid GUID
#define IDirectInputDevice8_SetDataFormat(p, a)
Definition: dinput.h:2044
#define XINPUT_DEVSUBTYPE_DRUM_KIT
Definition: xinput.h:120
static void closeJoystick(_GLFWjoystick *js)
static const char * getDeviceDescription(const XINPUT_CAPABILITIES *xic)
#define GUID_XAxis
#define NULL
Definition: tinycthread.c:47
int i
LONG lMin
Definition: dinput.h:781
#define DIENUM_CONTINUE
Definition: dinput.h:215
DWORD dwHeaderSize
Definition: dinput.h:758
#define DIJOFS_RY
Definition: dinput.h:1193
_GLFWjoystick joysticks[GLFW_JOYSTICK_LAST+1]
Definition: internal.h:531
LONG lMax
Definition: dinput.h:782
static BOOL CALLBACK deviceObjectCallback(const DIDEVICEOBJECTINSTANCEW *doi, void *user)
#define DI8DEVCLASS_GAMECTRL
Definition: dinput.h:234
GLboolean * data
#define DIDFT_GETTYPE(n)
Definition: dinput.h:683
struct _GLFWobjenumWin32 _GLFWobjenumWin32
GLuint64EXT * result
Definition: glext.h:10921
BYTE bLeftTrigger
Definition: xinput.h:165
#define DIERR_INPUTLOST
Definition: dinput.h:190
#define _GLFW_TYPE_POV
Definition: parser.hpp:150
#define XINPUT_DEVSUBTYPE_GUITAR
Definition: xinput.h:119
#define XINPUT_GAMEPAD_LEFT_SHOULDER
Definition: xinput.h:40
#define IDirectInput8_EnumDevices(p, a, b, c, d)
Definition: dinput.h:2422
#define IDirectInputDevice8_SetProperty(p, a, b)
Definition: dinput.h:2039
DWORD WINAPI XInputGetState(DWORD, XINPUT_STATE *)
#define IDirectInput8_Release(p)
Definition: dinput.h:2419
#define XINPUT_DEVSUBTYPE_GAMEPAD
Definition: xinput.h:114


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:23