Disable device check routine in daemon

Prior to this change, the device check was sending a vendor specific
command with wIndex and wValue both set to 0 every 50 ms. On some
systems, this was causing issues with the joystick flapping the state,
and reporting weird values from the stick, and generally sluggish
response.

This change uses the updated libx52 library which uses the hotplug
notification to determine if the device is connected, and should resolve
the issues seen.

Fixes #33
reverse-scroll
nirenjan 2021-09-13 21:05:42 -07:00
parent 627c1fb004
commit 7d757dd40f
4 changed files with 25 additions and 47 deletions

View File

@ -90,7 +90,17 @@ static void *x52_dev_upd(void *param)
if (!device_update_needed || !device_upd_thr_enable) {
usleep(UPDATE_CHECK_DELAY);
/* Check if the device is still connected */
x52d_dev_check();
if (device_upd_thr_enable && !libx52_is_connected(x52_dev)) {
// Detach and spawn thread to reconnect
PINELOG_TRACE("Disconnecting detached device");
libx52_disconnect(x52_dev);
PINELOG_TRACE("Disabling device update thread");
device_upd_thr_enable = false;
PINELOG_TRACE("Signaling device search thread");
device_acq_thr_enable = true;
}
continue;
}
@ -232,34 +242,3 @@ int x52d_dev_update(void)
return rc;
}
void x52d_dev_check(void)
{
int rc;
if (!libx52_is_connected(x52_dev)) {
return;
}
pthread_mutex_lock(&device_mutex);
/* Use a dummy vendor command to check if the device is connected */
rc = libx52_vendor_command(x52_dev, 0, 0);
pthread_mutex_unlock(&device_mutex);
if (rc != LIBX52_SUCCESS) {
if (rc == LIBX52_ERROR_NO_DEVICE) {
// Detach and spawn thread to reconnect
PINELOG_TRACE("Disconnecting detached device");
libx52_disconnect(x52_dev);
PINELOG_TRACE("Disabling device update thread");
device_upd_thr_enable = false;
PINELOG_TRACE("Signaling device search thread");
device_acq_thr_enable = true;
} else {
PINELOG_ERROR(_("Error %d when updating X52 device: %s"),
rc, libx52_strerror(rc));
}
}
}

View File

@ -27,6 +27,5 @@ int x52d_dev_set_brightness(uint8_t mfd, uint16_t brightness);
int x52d_dev_set_shift(uint8_t state);
int x52d_dev_set_blink(uint8_t state);
int x52d_dev_update(void);
void x52d_dev_check(void);
#endif // !defined X52D_DEVICE_H

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: x52pro-linux 0.2.2\n"
"Report-Msgid-Bugs-To: https://github.com/nirenjan/x52pro-linux/issues\n"
"POT-Creation-Date: 2021-08-30 12:33-0700\n"
"POT-Creation-Date: 2021-09-14 01:00-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -688,29 +688,29 @@ msgstr ""
msgid "Starting X52 device update thread"
msgstr ""
#: daemon/x52d_device.c:107
#: daemon/x52d_device.c:117
msgid "Initializing libx52"
msgstr ""
#: daemon/x52d_device.c:111
#: daemon/x52d_device.c:121
#, c-format
msgid "Failure %d initializing libx52: %s"
msgstr ""
#: daemon/x52d_device.c:130
#: daemon/x52d_device.c:140
msgid "Shutting down X52 device acquisition thread"
msgstr ""
#: daemon/x52d_device.c:133
#: daemon/x52d_device.c:143
msgid "Shutting down X52 device update thread"
msgstr ""
#: daemon/x52d_device.c:146
#: daemon/x52d_device.c:156
#, c-format
msgid "Error %d when updating X52 parameter: %s"
msgstr ""
#: daemon/x52d_device.c:226 daemon/x52d_device.c:261
#: daemon/x52d_device.c:236
#, c-format
msgid "Error %d when updating X52 device: %s"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: x52pro-linux 0.2.1\n"
"Report-Msgid-Bugs-To: https://github.com/nirenjan/x52pro-linux/issues\n"
"POT-Creation-Date: 2021-08-30 12:33-0700\n"
"POT-Creation-Date: 2021-09-14 01:00-0700\n"
"PO-Revision-Date: 2021-08-30 10:41-0700\n"
"Last-Translator: Nirenjan Krishnan <nirenjan@gmail.com>\n"
"Language-Team: Dummy Language for testing i18n\n"
@ -737,29 +737,29 @@ msgstr "Eviceday onnectedcay, itingwray onfigurationcay"
msgid "Starting X52 device update thread"
msgstr "Artingstay X52 eviceday updateay eadthray"
#: daemon/x52d_device.c:107
#: daemon/x52d_device.c:117
msgid "Initializing libx52"
msgstr "Initializingay libx52"
#: daemon/x52d_device.c:111
#: daemon/x52d_device.c:121
#, c-format
msgid "Failure %d initializing libx52: %s"
msgstr "Ailurefay %d initializeay libx52: %s"
#: daemon/x52d_device.c:130
#: daemon/x52d_device.c:140
msgid "Shutting down X52 device acquisition thread"
msgstr "Uttingshay ownday X52 eviceday acquisitionay eadthray"
#: daemon/x52d_device.c:133
#: daemon/x52d_device.c:143
msgid "Shutting down X52 device update thread"
msgstr "Uttingshay ownday X52 eviceday updateay eadthray"
#: daemon/x52d_device.c:146
#: daemon/x52d_device.c:156
#, c-format
msgid "Error %d when updating X52 parameter: %s"
msgstr "Erroray %d enwhay updatingay X52 arameterpay: %s"
#: daemon/x52d_device.c:226 daemon/x52d_device.c:261
#: daemon/x52d_device.c:236
#, c-format
msgid "Error %d when updating X52 device: %s"
msgstr "Erroray %d enwhay updatingay X52 eviceday: %s"