mirror of https://github.com/nirenjan/libx52.git
Reset reports on thread create and device disconnection
This ensures that if the device gets disconnected while the axis is held outside of the default position, the axis will get reset.reverse-scroll
parent
276b512478
commit
2a8ca8424e
|
@ -71,6 +71,8 @@ static void *x52_io_thr(void *param)
|
|||
|
||||
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;
|
||||
break;
|
||||
|
||||
|
|
|
@ -106,6 +106,15 @@ static int report_axis(int axis, int index)
|
|||
return rc;
|
||||
}
|
||||
|
||||
static void reset_reports(void)
|
||||
{
|
||||
memset((void *)&old_report, 0, sizeof(old_report));
|
||||
/* Set the default thumbstick values to the mid-point */
|
||||
old_report.axis[LIBX52IO_AXIS_THUMBX] = 8;
|
||||
old_report.axis[LIBX52IO_AXIS_THUMBY] = 8;
|
||||
memcpy((void *)&new_report, (void *)&old_report, sizeof(new_report));
|
||||
}
|
||||
|
||||
static void * x52_mouse_thr(void *param)
|
||||
{
|
||||
bool state_changed;
|
||||
|
@ -166,11 +175,7 @@ void x52d_mouse_evdev_thread_control(bool enabled)
|
|||
PINELOG_TRACE("Ignoring re-enable mouse thread");
|
||||
return;
|
||||
} else {
|
||||
memset((void *)&old_report, 0, sizeof(old_report));
|
||||
/* Set the default thumbstick values to the mid-point */
|
||||
old_report.axis[LIBX52IO_AXIS_THUMBX] = 8;
|
||||
old_report.axis[LIBX52IO_AXIS_THUMBY] = 8;
|
||||
memcpy((void *)&new_report, (void *)&old_report, sizeof(new_report));
|
||||
reset_reports();
|
||||
x52d_mouse_thr_init();
|
||||
}
|
||||
} else {
|
||||
|
@ -186,7 +191,11 @@ void x52d_mouse_evdev_thread_control(bool enabled)
|
|||
|
||||
void x52d_mouse_report_event(libx52io_report *report)
|
||||
{
|
||||
memcpy((void *)&new_report, report, sizeof(new_report));
|
||||
if (report) {
|
||||
memcpy((void *)&new_report, report, sizeof(new_report));
|
||||
} else {
|
||||
reset_reports();
|
||||
}
|
||||
}
|
||||
|
||||
void x52d_mouse_evdev_init(void)
|
||||
|
@ -217,6 +226,7 @@ void x52d_mouse_evdev_init(void)
|
|||
|
||||
void x52d_mouse_evdev_exit(void)
|
||||
{
|
||||
x52d_mouse_evdev_thread_control(false);
|
||||
mouse_uidev_created = false;
|
||||
libevdev_uinput_destroy(mouse_uidev);
|
||||
}
|
||||
|
|
|
@ -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 17:04-0700\n"
|
||||
"POT-Creation-Date: 2021-09-14 17:33-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"
|
||||
|
@ -724,22 +724,22 @@ msgstr ""
|
|||
msgid "Error %d opening X52 I/O device: %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_io.c:78
|
||||
#: daemon/x52d_io.c:80
|
||||
#, c-format
|
||||
msgid "Error %d reading from X52 I/O device: %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_io.c:97
|
||||
#: daemon/x52d_io.c:99
|
||||
#, c-format
|
||||
msgid "Error %d initializing X52 I/O library: %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_io.c:103
|
||||
#: daemon/x52d_io.c:105
|
||||
#, c-format
|
||||
msgid "Error %d initializing I/O driver thread: %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_io.c:110
|
||||
#: daemon/x52d_io.c:112
|
||||
msgid "Shutting down X52 I/O driver thread"
|
||||
msgstr ""
|
||||
|
||||
|
@ -773,28 +773,28 @@ msgstr ""
|
|||
msgid "Error writing mouse axis event (axis %d, value %d)"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:114
|
||||
#: daemon/x52d_mouse_evdev.c:123
|
||||
msgid "Starting X52 virtual mouse driver thread"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:127
|
||||
#: daemon/x52d_mouse_evdev.c:136
|
||||
msgid "Error writing mouse sync event"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:146
|
||||
#: daemon/x52d_mouse_evdev.c:155
|
||||
#, c-format
|
||||
msgid "Error %d initializing mouse thread: %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:153
|
||||
#: daemon/x52d_mouse_evdev.c:162
|
||||
msgid "Shutting down X52 virtual mouse driver thread"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:160
|
||||
#: daemon/x52d_mouse_evdev.c:169
|
||||
msgid "Virtual mouse not created. Ignoring thread state change"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:211
|
||||
#: daemon/x52d_mouse_evdev.c:220
|
||||
#, c-format
|
||||
msgid "Error %d creating X52 virtual mouse: %s"
|
||||
msgstr ""
|
||||
|
|
22
po/xx_PL.po
22
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 17:04-0700\n"
|
||||
"POT-Creation-Date: 2021-09-14 17:33-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"
|
||||
|
@ -773,22 +773,22 @@ msgstr "Artingstay X52 I/O eadthray"
|
|||
msgid "Error %d opening X52 I/O device: %s"
|
||||
msgstr "Erroray %d openingay X52 I/O eviceday: %s"
|
||||
|
||||
#: daemon/x52d_io.c:78
|
||||
#: daemon/x52d_io.c:80
|
||||
#, 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:97
|
||||
#: daemon/x52d_io.c:99
|
||||
#, c-format
|
||||
msgid "Error %d initializing X52 I/O library: %s"
|
||||
msgstr "Erroray %d initializingay X52 ibrarylay: %s"
|
||||
|
||||
#: daemon/x52d_io.c:103
|
||||
#: daemon/x52d_io.c:105
|
||||
#, c-format
|
||||
msgid "Error %d initializing I/O driver thread: %s"
|
||||
msgstr "Erroray %d initializingay I/O iverdray eadthray: %s"
|
||||
|
||||
#: daemon/x52d_io.c:110
|
||||
#: daemon/x52d_io.c:112
|
||||
msgid "Shutting down X52 I/O driver thread"
|
||||
msgstr "Uttingshay ownday X52 I/O iverdray eadthray"
|
||||
|
||||
|
@ -822,28 +822,28 @@ msgstr "Erroray itingwray ousemay eelwhay eventay %d"
|
|||
msgid "Error writing mouse axis event (axis %d, value %d)"
|
||||
msgstr "Erroray itingwray ousemay axisay eventay (axisay %d, aluevay %d)"
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:114
|
||||
#: daemon/x52d_mouse_evdev.c:123
|
||||
msgid "Starting X52 virtual mouse driver thread"
|
||||
msgstr "Artingstay X52 irtualvay ousemay iverdray eadthray"
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:127
|
||||
#: daemon/x52d_mouse_evdev.c:136
|
||||
msgid "Error writing mouse sync event"
|
||||
msgstr "Erroray itingwray ousemay yncsay eventay"
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:146
|
||||
#: daemon/x52d_mouse_evdev.c:155
|
||||
#, c-format
|
||||
msgid "Error %d initializing mouse thread: %s"
|
||||
msgstr "Erroray %d initializingay ousemay eadthray: %s"
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:153
|
||||
#: daemon/x52d_mouse_evdev.c:162
|
||||
msgid "Shutting down X52 virtual mouse driver thread"
|
||||
msgstr "Uttingshay ownday X52 irtualvay ousemay iverdray eadthray"
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:160
|
||||
#: daemon/x52d_mouse_evdev.c:169
|
||||
msgid "Virtual mouse not created. Ignoring thread state change"
|
||||
msgstr "Irtualvay ousemay otnay eatedcray. Ignoringa eadthray atestay angechay"
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:211
|
||||
#: daemon/x52d_mouse_evdev.c:220
|
||||
#, c-format
|
||||
msgid "Error %d creating X52 virtual mouse: %s"
|
||||
msgstr "Erroray %d eatingcray X52 irtualvay ousemay: %s"
|
||||
|
|
Loading…
Reference in New Issue