Renamed glfwGetJoystickPos to glfwGetJoystickAxes.

This commit is contained in:
Camilla Berglund 2012-08-29 18:31:12 +02:00
parent 38e4cc3dad
commit 2502e4d6f3
8 changed files with 21 additions and 20 deletions

View File

@ -564,7 +564,7 @@ GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun);
/* Joystick input */
GLFWAPI int glfwGetJoystickParam(int joy, int param);
GLFWAPI int glfwGetJoystickPos(int joy, float* pos, int numaxes);
GLFWAPI int glfwGetJoystickAxes(int joy, float* axes, int numaxes);
GLFWAPI int glfwGetJoystickButtons(int joy, unsigned char* buttons, int numbuttons);
/* Clipboard */

View File

@ -300,6 +300,7 @@ version of GLFW.</p>
<li>Renamed <code>GLFW_BUILD_DLL</code> to <code>_GLFW_BUILD_DLL</code></li>
<li>Renamed <code>version</code> test to <code>glfwinfo</code></li>
<li>Renamed <code>GLFW_NO_GLU</code> to <code>GLFW_INCLUDE_GLU</code> and made it disabled by default</li>
<li>Renamed <code>glfwGetJoystickPos</code> to <code>glfwGetJoystickAxes</code> to match <code>glfwGetJoystickButtons</code></li>
<li>Renamed mouse position functions to cursor position equivalents</li>
<li>Replaced <code>glfwOpenWindow</code> and <code>glfwCloseWindow</code> with <code>glfwCreateWindow</code> and <code>glfwDestroyWindow</code></li>
<li>Replaced ad hoc build system with CMake</li>

View File

@ -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;

View File

@ -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

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -137,7 +137,7 @@ static void refresh_joysticks(void)
j->axes = realloc(j->axes, j->axis_count * sizeof(float));
}
glfwGetJoystickPos(GLFW_JOYSTICK_1 + i, j->axes, j->axis_count);
glfwGetJoystickAxes(GLFW_JOYSTICK_1 + i, j->axes, j->axis_count);
button_count = glfwGetJoystickParam(GLFW_JOYSTICK_1 + i, GLFW_BUTTONS);
if (button_count != j->button_count)