33 #define _GLFW_TYPE_AXIS 0 34 #define _GLFW_TYPE_SLIDER 1 35 #define _GLFW_TYPE_BUTTON 2 36 #define _GLFW_TYPE_POV 3 54 {0xbf798031,0x483a,0x4da2,{0xaa,0x99,0x5d,0x64,0xed,0x36,0x97,0x00}};
56 {0xa36d02e0,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
58 {0xa36d02e1,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
60 {0xa36d02e2,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
62 {0xa36d02f4,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
64 {0xa36d02f5,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
66 {0xa36d02e3,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
68 {0xa36d02e4,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
70 {0xa36d02f2,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
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 142 _glfwObjectDataFormats
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";
166 return "Wireless Xbox Controller";
168 return "Xbox Controller";
172 return "Unknown XInput Device";
194 RAWINPUTDEVICELIST* ridl;
197 if (GetRawInputDeviceList(
NULL, &count,
sizeof(RAWINPUTDEVICELIST)) != 0)
200 ridl = calloc(count,
sizeof(RAWINPUTDEVICELIST));
202 if (GetRawInputDeviceList(ridl, &count,
sizeof(RAWINPUTDEVICELIST)) == (UINT) -1)
208 for (i = 0; i <
count; i++)
214 if (ridl[i].dwType != RIM_TYPEHID)
217 ZeroMemory(&rdi,
sizeof(rdi));
218 rdi.cbSize =
sizeof(rdi);
221 if ((INT) GetRawInputDeviceInfoA(ridl[i].hDevice,
228 if (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) != (LONG) guid->Data1)
231 memset(name, 0,
sizeof(name));
234 if ((INT) GetRawInputDeviceInfoA(ridl[i].hDevice,
241 name[
sizeof(
name) - 1] =
'\0';
242 if (strstr(name,
"IG_"))
257 if (js->win32.device)
297 ZeroMemory(&dipr,
sizeof(dipr));
358 if (memcmp(&js->win32.
guid, &di->guidInstance,
sizeof(
GUID)) == 0)
378 "Win32: Failed to set device data format");
384 ZeroMemory(&dc,
sizeof(dc));
390 "Win32: Failed to query device capabilities");
396 ZeroMemory(&dipd,
sizeof(dipd));
407 "Win32: Failed to set device axis mode");
413 memset(&data, 0,
sizeof(data));
424 "Win32: Failed to enumerate device objects");
435 if (!WideCharToMultiByte(CP_UTF8, 0,
436 di->tszInstanceName, -1,
441 "Win32: Failed to convert joystick name to UTF-8");
449 if (memcmp(&di->guidProduct.Data4[2],
"PIDVID", 6) == 0)
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));
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]);
476 js->win32.device =
device;
477 js->win32.
guid = di->guidInstance;
478 js->win32.objects = data.
objects;
494 if (
_glfw.win32.dinput8.instance)
499 (
void**) &
_glfw.win32.dinput8.api,
503 "Win32: Failed to create interface");
519 if (
_glfw.win32.dinput8.api)
527 if (
_glfw.win32.xinput.instance)
555 sprintf(guid,
"78696e707574%02x000000000000000000",
562 js->win32.index =
index;
568 if (
_glfw.win32.dinput8.api)
577 "Failed to enumerate DirectInput8 devices");
604 if (js->win32.device)
606 int i, ai = 0, bi = 0,
pi = 0;
632 for (i = 0; i < js->win32.objectCount; i++)
634 const void*
data = (
char*) &state + js->win32.objects[i].offset;
636 switch (js->win32.objects[i].type)
641 const float value = (*((LONG*) data) + 0.5f) / 32767.5
f;
649 const char value = (*((
BYTE*) data) & 0x80) != 0;
671 int state = LOWORD(*(DWORD*) data) / (45 *
DI_DEGREES);
687 const WORD buttons[10] =
702 if (result != ERROR_SUCCESS)
704 if (result == ERROR_DEVICE_NOT_CONNECTED)
720 for (i = 0; i < 10; i++)
743 if (strcmp(guid + 20,
"504944564944") == 0)
746 strcpy(original, guid);
747 sprintf(guid,
"03000000%.4s0000%.4s000000000000",
748 original, original + 4);
static const GUID _glfw_GUID_XAxis
GLuint const GLchar * name
static const GUID _glfw_IID_IDirectInput8W
static const DIDATAFORMAT _glfwDataFormat
static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE *di, void *user)
void _glfwDetectJoystickConnectionWin32(void)
void _glfwTerminateJoysticksWin32(void)
void _glfwPlatformUpdateGamepadGUID(char *guid)
#define _GLFW_POLL_PRESENCE
#define IID_IDirectInput8W
#define _GLFW_TYPE_BUTTON
#define GLFW_DISCONNECTED
static const GUID _glfw_GUID_RzAxis
static int compareJoystickObjects(const void *first, const void *second)
#define GLFW_PLATFORM_ERROR
A platform-specific error occurred that does not match any of the more specific categories.
static const GUID _glfw_GUID_RxAxis
static const GUID _glfw_GUID_Slider
#define GLFW_JOYSTICK_LAST
#define GLFW_HAT_RIGHT_DOWN
void _glfwInputError(int code, const char *format,...)
void _glfwInitJoysticksWin32(void)
_GLFWjoyobjectWin32 * objects
#define _GLFW_TYPE_SLIDER
static DIOBJECTDATAFORMAT _glfwObjectDataFormats[]
#define GLFW_HAT_RIGHT_UP
static const GUID _glfw_GUID_YAxis
int _glfwPlatformPollJoystick(_GLFWjoystick *js, int mode)
IDirectInputDevice8W * device
#define GLFW_HAT_LEFT_DOWN
static const GUID _glfw_GUID_RyAxis
static const GUID _glfw_GUID_POV
static GLFWbool supportsXInput(const GUID *guid)
#define GLFW_HAT_CENTERED
void _glfwDetectJoystickDisconnectionWin32(void)
static const GUID _glfw_GUID_ZAxis
static void closeJoystick(_GLFWjoystick *js)
static const char * getDeviceDescription(const XINPUT_CAPABILITIES *xic)
_GLFWjoystick joysticks[GLFW_JOYSTICK_LAST+1]
static BOOL CALLBACK deviceObjectCallback(const DIDEVICEOBJECTINSTANCEW *doi, void *user)
struct _GLFWobjenumWin32 _GLFWobjenumWin32