41 float fpos = (float) pos;
42 float fmin = (float) min;
43 float fmax = (float) max;
45 return (2.
f * (fpos - fmin) / (fmax - fmin)) - 1.f;
66 free(
_glfw.winmm_js[i].name);
88 float* axes =
_glfw.winmm_js[joy].axes;
93 ji.dwSize =
sizeof(JOYINFOEX);
94 ji.dwFlags = JOY_RETURNX | JOY_RETURNY | JOY_RETURNZ |
95 JOY_RETURNR | JOY_RETURNU | JOY_RETURNV;
99 axes[(*count)++] =
normalizeAxis(ji.dwXpos, jc.wXmin, jc.wXmax);
100 axes[(*count)++] =
normalizeAxis(ji.dwYpos, jc.wYmin, jc.wYmax);
102 if (jc.wCaps & JOYCAPS_HASZ)
103 axes[(*count)++] =
normalizeAxis(ji.dwZpos, jc.wZmin, jc.wZmax);
105 if (jc.wCaps & JOYCAPS_HASR)
106 axes[(*count)++] =
normalizeAxis(ji.dwRpos, jc.wRmin, jc.wRmax);
108 if (jc.wCaps & JOYCAPS_HASU)
109 axes[(*count)++] =
normalizeAxis(ji.dwUpos, jc.wUmin, jc.wUmax);
111 if (jc.wCaps & JOYCAPS_HASV)
112 axes[(*count)++] =
normalizeAxis(ji.dwVpos, jc.wVmin, jc.wVmax);
121 unsigned char* buttons =
_glfw.winmm_js[joy].buttons;
126 ji.dwSize =
sizeof(JOYINFOEX);
127 ji.dwFlags = JOY_RETURNBUTTONS | JOY_RETURNPOV;
131 while (*count < (
int) jc.wNumButtons)
133 buttons[*
count] = (
unsigned char)
143 if ((jc.wCaps & JOYCAPS_HASPOV) && (jc.wCaps & JOYCAPS_POV4DIR))
145 int i,
value = ji.dwPOV / 100 / 45;
148 const int directions[9] = { 1, 3, 2, 6, 4, 12, 8, 9, 0 };
153 for (i = 0; i < 4; i++)
155 if (directions[value] & (1 << i))
172 free(
_glfw.winmm_js[joy].name);
175 return _glfw.winmm_js[joy].name;
_GLFWlibrary _glfw
All global data protected by _glfwInitialized. This should only be touched after a call to glfwInit t...
void _glfwInitJoysticks(void)
GLuint GLuint GLsizei count
#define GLFW_JOYSTICK_LAST
void _glfwTerminateJoysticks(void)
GLsizei const GLfloat * value
static float normalizeAxis(DWORD pos, DWORD min, DWORD max)
char * _glfwCreateUTF8FromWideString(const WCHAR *source)