mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Cleanup
This commit is contained in:
parent
6da26c8d6c
commit
99762ad7f0
@ -287,15 +287,12 @@ GLFWbool _glfwInitJoysticksLinux(void)
|
|||||||
if (regexec(&_glfw.linjs.regex, entry->d_name, 1, &match, 0) != 0)
|
if (regexec(&_glfw.linjs.regex, entry->d_name, 1, &match, 0) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const size_t length = strlen(dirname) + strlen(entry->d_name) + 1;
|
char path[PATH_MAX];
|
||||||
char* path = calloc(length + 1, 1);
|
|
||||||
|
|
||||||
snprintf(path, length + 1, "%s/%s", dirname, entry->d_name);
|
snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
|
||||||
|
|
||||||
if (openJoystickDevice(path))
|
if (openJoystickDevice(path))
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
free(path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
@ -349,9 +346,12 @@ void _glfwDetectJoystickConnectionLinux(void)
|
|||||||
regmatch_t match;
|
regmatch_t match;
|
||||||
const struct inotify_event* e = (struct inotify_event*) (buffer + offset);
|
const struct inotify_event* e = (struct inotify_event*) (buffer + offset);
|
||||||
|
|
||||||
if (regexec(&_glfw.linjs.regex, e->name, 1, &match, 0) == 0)
|
offset += sizeof(struct inotify_event) + e->len;
|
||||||
{
|
|
||||||
char path[20];
|
if (regexec(&_glfw.linjs.regex, e->name, 1, &match, 0) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
char path[PATH_MAX];
|
||||||
snprintf(path, sizeof(path), "/dev/input/%s", e->name);
|
snprintf(path, sizeof(path), "/dev/input/%s", e->name);
|
||||||
|
|
||||||
if (e->mask & (IN_CREATE | IN_ATTRIB))
|
if (e->mask & (IN_CREATE | IN_ATTRIB))
|
||||||
@ -370,9 +370,6 @@ void _glfwDetectJoystickConnectionLinux(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
offset += sizeof(struct inotify_event) + e->len;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user