Check if mouse is enabled before reporting buttons

Prior to this change, the IO thread would always report a mouse button
event, even if the mouse was disabled in configuration, or the uinput
device was not created. This results in unexpected button/wheel events.

This change checks that the uinput device has been created and the mouse
has been enabled in the configuration before reporting a button or wheel
event.
reverse-scroll
nirenjan 2022-02-03 11:11:41 -08:00
parent 5ab4784b21
commit cf6811d923
3 changed files with 8 additions and 4 deletions

View File

@ -197,6 +197,10 @@ void x52d_mouse_report_event(libx52io_report *report)
if (report) { if (report) {
memcpy((void *)&new_report, report, sizeof(new_report)); memcpy((void *)&new_report, report, sizeof(new_report));
if (!mouse_uidev_created || !mouse_thr_enabled) {
return;
}
state_changed = false; state_changed = false;
state_changed |= (0 == report_button_change(BTN_LEFT, LIBX52IO_BTN_MOUSE_PRIMARY)); state_changed |= (0 == report_button_change(BTN_LEFT, LIBX52IO_BTN_MOUSE_PRIMARY));
state_changed |= (0 == report_button_change(BTN_RIGHT, LIBX52IO_BTN_MOUSE_SECONDARY)); state_changed |= (0 == report_button_change(BTN_RIGHT, LIBX52IO_BTN_MOUSE_SECONDARY));

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: libx52 0.2.3\n" "Project-Id-Version: libx52 0.2.3\n"
"Report-Msgid-Bugs-To: https://github.com/nirenjan/libx52/issues\n" "Report-Msgid-Bugs-To: https://github.com/nirenjan/libx52/issues\n"
"POT-Creation-Date: 2021-11-22 10:08-0800\n" "POT-Creation-Date: 2022-02-03 11:11-0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -861,7 +861,7 @@ msgstr ""
msgid "Virtual mouse not created. Ignoring thread state change" msgid "Virtual mouse not created. Ignoring thread state change"
msgstr "" msgstr ""
#: daemon/x52d_mouse_evdev.c:232 #: daemon/x52d_mouse_evdev.c:236
#, c-format #, c-format
msgid "Error %d creating X52 virtual mouse: %s" msgid "Error %d creating X52 virtual mouse: %s"
msgstr "" msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: libx52 0.2.3\n" "Project-Id-Version: libx52 0.2.3\n"
"Report-Msgid-Bugs-To: https://github.com/nirenjan/libx52/issues\n" "Report-Msgid-Bugs-To: https://github.com/nirenjan/libx52/issues\n"
"POT-Creation-Date: 2021-11-22 10:08-0800\n" "POT-Creation-Date: 2022-02-03 11:11-0800\n"
"PO-Revision-Date: 2021-11-04 15:35-0700\n" "PO-Revision-Date: 2021-11-04 15:35-0700\n"
"Last-Translator: Nirenjan Krishnan <nirenjan@gmail.com>\n" "Last-Translator: Nirenjan Krishnan <nirenjan@gmail.com>\n"
"Language-Team: Dummy Language for testing i18n\n" "Language-Team: Dummy Language for testing i18n\n"
@ -913,7 +913,7 @@ msgstr "Uttingshay ownday X52 irtualvay ousemay iverdray eadthray"
msgid "Virtual mouse not created. Ignoring thread state change" msgid "Virtual mouse not created. Ignoring thread state change"
msgstr "Irtualvay ousemay otnay eatedcray. Ignoringa eadthray atestay angechay" msgstr "Irtualvay ousemay otnay eatedcray. Ignoringa eadthray atestay angechay"
#: daemon/x52d_mouse_evdev.c:232 #: daemon/x52d_mouse_evdev.c:236
#, c-format #, c-format
msgid "Error %d creating X52 virtual mouse: %s" msgid "Error %d creating X52 virtual mouse: %s"
msgstr "Erroray %d eatingcray X52 irtualvay ousemay: %s" msgstr "Erroray %d eatingcray X52 irtualvay ousemay: %s"