Rename joystick ID variables

This commit is contained in:
Camilla Berglund
2016-10-10 03:24:07 +02:00
parent bf747e32b4
commit efc6b35615
9 changed files with 119 additions and 119 deletions
+23 -23
View File
@@ -272,24 +272,24 @@ static void matchCallback(void* context,
IOHIDDeviceRef deviceRef)
{
_GLFWjoystickNS* js;
int joy;
int jid;
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (_glfw.ns_js[joy].present && _glfw.ns_js[joy].deviceRef == deviceRef)
if (_glfw.ns_js[jid].present && _glfw.ns_js[jid].deviceRef == deviceRef)
return;
}
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (!_glfw.ns_js[joy].present)
if (!_glfw.ns_js[jid].present)
break;
}
if (joy > GLFW_JOYSTICK_LAST)
if (jid > GLFW_JOYSTICK_LAST)
return;
js = _glfw.ns_js + joy;
js = _glfw.ns_js + jid;
js->present = GLFW_TRUE;
js->deviceRef = deviceRef;
@@ -324,7 +324,7 @@ static void matchCallback(void* context,
js->buttons = calloc(CFArrayGetCount(js->buttonElements) +
CFArrayGetCount(js->hatElements) * 4, 1);
_glfwInputJoystickChange(joy, GLFW_CONNECTED);
_glfwInputJoystickChange(jid, GLFW_CONNECTED);
}
// Callback for user-initiated joystick removal
@@ -334,13 +334,13 @@ static void removeCallback(void* context,
void* sender,
IOHIDDeviceRef deviceRef)
{
int joy;
int jid;
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (_glfw.ns_js[joy].deviceRef == deviceRef)
if (_glfw.ns_js[jid].deviceRef == deviceRef)
{
removeJoystick(_glfw.ns_js + joy);
removeJoystick(_glfw.ns_js + jid);
break;
}
}
@@ -456,11 +456,11 @@ void _glfwInitJoysticksNS(void)
//
void _glfwTerminateJoysticksNS(void)
{
int joy;
int jid;
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
{
_GLFWjoystickNS* js = _glfw.ns_js + joy;
_GLFWjoystickNS* js = _glfw.ns_js + jid;
removeJoystick(js);
}
@@ -473,15 +473,15 @@ void _glfwTerminateJoysticksNS(void)
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
int _glfwPlatformJoystickPresent(int joy)
int _glfwPlatformJoystickPresent(int jid)
{
_GLFWjoystickNS* js = _glfw.ns_js + joy;
_GLFWjoystickNS* js = _glfw.ns_js + jid;
return js->present;
}
const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
const float* _glfwPlatformGetJoystickAxes(int jid, int* count)
{
_GLFWjoystickNS* js = _glfw.ns_js + joy;
_GLFWjoystickNS* js = _glfw.ns_js + jid;
if (!pollJoystickAxisEvents(js))
return NULL;
@@ -489,9 +489,9 @@ const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
return js->axes;
}
const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
const unsigned char* _glfwPlatformGetJoystickButtons(int jid, int* count)
{
_GLFWjoystickNS* js = _glfw.ns_js + joy;
_GLFWjoystickNS* js = _glfw.ns_js + jid;
if (!pollJoystickButtonEvents(js))
return NULL;
@@ -500,9 +500,9 @@ const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
return js->buttons;
}
const char* _glfwPlatformGetJoystickName(int joy)
const char* _glfwPlatformGetJoystickName(int jid)
{
_GLFWjoystickNS* js = _glfw.ns_js + joy;
_GLFWjoystickNS* js = _glfw.ns_js + jid;
if (!js->present)
return NULL;
+18 -18
View File
@@ -124,10 +124,10 @@ void _glfwInputDrop(_GLFWwindow* window, int count, const char** paths)
window->callbacks.drop((GLFWwindow*) window, count, paths);
}
void _glfwInputJoystickChange(int joy, int event)
void _glfwInputJoystickChange(int jid, int event)
{
if (_glfw.callbacks.joystick)
_glfw.callbacks.joystick(joy, event);
_glfw.callbacks.joystick(jid, event);
}
@@ -553,62 +553,62 @@ GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun)
return cbfun;
}
GLFWAPI int glfwJoystickPresent(int joy)
GLFWAPI int glfwJoystickPresent(int jid)
{
_GLFW_REQUIRE_INIT_OR_RETURN(0);
if (joy < 0 || joy > GLFW_JOYSTICK_LAST)
if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick %i", joy);
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick %i", jid);
return 0;
}
return _glfwPlatformJoystickPresent(joy);
return _glfwPlatformJoystickPresent(jid);
}
GLFWAPI const float* glfwGetJoystickAxes(int joy, int* count)
GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count)
{
assert(count != NULL);
*count = 0;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (joy < 0 || joy > GLFW_JOYSTICK_LAST)
if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick %i", joy);
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick %i", jid);
return NULL;
}
return _glfwPlatformGetJoystickAxes(joy, count);
return _glfwPlatformGetJoystickAxes(jid, count);
}
GLFWAPI const unsigned char* glfwGetJoystickButtons(int joy, int* count)
GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count)
{
assert(count != NULL);
*count = 0;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (joy < 0 || joy > GLFW_JOYSTICK_LAST)
if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick %i", joy);
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick %i", jid);
return NULL;
}
return _glfwPlatformGetJoystickButtons(joy, count);
return _glfwPlatformGetJoystickButtons(jid, count);
}
GLFWAPI const char* glfwGetJoystickName(int joy)
GLFWAPI const char* glfwGetJoystickName(int jid)
{
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (joy < 0 || joy > GLFW_JOYSTICK_LAST)
if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick %i", joy);
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick %i", jid);
return NULL;
}
return _glfwPlatformGetJoystickName(joy);
return _glfwPlatformGetJoystickName(jid);
}
GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun)
+6 -6
View File
@@ -608,22 +608,22 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window);
/*! @copydoc glfwJoystickPresent
* @ingroup platform
*/
int _glfwPlatformJoystickPresent(int joy);
int _glfwPlatformJoystickPresent(int jid);
/*! @copydoc glfwGetJoystickAxes
* @ingroup platform
*/
const float* _glfwPlatformGetJoystickAxes(int joy, int* count);
const float* _glfwPlatformGetJoystickAxes(int jid, int* count);
/*! @copydoc glfwGetJoystickButtons
* @ingroup platform
*/
const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count);
const unsigned char* _glfwPlatformGetJoystickButtons(int jid, int* count);
/*! @copydoc glfwGetJoystickName
* @ingroup platform
*/
const char* _glfwPlatformGetJoystickName(int joy);
const char* _glfwPlatformGetJoystickName(int jid);
/*! @copydoc glfwGetTimerValue
* @ingroup platform
@@ -961,11 +961,11 @@ void _glfwInputError(int error, const char* format, ...);
void _glfwInputDrop(_GLFWwindow* window, int count, const char** names);
/*! @brief Notifies shared code of a joystick connection/disconnection event.
* @param[in] joy The joystick that was connected or disconnected.
* @param[in] jid The joystick that was connected or disconnected.
* @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`.
* @ingroup event
*/
void _glfwInputJoystickChange(int joy, int event);
void _glfwInputJoystickChange(int jid, int event);
//========================================================================
+17 -17
View File
@@ -50,25 +50,25 @@ static GLFWbool openJoystickDevice(const char* path)
{
char axisCount, buttonCount;
char name[256] = "";
int joy, fd, version;
int jid, fd, version;
_GLFWjoystickLinux* js;
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (!_glfw.linux_js.js[joy].present)
if (!_glfw.linux_js.js[jid].present)
continue;
if (strcmp(_glfw.linux_js.js[joy].path, path) == 0)
if (strcmp(_glfw.linux_js.js[jid].path, path) == 0)
return GLFW_FALSE;
}
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (!_glfw.linux_js.js[joy].present)
if (!_glfw.linux_js.js[jid].present)
break;
}
if (joy > GLFW_JOYSTICK_LAST)
if (jid > GLFW_JOYSTICK_LAST)
return GLFW_FALSE;
fd = open(path, O_RDONLY | O_NONBLOCK);
@@ -87,7 +87,7 @@ static GLFWbool openJoystickDevice(const char* path)
if (ioctl(fd, JSIOCGNAME(sizeof(name)), name) < 0)
strncpy(name, "Unknown", sizeof(name));
js = _glfw.linux_js.js + joy;
js = _glfw.linux_js.js + jid;
js->present = GLFW_TRUE;
js->name = strdup(name);
js->path = strdup(path);
@@ -101,7 +101,7 @@ static GLFWbool openJoystickDevice(const char* path)
js->buttonCount = (int) buttonCount;
js->buttons = calloc(buttonCount, 1);
_glfwInputJoystickChange(joy, GLFW_CONNECTED);
_glfwInputJoystickChange(jid, GLFW_CONNECTED);
return GLFW_TRUE;
}
#endif // __linux__
@@ -304,15 +304,15 @@ void _glfwPollJoystickEvents(void)
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
int _glfwPlatformJoystickPresent(int joy)
int _glfwPlatformJoystickPresent(int jid)
{
_GLFWjoystickLinux* js = _glfw.linux_js.js + joy;
_GLFWjoystickLinux* js = _glfw.linux_js.js + jid;
return pollJoystickEvents(js);
}
const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
const float* _glfwPlatformGetJoystickAxes(int jid, int* count)
{
_GLFWjoystickLinux* js = _glfw.linux_js.js + joy;
_GLFWjoystickLinux* js = _glfw.linux_js.js + jid;
if (!pollJoystickEvents(js))
return NULL;
@@ -320,9 +320,9 @@ const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
return js->axes;
}
const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
const unsigned char* _glfwPlatformGetJoystickButtons(int jid, int* count)
{
_GLFWjoystickLinux* js = _glfw.linux_js.js + joy;
_GLFWjoystickLinux* js = _glfw.linux_js.js + jid;
if (!pollJoystickEvents(js))
return NULL;
@@ -330,9 +330,9 @@ const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
return js->buttons;
}
const char* _glfwPlatformGetJoystickName(int joy)
const char* _glfwPlatformGetJoystickName(int jid)
{
_GLFWjoystickLinux* js = _glfw.linux_js.js + joy;
_GLFWjoystickLinux* js = _glfw.linux_js.js + jid;
if (!pollJoystickEvents(js))
return NULL;
+32 -32
View File
@@ -332,26 +332,26 @@ static BOOL CALLBACK deviceObjectCallback(const DIDEVICEOBJECTINSTANCEW* doi,
//
static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
{
int joy = 0;
int jid = 0;
DIDEVCAPS dc;
DIPROPDWORD dipd;
IDirectInputDevice8* device;
_GLFWobjenumWin32 data;
_GLFWjoystickWin32* js;
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (memcmp(&_glfw.win32_js[joy].guid, &di->guidInstance, sizeof(GUID)) == 0)
if (memcmp(&_glfw.win32_js[jid].guid, &di->guidInstance, sizeof(GUID)) == 0)
return DIENUM_CONTINUE;
}
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (!_glfw.win32_js[joy].present)
if (!_glfw.win32_js[jid].present)
break;
}
if (joy > GLFW_JOYSTICK_LAST)
if (jid > GLFW_JOYSTICK_LAST)
return DIENUM_STOP;
if (supportsXInput(&di->guidProduct))
@@ -426,7 +426,7 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
sizeof(_GLFWjoyobjectWin32),
compareJoystickObjects);
js = _glfw.win32_js + joy;
js = _glfw.win32_js + jid;
js->device = device;
js->guid = di->guidInstance;
js->axisCount = data.axisCount + data.sliderCount;
@@ -438,7 +438,7 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
js->name = _glfwCreateUTF8FromWideStringWin32(di->tszInstanceName);
js->present = GLFW_TRUE;
_glfwInputJoystickChange(joy, GLFW_CONNECTED);
_glfwInputJoystickChange(jid, GLFW_CONNECTED);
return DIENUM_CONTINUE;
}
@@ -447,33 +447,33 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
//
static GLFWbool openXinputDevice(DWORD index)
{
int joy;
int jid;
XINPUT_CAPABILITIES xic;
_GLFWjoystickWin32* js;
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (_glfw.win32_js[joy].present &&
_glfw.win32_js[joy].device == NULL &&
_glfw.win32_js[joy].index == index)
if (_glfw.win32_js[jid].present &&
_glfw.win32_js[jid].device == NULL &&
_glfw.win32_js[jid].index == index)
{
return GLFW_FALSE;
}
}
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (!_glfw.win32_js[joy].present)
if (!_glfw.win32_js[jid].present)
break;
}
if (joy > GLFW_JOYSTICK_LAST)
if (jid > GLFW_JOYSTICK_LAST)
return GLFW_FALSE;
if (_glfw_XInputGetCapabilities(index, 0, &xic) != ERROR_SUCCESS)
return GLFW_FALSE;
js = _glfw.win32_js + joy;
js = _glfw.win32_js + jid;
js->axisCount = 6;
js->axes = calloc(js->axisCount, sizeof(float));
js->buttonCount = 14;
@@ -482,7 +482,7 @@ static GLFWbool openXinputDevice(DWORD index)
js->name = strdup(getDeviceDescription(&xic));
js->index = index;
_glfwInputJoystickChange(joy, GLFW_CONNECTED);
_glfwInputJoystickChange(jid, GLFW_CONNECTED);
return GLFW_TRUE;
}
@@ -675,10 +675,10 @@ void _glfwInitJoysticksWin32(void)
//
void _glfwTerminateJoysticksWin32(void)
{
int joy;
int jid;
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
closeJoystick(_glfw.win32_js + joy);
for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
closeJoystick(_glfw.win32_js + jid);
if (_glfw.win32.dinput8.api)
IDirectInput8_Release(_glfw.win32.dinput8.api);
@@ -715,10 +715,10 @@ void _glfwDetectJoystickConnectionWin32(void)
//
void _glfwDetectJoystickDisconnectionWin32(void)
{
int joy;
int jid;
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
pollJoystickState(_glfw.win32_js + joy, _GLFW_PRESENCE_ONLY);
for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
pollJoystickState(_glfw.win32_js + jid, _GLFW_PRESENCE_ONLY);
}
@@ -726,15 +726,15 @@ void _glfwDetectJoystickDisconnectionWin32(void)
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
int _glfwPlatformJoystickPresent(int joy)
int _glfwPlatformJoystickPresent(int jid)
{
_GLFWjoystickWin32* js = _glfw.win32_js + joy;
_GLFWjoystickWin32* js = _glfw.win32_js + jid;
return pollJoystickState(js, _GLFW_PRESENCE_ONLY);
}
const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
const float* _glfwPlatformGetJoystickAxes(int jid, int* count)
{
_GLFWjoystickWin32* js = _glfw.win32_js + joy;
_GLFWjoystickWin32* js = _glfw.win32_js + jid;
if (!pollJoystickState(js, _GLFW_UPDATE_STATE))
return NULL;
@@ -742,9 +742,9 @@ const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
return js->axes;
}
const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
const unsigned char* _glfwPlatformGetJoystickButtons(int jid, int* count)
{
_GLFWjoystickWin32* js = _glfw.win32_js + joy;
_GLFWjoystickWin32* js = _glfw.win32_js + jid;
if (!pollJoystickState(js, _GLFW_UPDATE_STATE))
return NULL;
@@ -752,9 +752,9 @@ const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
return js->buttons;
}
const char* _glfwPlatformGetJoystickName(int joy)
const char* _glfwPlatformGetJoystickName(int jid)
{
_GLFWjoystickWin32* js = _glfw.win32_js + joy;
_GLFWjoystickWin32* js = _glfw.win32_js + jid;
if (!pollJoystickState(js, _GLFW_PRESENCE_ONLY))
return NULL;