mirror of https://github.com/nirenjan/libx52.git
Fix use of libx52io return codes
Prior to this change, we were treating ERROR_NO_DEVICE as if the hidapi library itself would return such a code. However, that is not the case, and we should be treating any error condition as a critical issue and treat it as if the device was disconnected. The worst case scenario is that it would have to re-enumerate the HID device list and reopen the joystick.reverse-scroll
parent
025a06351a
commit
c56f715155
|
@ -34,7 +34,6 @@ static void *x52_io_thr(void *param)
|
|||
int rc;
|
||||
libx52io_report report;
|
||||
libx52io_report prev_report;
|
||||
bool connected = false;
|
||||
|
||||
#define IO_READ_TIMEOUT 50 /* milliseconds */
|
||||
#define IO_ACQ_TIMEOUT 5 /* seconds */
|
||||
|
@ -44,20 +43,6 @@ static void *x52_io_thr(void *param)
|
|||
memset(&prev_report, 0, sizeof(prev_report));
|
||||
|
||||
for (;;) {
|
||||
if (!connected) {
|
||||
rc = libx52io_open(io_ctx);
|
||||
if (rc == LIBX52IO_SUCCESS) {
|
||||
connected = true;
|
||||
} else {
|
||||
if (rc != LIBX52IO_ERROR_NO_DEVICE) {
|
||||
PINELOG_ERROR(_("Error %d opening X52 I/O device: %s"),
|
||||
rc, libx52io_strerror(rc));
|
||||
} else {
|
||||
PINELOG_TRACE("No compatible X52 I/O device found. Waiting %d seconds before trying again.", IO_ACQ_TIMEOUT);
|
||||
}
|
||||
sleep(IO_ACQ_TIMEOUT);
|
||||
}
|
||||
} else {
|
||||
rc = libx52io_read_timeout(io_ctx, &report, IO_READ_TIMEOUT);
|
||||
switch (rc) {
|
||||
case LIBX52IO_SUCCESS:
|
||||
|
@ -70,19 +55,35 @@ static void *x52_io_thr(void *param)
|
|||
break;
|
||||
|
||||
case LIBX52IO_ERROR_NO_DEVICE:
|
||||
PINELOG_TRACE("Device disconnected, signaling I/O connect thread");
|
||||
/* Report a NULL report to reset the mouse to default state */
|
||||
x52d_mouse_report_event(NULL);
|
||||
connected = false;
|
||||
PINELOG_TRACE("Device disconnected, trying to connect");
|
||||
rc = libx52io_open(io_ctx);
|
||||
if (rc != LIBX52IO_SUCCESS) {
|
||||
if (rc != LIBX52IO_ERROR_NO_DEVICE) {
|
||||
PINELOG_ERROR(_("Error %d opening X52 I/O device: %s"),
|
||||
rc, libx52io_strerror(rc));
|
||||
} else {
|
||||
PINELOG_TRACE("No compatible X52 I/O device found. Sleeping %d seconds before trying again.",
|
||||
IO_ACQ_TIMEOUT);
|
||||
}
|
||||
sleep(IO_ACQ_TIMEOUT);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
PINELOG_ERROR(_("Error %d reading from X52 I/O device: %s"),
|
||||
rc, libx52io_strerror(rc));
|
||||
|
||||
/*
|
||||
* Possibly disconnected, better to force disconnect now, and try
|
||||
* to reconnect later
|
||||
*/
|
||||
libx52io_close(io_ctx);
|
||||
|
||||
/* Report a NULL report to reset the mouse to default state */
|
||||
x52d_mouse_report_event(NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#undef IO_READ_TIMEOUT
|
||||
#undef IO_ACQ_TIMEOUT
|
||||
|
||||
|
|
|
@ -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-09-14 23:34-0700\n"
|
||||
"POT-Creation-Date: 2021-09-15 00:04-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"
|
||||
|
@ -715,31 +715,31 @@ msgstr ""
|
|||
msgid "Error %d when updating X52 device: %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_io.c:41
|
||||
#: daemon/x52d_io.c:40
|
||||
msgid "Starting X52 I/O thread"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_io.c:53
|
||||
#: daemon/x52d_io.c:62
|
||||
#, c-format
|
||||
msgid "Error %d opening X52 I/O device: %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_io.c:80
|
||||
#: daemon/x52d_io.c:73
|
||||
#, c-format
|
||||
msgid "Error %d reading from X52 I/O device: %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_io.c:99
|
||||
#: daemon/x52d_io.c:100
|
||||
#, c-format
|
||||
msgid "Error %d initializing X52 I/O library: %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_io.c:105
|
||||
#: daemon/x52d_io.c:106
|
||||
#, c-format
|
||||
msgid "Error %d initializing I/O driver thread: %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_io.c:112
|
||||
#: daemon/x52d_io.c:113
|
||||
msgid "Shutting down X52 I/O driver thread"
|
||||
msgstr ""
|
||||
|
||||
|
|
14
po/xx_PL.po
14
po/xx_PL.po
|
@ -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-09-14 23:34-0700\n"
|
||||
"POT-Creation-Date: 2021-09-15 00:04-0700\n"
|
||||
"PO-Revision-Date: 2021-09-14 17:07-0700\n"
|
||||
"Last-Translator: Nirenjan Krishnan <nirenjan@gmail.com>\n"
|
||||
"Language-Team: Dummy Language for testing i18n\n"
|
||||
|
@ -764,31 +764,31 @@ msgstr "Erroray %d enwhay updatingay X52 arameterpay: %s"
|
|||
msgid "Error %d when updating X52 device: %s"
|
||||
msgstr "Erroray %d enwhay updatingay X52 eviceday: %s"
|
||||
|
||||
#: daemon/x52d_io.c:41
|
||||
#: daemon/x52d_io.c:40
|
||||
msgid "Starting X52 I/O thread"
|
||||
msgstr "Artingstay X52 I/O eadthray"
|
||||
|
||||
#: daemon/x52d_io.c:53
|
||||
#: daemon/x52d_io.c:62
|
||||
#, c-format
|
||||
msgid "Error %d opening X52 I/O device: %s"
|
||||
msgstr "Erroray %d openingay X52 I/O eviceday: %s"
|
||||
|
||||
#: daemon/x52d_io.c:80
|
||||
#: daemon/x52d_io.c:73
|
||||
#, c-format
|
||||
msgid "Error %d reading from X52 I/O device: %s"
|
||||
msgstr "Erroray %d eadingray omfray X52 I/O eviceday: %s"
|
||||
|
||||
#: daemon/x52d_io.c:99
|
||||
#: daemon/x52d_io.c:100
|
||||
#, c-format
|
||||
msgid "Error %d initializing X52 I/O library: %s"
|
||||
msgstr "Erroray %d initializingay X52 ibrarylay: %s"
|
||||
|
||||
#: daemon/x52d_io.c:105
|
||||
#: daemon/x52d_io.c:106
|
||||
#, c-format
|
||||
msgid "Error %d initializing I/O driver thread: %s"
|
||||
msgstr "Erroray %d initializingay I/O iverdray eadthray: %s"
|
||||
|
||||
#: daemon/x52d_io.c:112
|
||||
#: daemon/x52d_io.c:113
|
||||
msgid "Shutting down X52 I/O driver thread"
|
||||
msgstr "Uttingshay ownday X52 I/O iverdray eadthray"
|
||||
|
||||
|
|
Loading…
Reference in New Issue