From 2502e4d6f36011732d14e9253faeeb88a743e536 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Wed, 29 Aug 2012 18:31:12 +0200
Subject: [PATCH] Renamed glfwGetJoystickPos to glfwGetJoystickAxes.
---
include/GL/glfw3.h | 2 +-
readme.html | 1 +
src/cocoa_joystick.m | 8 ++++----
src/internal.h | 2 +-
src/joystick.c | 8 ++++----
src/win32_joystick.c | 14 +++++++-------
src/x11_joystick.c | 4 ++--
tests/joysticks.c | 2 +-
8 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index 5172da21..45f44339 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -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 */
diff --git a/readme.html b/readme.html
index 23c9113f..d330d1c1 100644
--- a/readme.html
+++ b/readme.html
@@ -300,6 +300,7 @@ version of GLFW.
Renamed GLFW_BUILD_DLL
to _GLFW_BUILD_DLL
Renamed version
test to glfwinfo
Renamed GLFW_NO_GLU
to GLFW_INCLUDE_GLU
and made it disabled by default
+ Renamed glfwGetJoystickPos
to glfwGetJoystickAxes
to match glfwGetJoystickButtons
Renamed mouse position functions to cursor position equivalents
Replaced glfwOpenWindow
and glfwCloseWindow
with glfwCreateWindow
and glfwDestroyWindow
Replaced ad hoc build system with CMake
diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m
index ff4ba958..7eac7f91 100644
--- a/src/cocoa_joystick.m
+++ b/src/cocoa_joystick.m
@@ -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;
diff --git a/src/internal.h b/src/internal.h
index 8fe3b241..c83b0949 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -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
diff --git a/src/joystick.c b/src/joystick.c
index d7f98758..84763951 100644
--- a/src/joystick.c
+++ b/src/joystick.c
@@ -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);
}
diff --git a/src/win32_joystick.c b/src/win32_joystick.c
index fcc6b599..a51773d3 100644
--- a/src/win32_joystick.c
+++ b/src/win32_joystick.c
@@ -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;
}
diff --git a/src/x11_joystick.c b/src/x11_joystick.c
index 09885373..a5700c68 100644
--- a/src/x11_joystick.c
+++ b/src/x11_joystick.c
@@ -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;
}
diff --git a/tests/joysticks.c b/tests/joysticks.c
index 488f98ad..40202ce7 100644
--- a/tests/joysticks.c
+++ b/tests/joysticks.c
@@ -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)