Add option to reverse mouse scroll direction

This change adds a ReverseScroll parameter to the configuration, which
if set, will change the direction of the scroll wheel of the virtual
mouse.

Github-Issue: #45
cpp
nirenjan 2022-06-05 11:18:45 -07:00
parent d0f0232dae
commit 95a10b5ac9
8 changed files with 52 additions and 16 deletions

View File

@ -85,6 +85,9 @@ Enabled=yes
# Speed is proportional to the speed of updates to the virtual mouse # Speed is proportional to the speed of updates to the virtual mouse
Speed=0 Speed=0
# ReverseScroll reverses the direction of the virtual scroll wheel
ReverseScroll=no
###################################################################### ######################################################################
# Profiles - only valid on Linux # Profiles - only valid on Linux
###################################################################### ######################################################################

View File

@ -75,6 +75,9 @@ CFG(Mouse, Enabled, mouse_enabled, bool, true)
// virtual mouse // virtual mouse
CFG(Mouse, Speed, mouse_speed, int, 0) CFG(Mouse, Speed, mouse_speed, int, 0)
// ReverseScroll controls the scrolling direction
CFG(Mouse, ReverseScroll, mouse_reverse_scroll, bool, false)
/********************************************************************** /**********************************************************************
* Profiles - only valid on Linux * Profiles - only valid on Linux
*********************************************************************/ *********************************************************************/

View File

