mirror of
https://github.com/glfw/glfw.git
synced 2026-09-21 16:44:11 +00:00
Renamed glfwGetJoystickPos to glfwGetJoystickAxes.
This commit is contained in:
@@ -528,7 +528,7 @@ int _glfwPlatformGetJoystickParam(int joy, int param)
|
||||
// Get joystick axis positions
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformGetJoystickPos(int joy, float* pos, int numaxes)
|
||||
int _glfwPlatformGetJoystickAxes(int joy, float* axes, int numaxes)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -556,12 +556,12 @@ int _glfwPlatformGetJoystickPos(int joy, float* pos, int numaxes)
|
||||
long readScale = axes->maxReport - axes->minReport;
|
||||
|
||||
if (readScale == 0)
|
||||
pos[i] = axes->value;
|
||||
axes[i] = axes->value;
|
||||
else
|
||||
pos[i] = (2.0f * (axes->value - axes->minReport) / readScale) - 1.0f;
|
||||
axes[i] = (2.0f * (axes->value - axes->minReport) / readScale) - 1.0f;
|
||||
|
||||
if (i & 1)
|
||||
pos[i] = -pos[i];
|
||||
axes[i] = -axes[i];
|
||||
}
|
||||
|
||||
return numaxes;
|
||||
|
||||
+1
-1
@@ -273,7 +273,7 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window);
|
||||
|
||||
// Joystick input
|
||||
int _glfwPlatformGetJoystickParam(int joy, int param);
|
||||
int _glfwPlatformGetJoystickPos(int joy, float* pos, int numaxes);
|
||||
int _glfwPlatformGetJoystickAxes(int joy, float* axes, int numaxes);
|
||||
int _glfwPlatformGetJoystickButtons(int joy, unsigned char* buttons, int numbuttons);
|
||||
|
||||
// Time input
|
||||
|
||||
+4
-4
@@ -61,7 +61,7 @@ GLFWAPI int glfwGetJoystickParam(int joy, int param)
|
||||
// Get joystick axis positions
|
||||
//========================================================================
|
||||
|
||||
GLFWAPI int glfwGetJoystickPos(int joy, float* pos, int numaxes)
|
||||
GLFWAPI int glfwGetJoystickAxes(int joy, float* axes, int numaxes)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -77,7 +77,7 @@ GLFWAPI int glfwGetJoystickPos(int joy, float* pos, int numaxes)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (pos == NULL || numaxes < 0)
|
||||
if (axes == NULL || numaxes < 0)
|
||||
{
|
||||
_glfwSetError(GLFW_INVALID_VALUE, NULL);
|
||||
return 0;
|
||||
@@ -85,9 +85,9 @@ GLFWAPI int glfwGetJoystickPos(int joy, float* pos, int numaxes)
|
||||
|
||||
// Clear positions
|
||||
for (i = 0; i < numaxes; i++)
|
||||
pos[i] = 0.0f;
|
||||
axes[i] = 0.0f;
|
||||
|
||||
return _glfwPlatformGetJoystickPos(joy, pos, numaxes);
|
||||
return _glfwPlatformGetJoystickAxes(joy, axes, numaxes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ int _glfwPlatformGetJoystickParam(int joy, int param)
|
||||
// Get joystick axis positions
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformGetJoystickPos(int joy, float* pos, int numaxes)
|
||||
int _glfwPlatformGetJoystickAxes(int joy, float* axes, int numaxes)
|
||||
{
|
||||
JOYCAPS jc;
|
||||
JOYINFOEX ji;
|
||||
@@ -137,22 +137,22 @@ int _glfwPlatformGetJoystickPos(int joy, float* pos, int numaxes)
|
||||
// Get position values for all axes
|
||||
axis = 0;
|
||||
if (axis < numaxes)
|
||||
pos[axis++] = calcJoystickPos(ji.dwXpos, jc.wXmin, jc.wXmax);
|
||||
axes[axis++] = calcJoystickPos(ji.dwXpos, jc.wXmin, jc.wXmax);
|
||||
|
||||
if (axis < numaxes)
|
||||
pos[axis++] = -calcJoystickPos(ji.dwYpos, jc.wYmin, jc.wYmax);
|
||||
axes[axis++] = -calcJoystickPos(ji.dwYpos, jc.wYmin, jc.wYmax);
|
||||
|
||||
if (axis < numaxes && jc.wCaps & JOYCAPS_HASZ)
|
||||
pos[axis++] = calcJoystickPos(ji.dwZpos, jc.wZmin, jc.wZmax);
|
||||
axes[axis++] = calcJoystickPos(ji.dwZpos, jc.wZmin, jc.wZmax);
|
||||
|
||||
if (axis < numaxes && jc.wCaps & JOYCAPS_HASR)
|
||||
pos[axis++] = calcJoystickPos(ji.dwRpos, jc.wRmin, jc.wRmax);
|
||||
axes[axis++] = calcJoystickPos(ji.dwRpos, jc.wRmin, jc.wRmax);
|
||||
|
||||
if (axis < numaxes && jc.wCaps & JOYCAPS_HASU)
|
||||
pos[axis++] = calcJoystickPos(ji.dwUpos, jc.wUmin, jc.wUmax);
|
||||
axes[axis++] = calcJoystickPos(ji.dwUpos, jc.wUmin, jc.wUmax);
|
||||
|
||||
if (axis < numaxes && jc.wCaps & JOYCAPS_HASV)
|
||||
pos[axis++] = -calcJoystickPos(ji.dwVpos, jc.wVmin, jc.wVmax);
|
||||
axes[axis++] = -calcJoystickPos(ji.dwVpos, jc.wVmin, jc.wVmax);
|
||||
|
||||
return axis;
|
||||
}
|
||||
|
||||
+2
-2
@@ -260,7 +260,7 @@ int _glfwPlatformGetJoystickParam(int joy, int param)
|
||||
// Get joystick axis positions
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformGetJoystickPos(int joy, float* pos, int numAxes)
|
||||
int _glfwPlatformGetJoystickAxes(int joy, float* axes, int numAxes)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -273,7 +273,7 @@ int _glfwPlatformGetJoystickPos(int joy, float* pos, int numAxes)
|
||||
numAxes = _glfwLibrary.X11.joystick[joy].numAxes;
|
||||
|
||||
for (i = 0; i < numAxes; i++)
|
||||
pos[i] = _glfwLibrary.X11.joystick[joy].axis[i];
|
||||
axes[i] = _glfwLibrary.X11.joystick[joy].axis[i];
|
||||
|
||||
return numAxes;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user