diff --git a/daemon/x52d_mouse_evdev.c b/daemon/x52d_mouse_evdev.c index 58e2009..9b8a6a8 100644 --- a/daemon/x52d_mouse_evdev.c +++ b/daemon/x52d_mouse_evdev.c @@ -30,13 +30,21 @@ static bool mouse_uidev_created = false; static volatile libx52io_report old_report; static volatile libx52io_report new_report; +static bool button_changed(int index, bool *new_value) +{ + bool changed = old_report.button[index] != new_report.button[index]; + if (changed) { + *new_value = new_report.button[index]; + } + return changed; +} + static int report_button_change(int button, int index) { int rc = 1; - bool old_button = old_report.button[index]; - bool new_button = new_report.button[index]; + bool new_button; - if (old_button != new_button) { + if (button_changed(index, &new_button)) { rc = libevdev_uinput_write_event(mouse_uidev, EV_KEY, button, (int)new_button); if (rc != 0) { @@ -52,8 +60,10 @@ static int report_wheel(void) { int rc = 1; int wheel = 0; - bool scroll_up = new_report.button[LIBX52IO_BTN_MOUSE_SCROLL_UP]; - bool scroll_dn = new_report.button[LIBX52IO_BTN_MOUSE_SCROLL_DN]; + bool scroll_up = false; + bool scroll_dn = false; + button_changed(LIBX52IO_BTN_MOUSE_SCROLL_UP, &scroll_up); + button_changed(LIBX52IO_BTN_MOUSE_SCROLL_DN, &scroll_dn); if (scroll_up) { // Scroll up event diff --git a/po/libx52.pot b/po/libx52.pot index b2ec05d..e1db518 100644 --- a/po/libx52.pot +++ b/po/libx52.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: libx52 0.2.3\n" "Report-Msgid-Bugs-To: https://github.com/nirenjan/libx52/issues\n" -"POT-Creation-Date: 2022-06-05 08:22-0700\n" +"POT-Creation-Date: 2022-06-05 12:59-0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -832,43 +832,43 @@ msgstr "" msgid "Setting mouse reverse scroll to %s" msgstr "" -#: daemon/x52d_mouse_evdev.c:43 +#: daemon/x52d_mouse_evdev.c:51 #, c-format msgid "Error writing mouse button event (button %d, state %d)" msgstr "" -#: daemon/x52d_mouse_evdev.c:69 +#: daemon/x52d_mouse_evdev.c:79 #, c-format msgid "Error writing mouse wheel event %d" msgstr "" -#: daemon/x52d_mouse_evdev.c:102 +#: daemon/x52d_mouse_evdev.c:112 #, c-format msgid "Error writing mouse axis event (axis %d, value %d)" msgstr "" -#: daemon/x52d_mouse_evdev.c:115 +#: daemon/x52d_mouse_evdev.c:125 msgid "Error writing mouse sync event" msgstr "" -#: daemon/x52d_mouse_evdev.c:134 +#: daemon/x52d_mouse_evdev.c:144 msgid "Starting X52 virtual mouse driver thread" msgstr "" -#: daemon/x52d_mouse_evdev.c:157 +#: daemon/x52d_mouse_evdev.c:167 #, c-format msgid "Error %d initializing mouse thread: %s" msgstr "" -#: daemon/x52d_mouse_evdev.c:164 +#: daemon/x52d_mouse_evdev.c:174 msgid "Shutting down X52 virtual mouse driver thread" msgstr "" -#: daemon/x52d_mouse_evdev.c:171 +#: daemon/x52d_mouse_evdev.c:181 msgid "Virtual mouse not created. Ignoring thread state change" msgstr "" -#: daemon/x52d_mouse_evdev.c:236 +#: daemon/x52d_mouse_evdev.c:246 #, c-format msgid "Error %d creating X52 virtual mouse: %s" msgstr "" diff --git a/po/xx_PL.po b/po/xx_PL.po index f055275..1c553cc 100644 --- a/po/xx_PL.po +++ b/po/xx_PL.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: libx52 0.2.3\n" "Report-Msgid-Bugs-To: https://github.com/nirenjan/libx52/issues\n" -"POT-Creation-Date: 2022-06-05 08:22-0700\n" +"POT-Creation-Date: 2022-06-05 12:59-0700\n" "PO-Revision-Date: 2022-06-05 08:51-0700\n" "Last-Translator: Nirenjan Krishnan \n" "Language-Team: Dummy Language for testing i18n\n" @@ -884,43 +884,43 @@ msgstr "Ettingsay ousemay eedspay otay %d (elayday %d ms, ultipliermay %f)" msgid "Setting mouse reverse scroll to %s" msgstr "Ettingsay ousemay everseray ollscray otay %s" -#: daemon/x52d_mouse_evdev.c:43 +#: daemon/x52d_mouse_evdev.c:51 #, c-format msgid "Error writing mouse button event (button %d, state %d)" msgstr "Erroray itingwray ousemay uttonbay eventay (uttonbay %d, atestay %d)" -#: daemon/x52d_mouse_evdev.c:69 +#: daemon/x52d_mouse_evdev.c:79 #, c-format msgid "Error writing mouse wheel event %d" msgstr "Erroray itingwray ousemay eelwhay eventay %d" -#: daemon/x52d_mouse_evdev.c:102 +#: daemon/x52d_mouse_evdev.c:112 #, c-format 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:115 +#: daemon/x52d_mouse_evdev.c:125 msgid "Error writing mouse sync event" msgstr "Erroray itingwray ousemay yncsay eventay" -#: daemon/x52d_mouse_evdev.c:134 +#: daemon/x52d_mouse_evdev.c:144 msgid "Starting X52 virtual mouse driver thread" msgstr "Artingstay X52 irtualvay ousemay iverdray eadthray" -#: daemon/x52d_mouse_evdev.c:157 +#: daemon/x52d_mouse_evdev.c:167 #, c-format msgid "Error %d initializing mouse thread: %s" msgstr "Erroray %d initializingay ousemay eadthray: %s" -#: daemon/x52d_mouse_evdev.c:164 +#: daemon/x52d_mouse_evdev.c:174 msgid "Shutting down X52 virtual mouse driver thread" msgstr "Uttingshay ownday X52 irtualvay ousemay iverdray eadthray" -#: daemon/x52d_mouse_evdev.c:171 +#: daemon/x52d_mouse_evdev.c:181 msgid "Virtual mouse not created. Ignoring thread state change" msgstr "Irtualvay ousemay otnay eatedcray. Ignoringa eadthray atestay angechay" -#: daemon/x52d_mouse_evdev.c:236 +#: daemon/x52d_mouse_evdev.c:246 #, c-format msgid "Error %d creating X52 virtual mouse: %s" msgstr "Erroray %d eatingcray X52 irtualvay ousemay: %s"