@ -39,6 +39,7 @@ struct x52d_config {
bool mouse_enabled; bool mouse_enabled;
int mouse_speed; int mouse_speed;
bool mouse_reverse_scroll;
bool clutch_enabled; bool clutch_enabled;
bool clutch_latched; bool clutch_latched;
@ -71,6 +72,7 @@ void x52d_cfg_set_Brightness_MFD(uint16_t param);
void x52d_cfg_set_Brightness_LED(uint16_t param); void x52d_cfg_set_Brightness_LED(uint16_t param);
void x52d_cfg_set_Mouse_Enabled(bool param); void x52d_cfg_set_Mouse_Enabled(bool param);
void x52d_cfg_set_Mouse_Speed(int param); void x52d_cfg_set_Mouse_Speed(int param);
void x52d_cfg_set_Mouse_ReverseScroll(bool param);
void x52d_cfg_set_Profiles_Directory(char* param); void x52d_cfg_set_Profiles_Directory(char* param);
void x52d_cfg_set_Profiles_ClutchEnabled(bool param); void x52d_cfg_set_Profiles_ClutchEnabled(bool param);
void x52d_cfg_set_Profiles_ClutchLatched(bool param); void x52d_cfg_set_Profiles_ClutchLatched(bool param);

View File

@ -24,6 +24,7 @@
volatile int mouse_delay = DEFAULT_MOUSE_DELAY; volatile int mouse_delay = DEFAULT_MOUSE_DELAY;
volatile int mouse_mult = MOUSE_MULT_FACTOR; volatile int mouse_mult = MOUSE_MULT_FACTOR;
volatile int mouse_scroll_dir = 1;
void x52d_cfg_set_Mouse_Enabled(bool enabled) void x52d_cfg_set_Mouse_Enabled(bool enabled)
{ {
@ -60,3 +61,15 @@ void x52d_cfg_set_Mouse_Speed(int speed)
mouse_delay = new_delay; mouse_delay = new_delay;
mouse_mult = new_mult; mouse_mult = new_mult;
} }
void x52d_cfg_set_Mouse_ReverseScroll(bool enabled)
{
PINELOG_DEBUG(_("Setting mouse reverse scroll to %s"),
enabled ? _("on") : _("off"));
if (enabled) {
mouse_scroll_dir = -1;
} else {
mouse_scroll_dir = 1;
}
}

View File

@ -14,6 +14,7 @@
extern volatile int mouse_delay; extern volatile int mouse_delay;
extern volatile int mouse_mult; extern volatile int mouse_mult;
extern volatile int mouse_scroll_dir;
#define MOUSE_MULT_FACTOR 4 #define MOUSE_MULT_FACTOR 4

View File

@ -57,10 +57,10 @@ static int report_wheel(void)
if (scroll_up) { if (scroll_up) {
// Scroll up event // Scroll up event
wheel = 1; wheel = 1 * mouse_scroll_dir;
} else if (scroll_dn) { } else if (scroll_dn) {
// Scroll down event // Scroll down event
wheel = -1; wheel = -1 * mouse_scroll_dir;
} }
if (wheel != 0) { if (wheel != 0) {

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: 2022-05-16 10:47-0700\n" "POT-Creation-Date: 2022-06-05 08:22-0700\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"
@ -142,11 +142,13 @@ msgstr ""
msgid "Unknown LED state %d" msgid "Unknown LED state %d"
msgstr "" msgstr ""
#: libx52/x52_stringify.c:47 daemon/x52d_clock.c:29 daemon/x52d_mouse.c:31 #: libx52/x52_stringify.c:47 daemon/x52d_clock.c:29 daemon/x52d_mouse.c:32
#: daemon/x52d_mouse.c:68
msgid "off" msgid "off"
msgstr "" msgstr ""
#: libx52/x52_stringify.c:48 daemon/x52d_clock.c:29 daemon/x52d_mouse.c:31 #: libx52/x52_stringify.c:48 daemon/x52d_clock.c:29 daemon/x52d_mouse.c:32
#: daemon/x52d_mouse.c:68
msgid "on" msgid "on"
msgstr "" msgstr ""
@ -810,21 +812,26 @@ msgstr ""
msgid "Shutting down X52 I/O driver thread" msgid "Shutting down X52 I/O driver thread"
msgstr "" msgstr ""
#: daemon/x52d_mouse.c:30 #: daemon/x52d_mouse.c:31
#, c-format #, c-format
msgid "Setting mouse enable to %s" msgid "Setting mouse enable to %s"
msgstr "" msgstr ""
#: daemon/x52d_mouse.c:46 #: daemon/x52d_mouse.c:47
#, c-format #, c-format
msgid "Ignoring mouse speed %d outside supported range (0-%d)" msgid "Ignoring mouse speed %d outside supported range (0-%d)"
msgstr "" msgstr ""
#: daemon/x52d_mouse.c:58 #: daemon/x52d_mouse.c:59
#, c-format #, c-format
msgid "Setting mouse speed to %d (delay %d ms, multiplier %f)" msgid "Setting mouse speed to %d (delay %d ms, multiplier %f)"
msgstr "" msgstr ""
#: daemon/x52d_mouse.c:67
#, c-format
msgid "Setting mouse reverse scroll to %s"
msgstr ""
#: daemon/x52d_mouse_evdev.c:43 #: daemon/x52d_mouse_evdev.c:43
#, c-format #, c-format
msgid "Error writing mouse button event (button %d, state %d)" msgid "Error writing mouse button event (button %d, state %d)"

View File

@ -7,15 +7,15 @@ 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: 2022-05-16 10:47-0700\n" "POT-Creation-Date: 2022-06-05 08:22-0700\n"
"PO-Revision-Date: 2021-11-04 15:35-0700\n" "PO-Revision-Date: 2022-06-05 08:51-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"
"Language: xx_PL\n" "Language: xx_PL\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.0\n" "X-Generator: Poedit 3.0.1\n"
#: libx52/x52_strerror.c:23 libx52io/io_strings.c:101 #: libx52/x52_strerror.c:23 libx52io/io_strings.c:101
msgid "Success" msgid "Success"
@ -142,11 +142,13 @@ msgstr "YYay-MMay-DDay"
msgid "Unknown LED state %d" msgid "Unknown LED state %d"
msgstr "Unknownay EDLay atestay %d" msgstr "Unknownay EDLay atestay %d"
#: libx52/x52_stringify.c:47 daemon/x52d_clock.c:29 daemon/x52d_mouse.c:31 #: libx52/x52_stringify.c:47 daemon/x52d_clock.c:29 daemon/x52d_mouse.c:32
#: daemon/x52d_mouse.c:68
msgid "off" msgid "off"
msgstr "offay" msgstr "offay"
#: libx52/x52_stringify.c:48 daemon/x52d_clock.c:29 daemon/x52d_mouse.c:31 #: libx52/x52_stringify.c:48 daemon/x52d_clock.c:29 daemon/x52d_mouse.c:32
#: daemon/x52d_mouse.c:68
msgid "on" msgid "on"
msgstr "onay" msgstr "onay"
@ -862,21 +864,26 @@ msgstr "Erroray %d initializingay I/O iverdray eadthray: %s"
msgid "Shutting down X52 I/O driver thread" msgid "Shutting down X52 I/O driver thread"
msgstr "Uttingshay ownday X52 I/O iverdray eadthray" msgstr "Uttingshay ownday X52 I/O iverdray eadthray"
#: daemon/x52d_mouse.c:30 #: daemon/x52d_mouse.c:31
#, c-format #, c-format
msgid "Setting mouse enable to %s" msgid "Setting mouse enable to %s"
msgstr "Ettingsay ousemay enableay otay %s" msgstr "Ettingsay ousemay enableay otay %s"
#: daemon/x52d_mouse.c:46 #: daemon/x52d_mouse.c:47
#, c-format #, c-format
msgid "Ignoring mouse speed %d outside supported range (0-%d)" msgid "Ignoring mouse speed %d outside supported range (0-%d)"
msgstr "Ignoringay ousemay eedspay %d outsideay upportedsay angeray (0-%d)" msgstr "Ignoringay ousemay eedspay %d outsideay upportedsay angeray (0-%d)"
#: daemon/x52d_mouse.c:58 #: daemon/x52d_mouse.c:59
#, c-format #, c-format
msgid "Setting mouse speed to %d (delay %d ms, multiplier %f)" msgid "Setting mouse speed to %d (delay %d ms, multiplier %f)"
msgstr "Ettingsay ousemay eedspay otay %d (elayday %d ms, ultipliermay %f)" msgstr "Ettingsay ousemay eedspay otay %d (elayday %d ms, ultipliermay %f)"
#: daemon/x52d_mouse.c:67
#, c-format
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:43
#, c-format #, c-format
msgid "Error writing mouse button event (button %d, state %d)" msgid "Error writing mouse button event (button %d, state %d)"