float* _glfwPlatformGetJoystickAxes(int joy, int* count) { JOYCAPS jc; JOYINFOEX ji; float* axes = _glfw.win32.joystick[joy].axes; if (_glfw_joyGetDevCaps(joy, &jc, sizeof(JOYCAPS)) != JOYERR_NOERROR) return NULL; ji.dwSize = sizeof(JOYINFOEX); ji.dwFlags = JOY_RETURNX | JOY_RETURNY | JOY_RETURNZ | JOY_RETURNR | JOY_RETURNU | JOY_RETURNV; if (_glfw_joyGetPosEx(joy, &ji) != JOYERR_NOERROR) return NULL; axes[(*count)++] = calcJoystickPos(ji.dwXpos, jc.wXmin, jc.wXmax); axes[(*count)++] = -calcJoystickPos(ji.dwYpos, jc.wYmin, jc.wYmax); if (jc.wCaps & JOYCAPS_HASZ) axes[(*count)++] = calcJoystickPos(ji.dwZpos, jc.wZmin, jc.wZmax); if (jc.wCaps & JOYCAPS_HASR) axes[(*count)++] = calcJoystickPos(ji.dwRpos, jc.wRmin, jc.wRmax); if (jc.wCaps & JOYCAPS_HASU) axes[(*count)++] = calcJoystickPos(ji.dwUpos, jc.wUmin, jc.wUmax); if (jc.wCaps & JOYCAPS_HASV) axes[(*count)++] = -calcJoystickPos(ji.dwVpos, jc.wVmin, jc.wVmax); return axes; }
int _glfwPlatformGetJoystickPos(int joy, float* pos, int numaxes) { JOYCAPS jc; JOYINFOEX ji; int axis; if (!isJoystickPresent(joy)) return 0; // Get joystick capabilities _glfw_joyGetDevCaps(joy - GLFW_JOYSTICK_1, &jc, sizeof(JOYCAPS)); // Get joystick state ji.dwSize = sizeof(JOYINFOEX); ji.dwFlags = JOY_RETURNX | JOY_RETURNY | JOY_RETURNZ | JOY_RETURNR | JOY_RETURNU | JOY_RETURNV; _glfw_joyGetPosEx(joy - GLFW_JOYSTICK_1, &ji); // Get position values for all axes axis = 0; if (axis < numaxes) pos[axis++] = calcJoystickPos(ji.dwXpos, jc.wXmin, jc.wXmax); if (axis < numaxes) pos[axis++] = -calcJoystickPos(ji.dwYpos, jc.wYmin, jc.wYmax); if (axis < numaxes && jc.wCaps & JOYCAPS_HASZ) pos[axis++] = calcJoystickPos(ji.dwZpos, jc.wZmin, jc.wZmax); if (axis < numaxes && jc.wCaps & JOYCAPS_HASR) pos[axis++] = calcJoystickPos(ji.dwRpos, jc.wRmin, jc.wRmax); if (axis < numaxes && jc.wCaps & JOYCAPS_HASU) pos[axis++] = calcJoystickPos(ji.dwUpos, jc.wUmin, jc.wUmax); if (axis < numaxes && jc.wCaps & JOYCAPS_HASV) pos[axis++] = -calcJoystickPos(ji.dwVpos, jc.wVmin, jc.wVmax); return axis; }