Fix scroll event handling

Github-Issue: #45
reverse-scroll
nirenjan 2022-06-05 12:59:35 -07:00
parent 819d38fbd8
commit f1f7c72a59
3 changed files with 35 additions and 25 deletions

View File

@ -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

View File

@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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 ""

View File

@ -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 <nirenjan@gmail.com>\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"