Compare commits

...

2 Commits

Author SHA1 Message Date
Zhong Jianxin
bd32b2b030 Merge 51fb2f5fb3 into 3c84610b74 2023-08-05 20:43:06 +08:00
Zhong Jianxin
51fb2f5fb3 Fix device hotplug
Fix #27
2023-08-05 20:38:56 +08:00

View File

@@ -417,10 +417,15 @@ void listenJoy (void) {
sysPath = udev_device_get_syspath(mydev);
devPath = udev_device_get_devnode(mydev);
if (sysPath != NULL && devPath != NULL && strstr(sysPath, myDevPath) != 0) {
syslog(LOG_NOTICE, "Found Device: %s\n", devPath);
if ((joyFD = open(devPath, O_RDONLY)) < 0) { // Open the file descriptor
syslog(LOG_INFO, "error: failed to open fd\n");
if (sysPath != NULL && devPath != NULL && strstr(sysPath, "/js") != 0) {
syslog (LOG_NOTICE, "Found Device: %s\n", devPath);
if (joyFD < 0 || strcmp(devPath, myDevPath) == 0) {
// Open the file descriptor
if ((joyFD = open(devPath, O_RDONLY)) < 0) {
syslog (LOG_INFO, "error: failed to open fd\n");
} else {
syslog (LOG_NOTICE, "Watching: %s\n", devPath);
}
}
}