New joystick API.

This commit is contained in:
Camilla Berglund
2013-04-24 19:25:42 +02:00
parent c4d856bcb2
commit 7f2eb7b15b
10 changed files with 280 additions and 461 deletions
+12 -34
View File
@@ -35,7 +35,7 @@
////// GLFW public API //////
//////////////////////////////////////////////////////////////////////////
GLFWAPI int glfwGetJoystickParam(int joy, int param)
GLFWAPI int glfwJoystickPresent(int joy)
{
_GLFW_REQUIRE_INIT_OR_RETURN(0);
@@ -45,59 +45,37 @@ GLFWAPI int glfwGetJoystickParam(int joy, int param)
return 0;
}
return _glfwPlatformGetJoystickParam(joy, param);
return _glfwPlatformJoystickPresent(joy);
}
GLFWAPI int glfwGetJoystickAxes(int joy, float* axes, int numaxes)
GLFWAPI float* glfwGetJoystickAxes(int joy, int* count)
{
int i;
*count = 0;
_GLFW_REQUIRE_INIT_OR_RETURN(0);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (joy < 0 || joy > GLFW_JOYSTICK_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM, NULL);
return 0;
return NULL;
}
if (axes == NULL || numaxes < 0)
{
_glfwInputError(GLFW_INVALID_VALUE, NULL);
return 0;
}
// Clear positions
for (i = 0; i < numaxes; i++)
axes[i] = 0.0f;
return _glfwPlatformGetJoystickAxes(joy, axes, numaxes);
return _glfwPlatformGetJoystickAxes(joy, count);
}
GLFWAPI int glfwGetJoystickButtons(int joy,
unsigned char* buttons,
int numbuttons)
GLFWAPI unsigned char* glfwGetJoystickButtons(int joy, int* count)
{
int i;
*count = 0;
_GLFW_REQUIRE_INIT_OR_RETURN(0);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (joy < 0 || joy > GLFW_JOYSTICK_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM, NULL);
return 0;
return NULL;
}
if (buttons == NULL || numbuttons < 0)
{
_glfwInputError(GLFW_INVALID_VALUE, NULL);
return 0;
}
// Clear button states
for (i = 0; i < numbuttons; i++)
buttons[i] = GLFW_RELEASE;
return _glfwPlatformGetJoystickButtons(joy, buttons, numbuttons);
return _glfwPlatformGetJoystickButtons(joy, count);
}
GLFWAPI const char* glfwGetJoystickName(int joy)